commandcode 0.1.14: a Zero Data Retention switch sends x-cmd-zdr: 1 on the Provider API and Go's /alpha/generate (#246)

moonshardx (#246): Command Code keeps request content up to 30 days
unless Zero Data Retention is asked for (commandcode.ai/docs/resources/
zdr): CMD_ZDR=1 for the CLI, x-cmd-zdr: 1 on the Provider API. The
plugin had no way to send it.

- The plugin declares a "Zero Data Retention" switch (auth.options,
  magpie #2038, off by default, with a cost note to confirm). magpie
  shows it in the provider's editor; the plugin reads it through
  input.magpie.option at each request, so no restart is needed.
  CMD_ZDR=1 in the plugin process's environment also turns it on, as for
  the CLI; only "1" does, as the CLI's isCmdZdrEnabled reads it.
- While on, the Provider API request and Go's /alpha/generate request
  each carry x-cmd-zdr: 1. For /alpha/generate this mirrors the CLI: its
  1.84.0 bundle (npm pack, read, not run) adds [CMD_ZDR]:"1" in
  buildCommandAuthHeaders, and the installed CLI 1.74.1, run with
  CMD_ZDR=1 in a sandbox HOME through a logging pass-through proxy
  (COMMANDCODE_SANDBOX=true, COMMANDCODE_API_URL), sent x-cmd-zdr=1 on
  /alpha/generate and on every other request.
- A model with no ZDR upstream: the Provider API's 422 cmd_zdr_no_providers
  goes on as it came. On /alpha/generate Command Code answers 200 with an
  error line ({"type":"cmd_zdr_no_providers","code":
  "CMD_ZDR_NO_PROVIDERS","statusCode":400}); the agent gets that 400 and
  message as before, and now the error's type cmd_zdr_no_providers
  instead of commandcode_error.

Run: zdr.test.mjs is new (6 tests, fixtures are Command Code's literal
bodies from today). Broke each by hand and watched red: no option, no
Provider header, no generate header, CMD_ZDR read as truthy, the switch
read once, the 422 rewritten, the type dropped: 1 to 3 fail each.
bun test packages/commandcode: 55 pass, 1 skip, 0 fail.
bun scripts/check.mjs commandcode: ok. HOME=$(mktemp -d under $TMPDIR)
bun test: 1822 pass, 0 fail.
Live, with the owner's GOAT key, the plugin's fetch with the switch on:
Provider API deepseek-v4-flash 200 with x-cmd-zdr: 1; Provider API
poolside/laguna-s-2.1-free 422 cmd_zdr_no_providers, body as it came;
/alpha/generate (plan forced to Go) deepseek-v4-flash 200 with the header,
laguna 400 cmd_zdr_no_providers; with the switch off neither had the
header. Not tried: a real Go account (none here), the switch in magpie's
editor itself (driven by a stand-in for input.magpie), OpenCode.
This commit is contained in:
yetone
2026-10-19 18:24:20 +08:00
parent 24b08da95c
commit 5f101a5447
4 changed files with 209 additions and 12 deletions
+20
View File
@@ -48,6 +48,26 @@ When the plan isn't known yet and the Provider API refuses the key with
then on (and saved so with it), and a chat completion is sent again to
`/alpha/generate`.
## Zero Data Retention
[Zero Data Retention](https://commandcode.ai/docs/resources/zdr) sends
requests only to upstreams that keep no prompts or replies. It is off
until you turn it on, either way:
- **In magpie**: turn on **Zero Data Retention** in the Command Code
provider's editor (magpie v0.1.1231 or later). The switch is read at
each request, so it needs no restart.
- **Anywhere** (OpenCode too): set `CMD_ZDR=1` in the environment of the
process the plugin runs in, as for Command Code's CLI. Only `1` turns it
on.
While it is on, every request for a reply carries `x-cmd-zdr: 1`, on the
Provider API and on Go's `/alpha/generate` alike, as the CLI sends it with `CMD_ZDR=1`.
ZDR requests usually cost more. A model with no ZDR upstream is refused,
and the refusal reaches the agent as Command Code said it: on the Provider
API a 422 with code `cmd_zdr_no_providers`, on Go a 400 whose type is
`cmd_zdr_no_providers`. Turn the switch off, or pick another model.
## Models
The `config` hook declares the default list: