Repository navigation
Conversation
ZDR was environment-only and read once at registration, so opting in needed
`CMD_ZDR=1` in the host's environment and opting back out needed a restart.
Nothing in the host surfaced which state was active.
- `commandcode.enableZDR: true` in the agent `settings.json` now opts in. The
documented `CMD_ZDR`/`COMMANDCODE_ZDR` variables keep precedence so a shell
export cannot be weakened by a file, and only a literal `true` counts.
- `/commandcode-zdr [on|off]` reports the effective state and writes the key,
preserving every other settings key. A malformed or non-object file is never
overwritten, and `off` is refused while the environment forces ZDR on.
- Host settings are unreadable while extensions load, so the opt-in starts from
the environment and is completed on `session_start`. A changed state
re-registers the provider, which is the only way to change a registration
header, so a toggle applies to the next request instead of the next restart.
- `createProviderConfig` now always registers a `headers` object
(`headers ?? {}`): pi merges a re-registration over the previous one and
preserves undefined values, so an absent object would keep sending a ZDR
header after it is turned off.
- `/commandcode-status` and `/commandcode-diagnostics` report the state.
pierreraby
left a comment
There was a problem hiding this comment.
Thanks for working on this. I tested this exact head with Pi 1.5.2 and Oh My Pi 18.22.0 against a loopback mock. The existing test suite passes on both, and Pi adds/removes the header on the next request without a restart. I found three gaps in additional tests:
- OMP reports ZDR on while inference still sends no ZDR header. Unset both ZDR environment variables, start OMP with a Command Code model using Responses, run
/commandcode-zdr on, then send a prompt. The command reports that the change applies to the next request, but the mock receives nox-cmd-zdr. After refreshing the host registry and reselecting the model, the header appears;/commandcode-zdr offthen leaves it on the next request. Restarting withcommandcode.enableZDR: truestill on disk reportsoffand sends no header. In a fresh OMP home, I also observed the host migrate the initialsettings.jsontosettings.json.bakand createconfig.yml. As a control,CMD_ZDR=1sends the header on both hosts. Please make the command track the actual outgoing header and use a storage path the host can read back, or scope the persistent command to Pi and leave OMP on the existing env-only path. An RPC test should assert the next HTTP request afteronandoff, not just the notification. - Quota keeps the startup header (
index.ts:510–513,src/quota-command.ts:57). With no env opt-in, run/commandcode-zdr on, then/commandcode-quota: I observed/alpha/whoamiwithoutx-cmd-zdr, even on Pi where inference sends it. Please resolve the current header when the quota command runs. - Saving replaces a symlinked
settings.json(src/zdr.ts:109). Withsettings.jsonpointing to a managed settings file, the save replaces the symlink with a regular file and leaves the target unchanged. Please preserve the link by updating its target, or refuse the save without changing either file; a temp-directory test can cover this.
- limit /commandcode-zdr on|off to pi; other hosts keep the CMD_ZDR env opt-in - resolve the ZDR header per /commandcode-quota run - update a symlinked settings.json through its target, refuse dangling links - test the next outgoing request after /commandcode-zdr on and off
|
Thanks @pierreraby, all three points are addressed in 116c7cb.
Test limitation: the quota fix is only covered by that unit test. The mock Command Code server in |
|
Thanks — I retested One remaining case on Pi: the command writes the global settings file, but startup reads the merged global and project settings through
Could we read and write this global opt-in from the same agent settings file, keeping |
- read the same agent-directory settings.json the command writes instead of the host's merged global+project view, so a project override cannot turn the persisted opt-in off after restart - treat a missing or malformed settings file as off during startup; the write path still refuses to overwrite it - add a restart regression with a conflicting trusted project setting - document that project .pi/settings.json is not consulted for this opt-in
|
Thanks @pierreraby — fixed in 32e44e1. Startup now reads the same file the command writes. This also means a project Restart regression test. In Checks on this commit: |
|
Thanks — I confirmed on Pi 1.5.2 that
|
- gate the startup settings.json read behind the same pi-only probe as the /commandcode-zdr write, so OMP keeps the environment-only contract and a leftover settings.json cannot turn ZDR on there; CMD_ZDR=1 still applies - strip one leading UTF-8 BOM in both the reader and the writer so the host's BOM-tolerant settings parser cannot silently drop the saved opt-in, while a malformed file is still refused on write - add unit regressions for BOM handling and an OMP regression that a leftover settings.json is ignored and the environment opt-in still works
|
Thanks — both regressions are fixed in
Checks run locally on |
|
Thanks for sticking with this, @Trex-Hub. I retested There's one small test-only fix left in
Once that's in, I'll rerun the full suite with OMP required. Thanks again for the contribution and the quick follow-ups. |
- move the shared chatArgs above the print-mode test and reuse it there and in both ZDR calls, fixing the ReferenceError when OMP is installed - create a native config.yml before the leftover settings.json fixture so OMP cannot migrate the legacy file away, and assert the file survived so the test fails on the buggy head for the right reason
|
Thanks @pierreraby — fixed in Both test-only adjustments are in
With both, the targeted case passes on Checks locally: |
|
Verified with OMP locally as well: installed OMP OMP_BIN=/home/harness/.local/bin/omp OMP_COMPAT_REQUIRED=1 node tests/test-omp-compat.mjsIt passes, including |
What
Makes the zero-data-retention opt-in configurable without a process restart, and visible.
ZDR was environment-only (
CMD_ZDR=1/COMMANDCODE_ZDR=1) and read once while the extension registered its models, so:How it resolves
CMD_ZDR=1(documented) orCOMMANDCODE_ZDR=1(legacy alias) — wins, so a shell export cannot be weakened by a settings file.{ "commandcode": { "enableZDR": true } }in the agentsettings.json(~/.pi/agent/settings.jsonfor pi).Only a literal
truecounts, so a typo cannot silently weaken privacy./commandcode-statusand/commandcode-diagnosticsnow print the effective state and its source./commandcode-zdr [on|off]on/off: writescommandcode.enableZDRinto the agentsettings.json, preserving every other key. A malformed or non-object file is refused rather than overwritten.offwhileCMD_ZDR/COMMANDCODE_ZDRis set is refused with an explanation, because the environment wins./commandcode-refreshuses, so the header changes on the next request and pi re-resolves the current model (_refreshCurrentModelFromRegistry).Two host details that shaped this
pi.getSettings()is not readable while extensions load (getSettings: notInitializedin the loader). The state therefore starts from the environment, which is readable at load, and is completed onsession_start. A state change re-registers the provider.ModelRuntime.registerProvidermerges a re-registration over the previous registration and preservesundefinedvalues.createProviderConfignow always registers aheadersobject (headers ?? {}); otherwise turning ZDR off would keep the previously registeredx-cmd-zdrheader. Model-level headers follow the same rule, so{}is what clears it.Settings written externally still apply only after
/reloador a restart, consistent with how the host reloads settings.Tests
tests/test-zdr.ts(new, wired intotestandtest:unitplus atest:zdrscript): env parsing,true-only settings, environment precedence, header/description, and the writer — preserving unrelated keys, creating a missing agent directory,0600mode, and refusing malformed or non-object files without modifying them.tests/test-pi-local.mjs: real pi against the mock API — withCMD_ZDRunset,settings.jsonalone sendsx-cmd-zdr: 1; with neither opt-in the header is absent; the RPC command list includescommandcode-zdr.npm run typecheck,npm run test:unit,node tests/test-pi-local.mjs,node tests/test-pi-isolated.mjs,node tests/test-pi-authenticated.mjs,node tests/test-endpoint-routing.mjs,node tests/test-host-protocols.mjs, thenode --testrelease/maintenance/host-helper batch,npm run typecheck:entrypointagainst installed pi 1.5.2,npm run format:check,git diff --check. OMP tests skip locally (noompbinary) and rely on CI.