Repository navigation
Auto review fails every tool call when the session model routes through OpenCode Go #10643
Replies: 1 comment 1 reply
|
The missing piece is that the review request carries no session identity, and the adapter only forwards one when it is given.
// packages/llm/llm-pi-ai/src/adapter.ts:420
...options.sessionId === undefined ? {} : { sessionId: String(options.sessionId) },And // packages/experimental/auto-review/src/index.ts:624-635
const options: GenerateOptions = deepFreeze({
provider: snapshot.provider,
model: snapshot.model,
system: REVIEW_POLICY,
messages: [{ role: 'user', content: [{ type: 'text', text: reviewUserText(snapshot) }] }],
temperature: 0,
signal,
})So the reviewer runs on the session's route ( Two fixes, and they are not equivalent:
I verified the DSH side of the chain above. I did not verify what |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Auto review fails every tool call when the session model routes through OpenCode Go
Environment
0.2.1-rc.2(nightly, macOS arm64)/permission auto), approval policyaskopencode-go/deepseek-v4.1-flash(OpenCode Go subscription, base URLhttps://opencode.ai/zen/go/v1)Symptom
With Auto selected, every native tool call is cancelled before its body executes:
Switching permission to
never(or a non-Auto preset) makes the exact same call succeed.Root cause
OpenCode Go requires
x-opencode-sessionon inference requests. pi-ai's opencode-goprovider injects that header via
withOpenCodeSessionHeader(), but only when the callsupplies
options.sessionId(@earendil-works/pi-ai/dist/providers/opencode-headers.js).Ordinary agent-loop requests pass
sessionId, and so do auxiliary calls such ascompaction (
packages/compaction/compaction-basic/src/summarizer.ts) and session titles(
packages/session/session-title-llm/src/index.ts). The Auto reviewer does not:classifyRisk()inpackages/experimental/auto-review/src/index.tsbuilds itsGenerateOptionswithoutsessionId, so the header is never added and OpenCode Gorejects the request with
400 MissingSessionID.Transport requirement (reproduced directly)
Suggested fix
Pass the Session identity on the reviewer request, matching the existing auxiliary-call
convention:
}], temperature: 0, + // The review travels the Session's own provider route, so it carries the + // Session identity an ordinary call does. Transports that key per-request + // routing on it (OpenCode Go requires `x-opencode-session`) reject an + // identity-free request. + sessionId: agent.session.id, signal, })Add a regression assertion to
packages/experimental/auto-review/tests/auto-review.e2e.tsso every reviewed call must record the Session identity it sent:
import { createUserMessage, isAgentLoopRequest, ToolCallId, + type GenerateOptions, type StreamChunk, } from '@deepseek-ai/dsh-llm' @@ const observations: Observation[] = [] + const reviewerSessions: GenerateOptions['sessionId'][] = [] let reviewCalls = 0 @@ reviewCalls += 1 + // The reviewer request must carry the Session identity: transports such + // as OpenCode Go key per-request routing on it and reject an anonymous call. + reviewerSessions.push(options.sessionId) expect(options.provider === PROVIDER && options.model === mainAgent.options.model).toBe(true) @@ return { observations, + reviewerSessions, postToolInputs, @@ expect(runner.calls() - calls, `${id}: reviewer count`).toBe(1) + // Every reviewed call must present the Session identity to the provider. + expect(runner.reviewerSessions.at(-1), `${id}: reviewer session`).toBe(agent.id) const observed = runner.observations.at(-1)Verification
Targeted suite (no API key needed; the deterministic reviewer fixtures are keyless):
Tests 1 failed | 2 passed (3)—AssertionError: L01: reviewer session: expected undefined to be '<uuid>'Test Files 1 passed (1),Tests 3 passed (3).oxlinton both changed files: 0 warnings, 0 errors.pnpm run typecheck: 5 gates passed, 0 failed.Impact
Only the experimental Auto preset combined with a model route that requires
per-request session routing (pi-ai wraps both OpenCode provider routes,
opencode/ OpenCode Zenand
opencode-go, with this header). Other providers are unaffected.User-side workarounds: choose a non-Auto preset, or pin a literal
headers.x-opencode-sessionon the provider route (at the cost of per-session routing).Patch
All reactions