Repository navigation
Replies: 1 comment
|
cordis const next = () => (cbs.shift() ?? inner)(...args); // next() takes no parametersso Working version — wrap the export const name = "opencode-session-fallback";
export const inject = ["llm"];
const FALLBACK = "dsh-unknown-session";
const PATCHED = Symbol.for("opencode-session-fallback");
const withFallback = (o) =>
o && typeof o === "object" && o.sessionId === undefined ? { ...o, sessionId: FALLBACK } : o;
export function apply(ctx) {
const llm = ctx.llm;
if (!llm) return;
const wrap = (original) => function (options) {
return original.call(this, withFallback(options));
};
for (const target of [Object.getPrototypeOf(llm), llm]) {
try {
if (target && target[PATCHED] !== true && typeof target.stream === "function") {
target.stream = wrap(target.stream);
target[PATCHED] = true;
}
} catch { /* a proxied cordis service may reject the instance write; the prototype pass covers it */ }
}
}Register it the same way from the profile layer ( Verified working on 0.2.1-rc.5 / macOS: reviewer calls now carry the header and the auto preset executes tools normally. Patching both prototype and instance is deliberate — cordis service objects may be proxied. The one-line |
Uh oh!
There was an error while loading. Please reload this page.
Summary
With any
opencode-go/*model route, selecting the auto / 自动审查 permission preset makes every tool call fail before its body runs. Non-auto presets are unaffected, and this is still present in 0.2.1-rc.5.Environment
opencode-go/deepseek-v4.1-flash@deepseek-ai/dsh-experimental-auto-reviewRoot cause
dsh-experimental-auto-review→classifyRisk()builds the reviewer request from the session's provider/model only:sessionIdis missing. Theopencode-goprovider attaches its mandatory routing header only when that field exists (@earendil-works/pi-ai,providers/opencode-headers.js):The agent loop passes
sessionId: session.idon normal turns, so chat works; the reviewer call does not, gets a 400, and the preset then fails closed — no tool body ever executes.Verified against the gateway
POST https://opencode.ai/zen/go/v1/chat/completionswith an identical body:x-opencode-session400 MissingSessionIDx-opencode-session: dsh-unknown-session200So any stable value satisfies routing — the reviewer does not need the real session id for the call to succeed.
Fix
const options = deepFreeze({ provider: snapshot.provider, model: snapshot.model, + sessionId: agent.session.id, system: REVIEW_POLICY,Workaround (no ASAR patching, survives app updates)
A small user plugin on the
llm/streamwaterfall that defaultssessionIdonly when the caller omitted it. Main-turn calls keep their real id, so per-session routing and caching are untouched.Register it from the profile layer (
$DSH_HOME/profiles/<profile>/cordis.patch.yml):Suggestion
If a provider declares that it needs a routing identity, an
llm.streamcall that omitssessionIdshould fail loudly at dispatch time (or be caught at boot) rather than surfacing later as a 400 that the preset turns into "deny every tool call".Related
Same defect was reported earlier against rc.2 — #11423, #9972, #8764, #10643, #10381. Posting this one for the 0.2.1-rc.5 confirmation, the gateway-level probe, and a user-side workaround that unblocks the preset today.
All reactions