docs: document ClaudeAgentOptions.env field#1048
Open
ashishpatel26 wants to merge 2 commits into
Open
Conversation
Expand the one-line docstring on ClaudeAgentOptions.env to explain: - that it merges on top of the parent process env (additive, not replace) - which SDK-managed variables are injected and their override priority - that CLAUDECODE is stripped from the inherited env - usage example showing ANTHROPIC_API_KEY and CLAUDE_AGENT_SDK_CLIENT_APP - what CLAUDE_AGENT_SDK_CLIENT_APP does (User-Agent tagging) Closes anthropics#934
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.
Summary
ClaudeAgentOptions.envdocstring from a one-liner into a full explanation of how the field worksenvextends the parent process environment rather than replacing itCLAUDE_CODE_ENTRYPOINT,CLAUDE_AGENT_SDK_VERSION) can or cannot be overriddenCLAUDECODEis stripped from the inherited env (to prevent CLI self-detection confusion)ANTHROPIC_API_KEYandCLAUDE_AGENT_SDK_CLIENT_APPCLAUDE_AGENT_SDK_CLIENT_APPdoes (User-Agent header tagging for API usage attribution)Fixes #934.
Test plan
ClaudeAgentOptions.envinsrc/claude_agent_sdk/types.pyand verify it accurately reflects the subprocess merge logic in_internal/transport/subprocess_cli.py(lines 430–435)uv run ruff check src/ tests/ --fix && uv run ruff format src/ tests/passes with no changes