Repository navigation
feat: skip Supermemory for subagents, headless runs and helper prompts by default - #125
Merged
Merged
Conversation
…s by default Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…#126) * Re-serve cached recall for repeat queries and expire opening-prompt dedupe after 24h Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * Skip values of opencode value flags in headless detection and time out parent lookups Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * Accept yes/on/no/off for env flags and document OpenCode 2 run and inherited orchestrator env Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * Scope the recall cache to backend and credential, clear it on logout, and write cache files 0600 Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * chore(release): 2.2.0 Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --------- Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
… logout (#127) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Gate V5 session capture (V1 capture hook and OpenCode 2 compaction, cadence and session-end uploads) with the subagent/headless skip. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
MaheshtheDev
added a commit
to supermemoryai/supermemory
that referenced
this pull request
Nov 26, 2026
opencode-supermemory 2.3.0 (supermemoryai/opencode-supermemory#125): src/services/session-scope.ts skips subagent and v1 headless sessions, src/services/local-dedupe.ts adds the opening-prompt (200 chars, 24h, legacy capture only) and recall-query (10 min) indexes; flags and env vars in src/config.ts. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Dhravya's call (Nov 6): subagents, headless runs and host helper prompts should not hit Supermemory by default. A Pro customer running swarms of one-shot workers had ~60% of his bill in worker captures. This PR covers both OpenCode V1 (
opencode-ai) and OpenCode 2 (@opencode/cli). It also adds the Captain's scope additions: orchestrator handling, opening-prompt dedupe and a recall-query repeat skip. It also checks that worktree tags collapse correctly, with no tag changes.What is detected and how
session.parentID, read throughclient.session.get(cached, and primed fromsession.created/session.updatedevents). Thetasktool creates child sessions withparentID(packages/opencode/src/session/session.ts:520).opencode runuses the same field to spot subagents (src/cli/cmd/run.ts:693).session.get().parentID. Thesubagenttool spawns child sessions (packages/core/src/tool/plugin/subagent.ts), and core plugins skip children the same way (packages/core/src/plugin/warming.ts:117).process.argv:runorgithub run. Both host the server and plugins in the CLI process (src/cli/cmd/run.ts"Non-interactive (default)";src/cli/cmd/github.ts). The TUI runs plugins in a worker of the default$0 [project]command, so it is not matched.opencode runreuses the shared background service when it is up (packages/cli/src/commands/handlers/run.ts), and otherwise spawnsserve --stdiowith the same command line the TUI's--standaloneuses (packages/cli/src/services/standalone.ts). No session field, header or env marks the run. OpenCode 2runis still treated as interactive.chat.message(src/session/prompt.ts:193-250,ensureTitle). Compaction creates its user message withoutchat.message(src/session/compaction.ts:559). Neither reaches recall hooks, and the existing capture already dropssummary: truemessages. Verified: 0 calls from them (search count = 1 per real prompt).SessionRequestKind = "primary" | "compaction" | "title" | "generate"(packages/plugin/src/promise/session.ts:66), and the plugin only hookscontextandcompaction. Verified: 0 calls from title. The plugin's own compaction enrichment still runs for interactive top-level sessions (documented feature) and is skipped for subagents.Content heuristics are not used anywhere.
Orchestrators (Captain research)
CONDUCTOR_WORKSPACE_PATHandCONDUCTOR_SESSION_ID(https://www.conductor.build/docs/reference/environment-variables). Vibe Kanban setsVK_WORKSPACE_ID(BloopAI/vibe-kanbancrates/local-deployment/src/container.rs:1367-1368). When one of these is set, the process counts as interactive, even underopencode run.captureOrchestrated(defaulttrue; envSUPERMEMORY_CAPTURE_ORCHESTRATED=false) turns recall and capture off for those sessions.stravu/crystalclaudeCodeManager.ts), so itsrun-style sessions on V1 fall under the headless default unlesscaptureHeadlessis set. Claude Squad drives the interactive TUI, so it is unaffected.--standaloneand torunwithout a background service, which inherit the CLI env. They do not apply to a background service started elsewhere.Opt-in / opt-out settings
Each setting lives in
~/.config/opencode/supermemory.json(c). Each env var overrides its config field, andtrue/1/false/0are accepted.captureSubagentsfalseSUPERMEMORY_CAPTURE_SUBAGENTStruerestores recall, capture and compaction memory for child sessionscaptureHeadlessfalseSUPERMEMORY_CAPTURE_HEADLESStruerestores them for V1opencode run/github runcaptureOrchestratedtrueSUPERMEMORY_CAPTURE_ORCHESTRATEDfalseskips Conductor / Vibe Kanban sessionsdedupeOpeningPrompttrueSUPERMEMORY_DEDUPE_OPENING_PROMPTfalsealways sends repeated opening promptsdedupeRecallQueriestrueSUPERMEMORY_DEDUPE_RECALL_QUERIESfalsealways recalls on repeated queriesContainer tags, customIds and metadata shapes are unchanged. Only first-turn content changes, and only when
dedupeOpeningPromptfires.Opening-prompt dedupe and recall-query skip
~/.supermemory-opencode/opening-prompts.jsonholds up to 1,000 entries, keyed bysha256(containerTag + whitespace-normalised prompt)and mapped to the session that first captured the prompt. Another session sending the same opening prompt has the first message of its turn-1 batch replaced with[Opening prompt omitted: identical to one already captured from this machine (sha256:…)]. The rest of the conversation is still captured.~/.supermemory-opencode/recall-queries.jsonholds up to 500 entries with a 10-minute window, keyed by container tag and lowercased, whitespace-collapsed query. Matching is exact only.skipQueryseam inbuildDirectRecallResult, which is the hook point for future recall-skip checks.Worktree collapse (verified, no tag changes)
Linked worktrees already resolve through
git rev-parse --git-common-dirto the base checkout, so Conductor-style parallel worktrees share the base repo's container, with or without an origin remote. This PR does not changetags.ts. Checked against real git 2.55 repositories:app,app/sub,conductor/workspaces/app/{tokyo,lima}repo_app__6fad7069f7bdd12e(all)app2,conductor/workspaces/app2/oslorepo_app2__bdcc5edc12fbd02e(both)app5.git,app5-main,app5-featrepo_app5__ee0edee1265913fb(all)Cross-plugin follow-up: worktrees of a bare repo with no origin. A bare repo has no main checkout, so every worktree hashes its own path and gets its own tag. Examples:
app3-main→repo_app3_main__f972104f17bcd4cfandapp3-feat→repo_app3_feat__356186b748a0c2ae; in the.barelayout,proj4/main→repo_main__2fa87958050dac2c. This is left unchanged on purpose. OpenCode, Codex and Claude share containers, and Codex (#77) and Claude (#160) also left this case alone. Fixing it in one plugin would split a user's memories away from the other two clients, so the fix needs to land in all three plugins together.Verification on the real hosts
opencode-ai@1.19.5and@opencode/cli@2.2.6from npm./v1/chat/completionsstreaming) via an@ai-sdk/openai-compatiblecustom provider. It answers with fixed text, or with atask(V1) /subagent(OC2) tool call when the prompt containsSPAWN_SUBAGENT.baseUrlinsupermemory.jsonwith a dummy key. It logs every method and path.mainwas built side by side.--standalone./v4/profile+ 11/v4/searchfan-out over read tags + 1/v3/documentscapture). OC2 counts 19 because it re-sends the same customId at shutdown, which is existing behaviour.mainopencode runrun+SUPERMEMORY_CAPTURE_HEADLESS=truerun+ subagent +CAPTURE_HEADLESS=trueSUPERMEMORY_CAPTURE_SUBAGENTS=truecaptureSubagents/captureHeadless: truein the config filerunwithCONDUCTOR_WORKSPACE_PATHsetSUPERMEMORY_CAPTURE_ORCHESTRATED=falseDEDUPE_OPENING_PROMPT=false DEDUPE_RECALL_QUERIES=false--standalone, prompt that spawns a subagentrun+ subagentrun+ subagent +SUPERMEMORY_CAPTURE_SUBAGENTS=truerun, plain (headless undetectable)run+ Conductor env +CAPTURE_ORCHESTRATED=falseExcerpt from the Supermemory stub log, V1 worker 2:
Plugin log in the subagent runs:
Automatic memory skipped for subagent session: {"sessionID":"ses_e4c23c122ffe…"}. Plugin log in the V1run:Automatic memory disabled for this process: {"reason":"headless"}.Repo checks:
bun run typecheck,bun test(46 pass, including newsession-scope,local-dedupeand V2 subagent tests) andbun run build. A test preload (bunfig.toml→scripts/test-preload.mjs) pointsos.homedir()at a temp dir, so tests never read or write the developer's~/.supermemory-opencodeor config.Not detectable
opencode run, SDK clients of the background service). The host exposes no signal to plugins.opencode run --attach <url>and SDK clients ofopencode serve. The plugin lives in the server, which cannot see the client's command line.