[Bug] Compaction summarizer never passes sessionId, so PR #2131's OpenCode headers are absent for that one call — every compaction fails on the OpenCode free tier
#2162
japorto100
started this conversation in
Bug reports
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Follow-up to #2072 and #2110, and specifically to the fix in #2131 (merged 2026-09-09). Those
addressed the missing OpenCode session header for provider requests. The compaction summarizer is
still affected, because it never supplies a
sessionIdfor the adapter to use.What happens
On
opencode / muse-spark-1.3-contributor-free(free tier), a session ran 500+ normal turns withouta single provider error. Every compaction attempt failed:
Reproduced twice, through both entry points:
await compact.run()from the Python kernel —Requested compaction failed: Summarization failed: …/compactfrom the TUI —Compaction failed: Turn prefix summarization failed: …Both go through
AgentSession._performCompaction, so this is not specific to how compaction istriggered. Version observed: 0.9.4.
Why
packages/coding-agent/src/core/compaction/compaction.tsbuilds the summarizer's completion optionswithout a
sessionId:generateSummary— line 556-559:{ maxTokens, signal, apiKey, headers }(plusreasoning)generateTurnPrefixSummary— line 826-829: the same shapesessionIddoes not occur anywhere in that file (0 occurrences in 845 lines at HEAD, commit read2026-09-09).
A normal turn does supply it:
Agent.sessionId→createLoopConfig()→sessionId: this.sessionId,which reaches the same
streamSimple/provider path the summarizer uses. The adapters then derivethe header from it, and only from it:
packages/ai/src/providers/opencode-headers.ts:if (sessionId) merged["x-opencode-session"] = sessionId;packages/ai/src/providers/openai-responses.ts,createClient:if (sessionId) { … headers.session_id = sessionId; headers["x-client-request-id"] = sessionId; }So the summarizer call is the one request in a session's lifetime that carries no session identity,
and #2131 could not change that — it fixed the adapters, and the adapters receive
undefined.The PR's file list confirms it touches only
packages/ai/src/providers/*and their tests.Other providers hide the same gap: the OpenAI-Codex adapter falls back to
options?.sessionId || createCodexRequestId(), so a missingsessionIdis invisible there. OpenCodehas no fallback and rejects with 400, which is why this surfaces only on that provider even though
the missing field is provider-independent.
A fix that works, for whatever it is worth
compact()already accepts aSummaryCallRunner(line 707) whose stated purpose is that hosts"decorate each call with its own request identity", and
_performCompactionalready uses it toattach the semantic-edge request id.
sessionManageris in scope there, so the session headers canbe added at that same point without changing any function signature:
…and spreading that into both
call(...)branches of the existingsummaryCall.Applied as a local patch on 0.9.4, the same
/compactin the same session that had just failedcompleted successfully:
Compacted from 137,879 tokens. (Header names there are the pre-#2131 ones;on current
mainthe equivalent would flow throughwithOpenCodeHeaders.)Passing
sessionIddown intocompletionOptionsincompaction.tswould be the more direct fix andwould let the adapters set whatever each provider needs — including
x-opencode-session— but thatis a maintainer call and touches signatures.
Scope and limits
mainat runtime — the source reading above is fromHEAD, the runtime reproduction is on the released 0.9.4.
Happy to test a maintainer's fix against the same reproduction.
All reactions