Compare commits

..

2 Commits

2 changed files with 17 additions and 0 deletions

View File

@ -163,6 +163,17 @@ The log captures the request (model id, body byte length), each HTTP attempt (st
wait, elapsed ms), every stream event payload, and the terminal finish reason + usage. It is wait, elapsed ms), every stream event payload, and the terminal finish reason + usage. It is
useful for diagnosing model selection, retry, tool-call, and finish-reason issues. useful for diagnosing model selection, retry, tool-call, and finish-reason issues.
## ZDR header toggle
The `x-cmd-zdr: 1` request header is **omitted by default** because it is rejected by some
models. Set `COMMANDCODE_ZDR=1` (or `true`/`yes`) when launching opencode to opt back in. The
value is read once at provider load, so restart opencode after changing it. Per-provider
overrides still win: `headers: { "x-cmd-zdr": "..." }` in `opencode.json` takes precedence over
the environment variable.
With `COMMANDCODE_DEBUG` enabled, the trace logs a `zdr on|off` line per request so the toggle
state is observable.
## Features ## Features
| Capability | Status | | Capability | Status |

View File

@ -23,6 +23,10 @@ import { redact } from "./redact.js";
import { transform } from "./transform.js"; import { transform } from "./transform.js";
import { finishReasonFrom, usageFromFinish, type FinishEvent } from "./usage.js"; import { finishReasonFrom, usageFromFinish, type FinishEvent } from "./usage.js";
// x-cmd-zdr breaks some models; off by default (server.py never sends it).
// COMMANDCODE_ZDR=1|true|yes opts back in. Read at load, like COMMANDCODE_DEBUG.
const ZDR_ENABLED = /^(1|true|yes)$/i.test(process.env["COMMANDCODE_ZDR"] ?? "");
export type CommandCodeOptions = { export type CommandCodeOptions = {
name?: string; name?: string;
apiKey?: string; apiKey?: string;
@ -139,8 +143,10 @@ class CommandCodeLanguageModel implements LanguageModelV3 {
"x-project-slug": "project", "x-project-slug": "project",
"x-taste-learning": "true", "x-taste-learning": "true",
"x-co-flag": "false", "x-co-flag": "false",
...(ZDR_ENABLED ? { "x-cmd-zdr": "1" } : {}),
...this.opts.headers, ...this.opts.headers,
}; };
debug("fetch", "zdr", ZDR_ENABLED ? "on" : "off");
const auth = bearer(this.opts.apiKey); const auth = bearer(this.opts.apiKey);
if (auth) headers["Authorization"] = auth; if (auth) headers["Authorization"] = auth;
for (const [k, v] of Object.entries(extra ?? {})) if (v !== undefined) headers[k] = v; for (const [k, v] of Object.entries(extra ?? {})) if (v !== undefined) headers[k] = v;