Skip to content

fix(opencode): exclude subagent sessions from capture and commit - #4988

Open
somewhere1994 wants to merge 1 commit into
volcengine:mainfrom
somewhere1994:fix/opencode-subagent-session-exclusion
Open

somewhere1994 wants to merge 1 commit into
volcengine:mainfrom
somewhere1994:fix/opencode-subagent-session-exclusion

Conversation

@somewhere1994

Copy link
Copy Markdown
Contributor

What

Subagent sessions were only excluded from recall injection; capture and commit still ran, so subagent transcripts leaked into the memory layer as regular events. Two defects were involved:

  1. message events can arrive without a parentID while racing the session-create event, defeating a naive "check parentID on the message" guard;
  2. the commit tool path committed subagent sessions with no parent check at all.

This PR:

  • excludes sessions that have a parentID from the memory loop at creation time (mirrors the DSH plugin's skipSubagentSessions);
  • authoritatively re-checks the parentID via the client API (client.session.get) before flushing — order-independent relative to message events, failing open when the query fails;
  • skips empty sessions and adds the parent guard to the commit tool path;
  • threads client through createMemorySessionManager.

Validation

  • Production-validated on a six-agent deployment over multi-day use: 0 subagent sessions leaked into the memory layer after this change (previously 1-2 leaked per heavy run, each requiring manual cleanup).
  • node --test examples/opencode-plugin/tests/ — 27 pass / 2 fail. The 2 failures (loadConfig derives workspace peer by default, loadConfig can disable workspace peer) fail identically on a clean main checkout — pre-existing, unrelated to this change.

Subagent sessions were only excluded from recall injection; capture and
commit still ran, leaking subagent transcripts into the memory layer as
regular events. Two defects were involved: message events carrying no
parentID race with the session-create event, and the commit tool path
committed subagent sessions without any parent check.

- Exclude sessions with a parentID from the memory loop at creation time
  (mirrors the DSH plugin's skipSubagentSessions).
- Authoritatively re-check parentID via the client API before flushing
  (order-independent), failing open when the query fails.
- Skip empty sessions and add a parent guard to the commit tool path.

Validated in production over multi-day use: 0 subagent sessions leaked
into the memory layer after this change (previously 1-2 leaked per heavy
run).

This branch has not been deployed

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

Labels

agent-plugins Agent harness and plugin integrations

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

2 participants