From 2e1e4dc27b8f82ca2448b40c488e91172cb255bd Mon Sep 17 00:00:00 2001 From: ashishpatel26 Date: Mon, 15 Jun 2026 11:28:39 +0530 Subject: [PATCH 1/2] docs: fix license reference in README to match MIT LICENSE file --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8d8445238..e5f587d55 100644 --- a/README.md +++ b/README.md @@ -354,6 +354,6 @@ The package is published to PyPI via the GitHub Actions workflow in `.github/wor The workflow tracks both the package version and the bundled CLI version separately, allowing you to release a new package version with an updated CLI without code changes. -## License and terms +## License -Use of this SDK is governed by Anthropic's [Commercial Terms of Service](https://www.anthropic.com/legal/commercial-terms), including when you use it to power products and services that you make available to your own customers and end users, except to the extent a specific component or dependency is covered by a different license as indicated in that component's LICENSE file. +This project is licensed under the [MIT License](LICENSE). From 90f114fdd82b111944bf9a2ba5a5109d73cf51e4 Mon Sep 17 00:00:00 2001 From: ashishpatel26 Date: Mon, 15 Jun 2026 11:28:40 +0530 Subject: [PATCH 2/2] docs: document ClaudeAgentOptions.env field for subprocess environment 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 #934 --- src/claude_agent_sdk/types.py | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/src/claude_agent_sdk/types.py b/src/claude_agent_sdk/types.py index 705648030..333d21d34 100644 --- a/src/claude_agent_sdk/types.py +++ b/src/claude_agent_sdk/types.py @@ -1775,10 +1775,35 @@ class ClaudeAgentOptions: """ env: dict[str, str] = field(default_factory=dict) - """Environment variables to pass to the Claude Code subprocess. + """Additional environment variables to pass to the Claude Code subprocess. - SDK consumers can identify their app/library in the User-Agent header by - setting ``CLAUDE_AGENT_SDK_CLIENT_APP`` (e.g. ``"my-app/1.0.0"``). + These are **merged on top of** the parent process environment: the + subprocess inherits every variable from the calling process (except + ``CLAUDECODE``, which is stripped to prevent the CLI from thinking it is + running inside another Claude Code instance), and the values in ``env`` + override or extend that inherited set. + + Two SDK-managed variables are always set and cannot be overridden by + ``env``: + + - ``CLAUDE_CODE_ENTRYPOINT`` is set to ``"sdk-py"`` by default; however, + values in ``env`` *can* override it (they are applied after the + default). + - ``CLAUDE_AGENT_SDK_VERSION`` is always stamped with the running SDK + version and cannot be overridden (it is applied last). + + Example — pass an API key and tag requests with your app name:: + + options = ClaudeAgentOptions( + env={ + "ANTHROPIC_API_KEY": "sk-ant-...", + "CLAUDE_AGENT_SDK_CLIENT_APP": "my-app/1.0.0", + } + ) + + ``CLAUDE_AGENT_SDK_CLIENT_APP`` is included in the ``User-Agent`` header + sent to the Anthropic API, which is useful for identifying your + application in usage logs. """ extra_args: dict[str, str | None] = field(default_factory=dict)