Repository navigation
agent: launches get one env policy, no API key unless named - #20
Merged
Merged
Conversation
Linux and Windows inherited fizzy's whole environment, so a stray ANTHROPIC_API_KEY could bill per token instead of the plan login. env.zig strips every *_API_KEY (and ANTHROPIC_AUTH_TOKEN) from the child's environment; "Use API key from environment" (off by default) forwards only the variables named in "api_key_vars". The chat's start note says "plan login" or "API key: <VAR> forwarded". Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Policy struct carries the setting so "off" forwards nothing by construction; env.spawn is the one place environ_map is set, with a test that spawns a child and checks its environment; status allocates instead of truncating; no file-scope buffer. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
foxnne
marked this pull request as ready for review
October 21, 2026 14:38
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of fizzyedit/work#10
Linux and Windows spawned the agent with fizzy's whole environment, so a stray
*_API_KEYcould bill per token instead of the person's plan login. Now:src/env.zig:child()copies the environment minus every*_API_KEYandANTHROPIC_AUTH_TOKEN(case-insensitive), then adds back only the names the person listed.Agent.spawnpasses it asenviron_map.use_api_key("Use API key from environment", off by default) andapi_key_vars(names only, never a value).(plan login)or(API key: <VAR> forwarded); only names are ever printed.zig build test, including one that spawns a real child and checks its environment, which fails ifenviron_mapis dropped) fail if any*_API_KEYreaches the child by default, and check opt-in forwards only named variables and that status never contains a value.Limits: the filter is name-based (
*_API_KEY,ANTHROPIC_AUTH_TOKEN), soCLAUDE_CODE_OAUTH_TOKEN,AWS_BEARER_TOKEN_BEDROCKand*_APIKEYstill pass; the opt-in list can name any variable,ANTHROPIC_AUTH_TOKENincluded.Environ.Mapcompares names case-insensitively on Windows (checked in std, with a Windows-only test).Not done: macOS still goes through
core.darwin_spawn, whose fixed allowlist already carries no API key but cannot add the opt-in; that needs an env option in fizzy'sdarwin_spawn(a fizzy PR). The macOS status always says "plan login".Verified on Windows 11:
zig fmt,zig build,zig build testpass (SDK 0.2.32). The app was not launched, so the status note and settings rows were not seen on screen.🤖 Generated with Claude Code