Skip to content

docs: document ClaudeAgentOptions.env field#1048

Open
ashishpatel26 wants to merge 2 commits into
anthropics:mainfrom
ashishpatel26:fix/issue-934-document-env-option
Open

docs: document ClaudeAgentOptions.env field#1048
ashishpatel26 wants to merge 2 commits into
anthropics:mainfrom
ashishpatel26:fix/issue-934-document-env-option

Conversation

@ashishpatel26

Copy link
Copy Markdown

Summary

  • Expands the ClaudeAgentOptions.env docstring from a one-liner into a full explanation of how the field works
  • Documents the additive/merge semantics: env extends the parent process environment rather than replacing it
  • Clarifies the exact merge order and which SDK-managed variables (CLAUDE_CODE_ENTRYPOINT, CLAUDE_AGENT_SDK_VERSION) can or cannot be overridden
  • Notes that CLAUDECODE is stripped from the inherited env (to prevent CLI self-detection confusion)
  • Adds a usage example showing ANTHROPIC_API_KEY and CLAUDE_AGENT_SDK_CLIENT_APP
  • Explains what CLAUDE_AGENT_SDK_CLIENT_APP does (User-Agent header tagging for API usage attribution)

Fixes #934.

Test plan

  • Read the updated docstring at ClaudeAgentOptions.env in src/claude_agent_sdk/types.py and 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

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

discussion: ClaudeAgentOptions.env only supports implicit parent-env inheritance with no documented isolated environment mode

1 participant