Open
Conversation
Syncs the Go SDK with changes from the Python Claude Agent SDK since commit 4e8e7c9, covering 2 bug fixes and 4 new features. Bug fixes: - Use --thinking adaptive/disabled flags instead of --max-thinking-tokens for non-budget thinking modes (aligns with CLI v2.1.96+) - Only pass --setting-sources when non-empty to avoid CLI arg parser issues Features: - Add ExcludeDynamicSections to SystemPromptPreset for cross-user prompt caching - Add WithSessionID option (--session-id CLI flag) - Expose ToolUseID in PermissionContext for tool permission callbacks - Add WithMaxResultSizeChars for MCP SDK tools to bypass 50K char truncation Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
42c747d to
2f1f18d
Compare
CLI v2.1.98 does not thread --permission-prompt-tool through to the streaming mode options object. The flag value is only included in the --print (one-shot) path, but streaming mode (--input-format stream-json) constructs its options without permissionPromptToolName, causing the permission handler to use the default auto-approve path instead of the control protocol. This is confirmed as a CLI bug affecting both the Go and Python SDKs. Tests are left failing until the CLI fix lands. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2f1f18d to
d3df7ec
Compare
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
Syncs the Go SDK with upstream changes from the Python Claude Agent SDK since commit
4e8e7c9fde85d92a53d7a7ca890cd0131c3f754a(38 commits, filtering to 6 meaningful changes).Bug Fixes
Fix thinking flag CLI args (python#796) —
ThinkingConfigAdaptiveandThinkingConfigDisabledwere incorrectly mapped to--max-thinking-tokens 32000/--max-thinking-tokens 0. The CLI (v2.1.96+) now expects--thinking adaptiveand--thinking disabled. OnlyThinkingConfigEnabled(with explicit budget) still uses--max-thinking-tokens.Fix --setting-sources passed when empty (python#778) — When
SettingSourceswas nil or empty, the SDK passed--setting-sources ""to the CLI, which caused the CLI's arg parser to consume the next flag as the value. Now only emits the flag whenlen > 0, consistent withAllowedTools,DisallowedTools, andBetas.Features
ExcludeDynamicSectionsin SystemPromptPreset (python#797) — Whentrue, the CLI strips per-user dynamic sections (working directory, auto-memory, git status) from the system prompt so it's byte-identical across users, enabling cross-user prompt caching. Sent asexcludeDynamicSectionsin the initialize control request. NewWithExcludeDynamicSections(bool)option.WithSessionIDoption (python#750) — AddsSessionIDfield mapped to--session-idCLI flag, allowing users to specify a custom session ID (distinct from--resumewhich resumes an existing session).ToolUseIDin PermissionContext (python#754) — Exposes thetool_use_idfield (already sent by the CLI and extracted for deduplication) in thePermissionContextpassed toCanUseToolcallbacks. Enables permission logic based on specific tool call IDs.MCP
maxResultSizeCharsvia_meta(python#756) — SDK MCP tools can now declareWithMaxResultSizeChars(n)to override the CLI's default 50K character hard limit for tool output. The value is forwarded as_meta: {"anthropic/maxResultSizeChars": n}in tools/list responses.Already present in Go SDK (no changes needed)
These Python SDK additions were already implemented in the Go SDK:
"auto"PermissionModeAgentDefinitionbackground/effort/permissionModefieldscontrol_cancel_requesthandlingget_context_usage()/GetContextUsage()Not applicable
Annotatedtype for per-parameter@tooldescriptions (Python-specific)connect()fix (Go SDK already handles this correctly)Files changed (15)
internal/cli/command.gointernal/cli/command_test.gointernal/cli/cli_test.gointernal/config/options.goSessionIDfield, updated doc commentinternal/config/preset.goExcludeDynamicSectionsfield onSystemPromptPresetinternal/protocol/session.goexcludeDynamicSectionsin initialize payload,ToolUseIDinparsePermissionContextinternal/protocol/session_test.gointernal/permission/permission.goToolUseIDfield onContextinternal/mcp/sdk_server.goAddToolWithOptions,_metainListToolsinternal/mcp/sdk_server_test.gooptions.goWithSessionID,WithExcludeDynamicSectionsoptionssdk_mcp_tool.goMaxResultSizeCharsfield,WithMaxResultSizeCharsoptionsdk_mcp_tool_test.gosdk_mcp_server.goMaxResultSizeCharsthrough to internal serverexamples/extended_thinking/main.goTest plan
go test -race ./...— all tests passgolangci-lint run --new-from-rev=origin/master— 0 issues🤖 Generated with Claude Code