Repository navigation
agent-guards: harness speed env in the managed settings drop-in - #1161
Conversation
With --settings the drop-in now carries an "env" of Claude Code speed variables (BASH_MAX_OUTPUT_LENGTH 12000, MAX_MCP_OUTPUT_TOKENS 8000, API_TIMEOUT_MS 180000, DISABLE_AUTOUPDATER 1; auto-compact window and prompt-cache TTLs known but off). The machine file's "agent-guards"."harnessEnv" rows override a value or take it out (null). A variable another managed settings file sets is left to it. A drop-in of an earlier release (hooks only) is still the kit's and upgrades. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
lens: code · reviewer: Claude Opus 5.5 · read at: 7f01791 blocker: none Checked and fine. All four default names are real: each is read in the 2.1.325 binary, and none is ignored. State (runs again / stops half-way / old or empty state).
🤖 Generated with Claude Code |
- DISABLE_AUTOUPDATER is off by default: the kit ships no update path, so it would freeze each machine's Claude Code version. Opt-in per machine. - API_TIMEOUT_MS 300000: it also caps a large request's first-byte watchdog and a whole non-streaming fallback answer. - MAX_MCP_OUTPUT_TOKENS 15000: a t3_thread_read page fits twice. - Variables T3 sets per session (prompt-cache TTLs, auto-compact window, FORCE_PROMPT_CACHING_5M) are refused in harnessEnv: managed env would silently override T3's value. - agent-guards self-check names each variable where the drop-in and the machine file differ (an edit without a reinstall). Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Fix round 1, head 284143a. Each point now has a test written first: it failed on the previous head and passes now.
Tests: agent-guards install 32, config 20, wiring 24, fast 45; common machine_file 27; the fork-checks scripts pass. 🤖 Generated with Claude Code |
|
lens: code · reviewer: Claude Opus 5.5 · read at: 284143a blocker: none round 1, fixed: Checked and fine. Self-check reads the same machine file as the installer: the same default path, and both owner uids are 0. A broken file gives the defaults in both, so the comparison matches what the installer would write. Values are compared as text on both sides ( State (runs again / stops half-way / old or empty state).
🤖 Generated with Claude Code |
* agent-guards: harness speed env in the managed settings drop-in With --settings the drop-in now carries an "env" of Claude Code speed variables (BASH_MAX_OUTPUT_LENGTH 12000, MAX_MCP_OUTPUT_TOKENS 8000, API_TIMEOUT_MS 180000, DISABLE_AUTOUPDATER 1; auto-compact window and prompt-cache TTLs known but off). The machine file's "agent-guards"."harnessEnv" rows override a value or take it out (null). A variable another managed settings file sets is left to it. A drop-in of an earlier release (hooks only) is still the kit's and upgrades. Co-Authored-By: Claude Opus 5.5 <[email protected]> * agent-guards: harnessEnv review round 1 - DISABLE_AUTOUPDATER is off by default: the kit ships no update path, so it would freeze each machine's Claude Code version. Opt-in per machine. - API_TIMEOUT_MS 300000: it also caps a large request's first-byte watchdog and a whole non-streaming fallback answer. - MAX_MCP_OUTPUT_TOKENS 15000: a t3_thread_read page fits twice. - Variables T3 sets per session (prompt-cache TTLs, auto-compact window, FORCE_PROMPT_CACHING_5M) are refused in harnessEnv: managed env would silently override T3's value. - agent-guards self-check names each variable where the drop-in and the machine file differ (an edit without a reinstall). Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
Part of #1094 (agent speed). This PR covers the harness speed settings; the rest of #1094 is not touched here.
What
With
--settings, the agent-guards managed settings drop-in (/etc/claude-code/managed-settings.d/agent-guards.json) now also has an"env"of Claude Code speed variables. Every session on a fork machine gets them. The defaults are config (agent_guards.config.HARNESS_ENV). A machine can change any of them in its machine file, as rows under"agent-guards"."harnessEnv":A row's value replaces the default.
nulltakes the variable out. Any other variable can be added.BASH_MAX_OUTPUT_LENGTH12000bashOutputMaxCharssetting overrides it)MAX_MCP_OUTPUT_TOKENS15000t3_thread_readpage (at most 30000 bytes, about 7.5k tokens) fits twiceAPI_TIMEOUT_MS300000DISABLE_AUTOUPDATER"1")CLAUDE_CODE_PROMPT_CACHE_TTL,CLAUDE_CODE_SUBAGENT_PROMPT_CACHE_TTL,CLAUDE_CODE_AUTO_COMPACT_WINDOW,FORCE_PROMPT_CACHING_5MharnessEnvrow naming one is left out and named. Set them in T3Every name was checked against code.claude.com/docs/en/env-vars and settings-reference (docs.claude.com/…/settings now redirects there). No name was dropped as unlisted. The prompt-cache TTL (
promptCacheTtl/subagentPromptCacheTtl, and their env forms) and the auto-compact window are not set by the kit, because T3 sets them per session (review round 1).Merge, never clobber
managed-settings.jsonfirst and thenmanaged-settings.d/*.jsonalphabetically.envmerges key by key and the later file wins. So the installer leaves out of the drop-in any variable thatmanaged-settings.jsonor another drop-in already sets, and names it (managed settings env left to <file>: …). It never writes those files.envwins over user and projectenvand over a shell export. That is how managed settings work. A machine that needs another value sets it inharnessEnv.MAX_MCP_OUTPUT_TOKENSmatchestoken. A name that looks like a secret is still refused here (the drop-in is world-readable), unless it is one of the kit's own known names. Bad rows and repeated names are left out and named by the installer andagent-guards self-check.State
write_fileskips the write; covered by a snapshot test with an override and a foreign managed env).planand written only in the existingsettingsstep, together with the hooks, in one atomic write. The existing every-step stop tests pass with env on. A stop beforesettingsleaves the old drop-in (with or without env) whole, and the next run writes the new one.wiring.oursnow accepts an optionalenvof strings) and is rewritten with env. No machine file, no section, noharnessEnvor[]gives the defaults. A machine file that cannot be read gives the defaults with a warning, and the install goes on (this is speed, not safety).--no-settingsremoves the env along with the hooks.Tests (written first, red on main, then green)
install.test.py(32 OK): defaults in the drop-in for no machine file / no section / no key / empty list; a machine value wins andnullremoves the key (all off → noenvkey); a foreign managed env is not clobbered; a broken machine file or bad/secret rows keep the defaults and are named; an old hooks-only drop-in upgrades and rollback removes it; idempotent re-run.config.test.py(18 OK): row parsing and problems;load_allacceptsharnessEnvand names its problems; the example file.wiring.test.py(24 OK):drop_in_text(env=…),ourswith env.agent-guards self-checkcompares the drop-in's env with what the machine file gives now (less what other managed files set) and names each difference, e.g. aharnessEnvedit without a reinstall, or an old drop-in without env.config.test.py, 20 OK): DISABLE_AUTOUPDATER off by default, API_TIMEOUT_MS ≥ 300000, MAX_MCP_OUTPUT_TOKENS ≥ two t3_thread_read pages, and T3-set variables refused.fast,read-size,facts,poll-loop,batch-nudge; commonkit_install(189),machine_file,alert; fork-checks schema/upstream-files/seam scripts and their tests (197).Note
An older release's installer does not know about
env, so it treats the new drop-in as not its own: installing an older sha with--settingsrefuses until the drop-in is removed by hand. Rollback withinstall --no-settingson the current release works as before.🤖 Generated with Claude Code