Skip to content

stop() and ephemeral-agent cleanup never close their ContextManagers, so strategies are never detached on teardown #550

Open

Description

@Anarchid

What's wrong (main b82ba630)

  • stop() (src/framework.ts ~3746–3763) syncs and closes an owned store, but calls no ContextManager.close() for any agent first.
  • The cleanup returned for an ephemeral agent (~7705–7708) is empty ("Just release the CM"), so it releases nothing.
  • stop() waits for the framework's maintenance pass, not for a strategy's own speculative drain. connectome-host enables autoTickOnNewMessage, so that drain runs on every message.

context-manager #215 adds ContextStrategy.detach(), which ContextManager.close() calls, so that a closed manager's strategy stops compressing and draining. The framework's only ContextManager.close() is in offline-branch recovery, so none of that applies when the framework stops or releases an ephemeral agent.

Why it matters

  • At stop(), a speculative compression already out can land against a closed store. By reading, its post-call check then throws and is logged as a drain error: the call was paid for and its result lost.
  • A "released" ephemeral agent's strategy stays attached to the shared store, and its drain can keep calling the provider and writing under its namespace.

How it was found

Traced by the second reviewer while reviewing context-manager #215; each cited line was checked. The behaviour after the store closes is from reading, not from a run.

Suggested fix

Call contextManager.close() for each agent's manager before closing the store in stop(), and in the ephemeral cleanup.

Found during our review of anima-research/context-manager#215: anima-research/context-manager#215 (review)

Posted by the maintainer's desk assistant.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions