claude-agent-sdk 0.14.0 → 0.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +21 -15
- data/lib/claude_agent_sdk/query.rb +4 -1
- data/lib/claude_agent_sdk/subprocess_cli_transport.rb +6 -9
- data/lib/claude_agent_sdk/types.rb +4 -2
- data/lib/claude_agent_sdk/version.rb +1 -1
- data/lib/claude_agent_sdk.rb +20 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2a7bc7ca34128ea7dd30f519fcef30ce934b1c05e8387e97f626ba6a0d19d5dc
|
|
4
|
+
data.tar.gz: e61274c9565ebb637d67917803d9c68b21964e4b91e0fa9d128ce8615efb4ff3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9c25ff87ec00eb19004445c112dd83b5dd180707d64ac3d916b54d7a7e733fccdb2d60973b73f1b06530393df8a0e02a60d1bafa8742e6bc685c52fdea4675f6
|
|
7
|
+
data.tar.gz: 49ee14d69651954d2615a1e5630637636d12b85c957c1d433c7d37bfdd8e6279cc2b8e9f7a7c0d4bc122374609bd66695696f3c3f5ea29ff7ee7a41f8f3bf570
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.14.1] - 2026-04-09
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
- **Thinking configuration**: Use `--thinking adaptive` / `--thinking disabled` CLI flags instead of mapping to `--max-thinking-tokens`. Previously, `ThinkingConfigAdaptive` was mapped to `--max-thinking-tokens 32000` (fixed budget) and `ThinkingConfigDisabled` to `--max-thinking-tokens 0`, which put the CLI into the wrong mode. Only `ThinkingConfigEnabled` now uses `--max-thinking-tokens`. (Parity with [Python SDK #796](https://github.com/anthropics/claude-agent-sdk-python/pull/796))
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
- **`exclude_dynamic_sections`** on `SystemPromptPreset`: When set to `true`, the CLI strips per-user dynamic sections (working directory, auto-memory, git status) from the preset system prompt and re-injects them into the first user message. This makes the system prompt byte-identical across users, enabling cross-user prompt-caching hits. Sent via `excludeDynamicSections` in the initialize control message; older CLIs silently ignore it. (Parity with [Python SDK #797](https://github.com/anthropics/claude-agent-sdk-python/pull/797))
|
|
15
|
+
|
|
8
16
|
## [0.14.0] - 2026-04-08 — Python SDK v0.1.51–0.1.56 Parity
|
|
9
17
|
|
|
10
18
|
### Added
|
data/README.md
CHANGED
|
@@ -128,11 +128,7 @@ gem install claude-agent-sdk
|
|
|
128
128
|
|
|
129
129
|
### Agentic Coding Skill
|
|
130
130
|
|
|
131
|
-
If you're using [Claude Code](https://claude.ai/claude-code)
|
|
132
|
-
|
|
133
|
-
**Option 1: Via Plugin Marketplace (recommended)**
|
|
134
|
-
|
|
135
|
-
This repo is a Claude Code plugin marketplace. Add it once, then install the skill:
|
|
131
|
+
If you're using [Claude Code](https://claude.ai/claude-code), this repo is a Claude Code plugin marketplace. Add it once, then install the skill:
|
|
136
132
|
|
|
137
133
|
```bash
|
|
138
134
|
# Add the marketplace
|
|
@@ -142,12 +138,6 @@ This repo is a Claude Code plugin marketplace. Add it once, then install the ski
|
|
|
142
138
|
/plugin install claude-agent-ruby@claude-agent-sdk-ruby
|
|
143
139
|
```
|
|
144
140
|
|
|
145
|
-
**Option 2: Via skills.sh**
|
|
146
|
-
|
|
147
|
-
```bash
|
|
148
|
-
npx skills add https://github.com/ya-luotao/claude-agent-sdk-ruby --skill claude-agent-sdk-ruby
|
|
149
|
-
```
|
|
150
|
-
|
|
151
141
|
This skill teaches your AI coding assistant about the SDK's APIs, patterns, and best practices, making it easier to get help writing code that uses this SDK.
|
|
152
142
|
|
|
153
143
|
## Quick Start
|
|
@@ -734,12 +724,12 @@ For complete examples, see [examples/structured_output_example.rb](examples/stru
|
|
|
734
724
|
Control extended thinking behavior with typed configuration objects. The `thinking` option takes precedence over the deprecated `max_thinking_tokens`.
|
|
735
725
|
|
|
736
726
|
```ruby
|
|
737
|
-
# Adaptive thinking —
|
|
727
|
+
# Adaptive thinking — CLI dynamically adjusts budget based on task complexity
|
|
738
728
|
options = ClaudeAgentSDK::ClaudeAgentOptions.new(
|
|
739
729
|
thinking: ClaudeAgentSDK::ThinkingConfigAdaptive.new
|
|
740
730
|
)
|
|
741
731
|
|
|
742
|
-
# Enabled thinking with
|
|
732
|
+
# Enabled thinking with explicit token budget
|
|
743
733
|
options = ClaudeAgentSDK::ClaudeAgentOptions.new(
|
|
744
734
|
thinking: ClaudeAgentSDK::ThinkingConfigEnabled.new(budget_tokens: 50_000)
|
|
745
735
|
)
|
|
@@ -760,6 +750,22 @@ options = ClaudeAgentSDK::ClaudeAgentOptions.new(
|
|
|
760
750
|
|
|
761
751
|
> **Note:** When `system_prompt` is `nil` (the default), the SDK passes `--system-prompt ""` to the CLI, which suppresses the default Claude Code system prompt. To use the default system prompt, use a `SystemPromptPreset`.
|
|
762
752
|
|
|
753
|
+
### Cross-User Prompt Caching
|
|
754
|
+
|
|
755
|
+
When running a multi-user fleet with shared preset prompts, enable `exclude_dynamic_sections` to make the system prompt byte-identical across users for prompt-caching hits:
|
|
756
|
+
|
|
757
|
+
```ruby
|
|
758
|
+
options = ClaudeAgentSDK::ClaudeAgentOptions.new(
|
|
759
|
+
system_prompt: ClaudeAgentSDK::SystemPromptPreset.new(
|
|
760
|
+
preset: 'claude_code',
|
|
761
|
+
append: '...your shared domain instructions...',
|
|
762
|
+
exclude_dynamic_sections: true
|
|
763
|
+
)
|
|
764
|
+
)
|
|
765
|
+
```
|
|
766
|
+
|
|
767
|
+
When set, the CLI strips per-user dynamic sections (working directory, auto-memory, git status) from the system prompt and re-injects them into the first user message instead. Older CLIs silently ignore this option.
|
|
768
|
+
|
|
763
769
|
## Budget Control
|
|
764
770
|
|
|
765
771
|
Use `max_budget_usd` to set a spending cap for your queries:
|
|
@@ -1575,9 +1581,9 @@ end
|
|
|
1575
1581
|
| `PermissionResultAllow` | Permission callback result to allow tool use |
|
|
1576
1582
|
| `PermissionResultDeny` | Permission callback result to deny tool use |
|
|
1577
1583
|
| `AgentDefinition` | Agent definition with description, prompt, tools, model, skills, memory, mcp_servers |
|
|
1578
|
-
| `ThinkingConfigAdaptive` | Adaptive thinking mode (
|
|
1584
|
+
| `ThinkingConfigAdaptive` | Adaptive thinking mode (CLI dynamically adjusts budget) |
|
|
1579
1585
|
| `ThinkingConfigEnabled` | Enabled thinking with explicit `budget_tokens` |
|
|
1580
|
-
| `ThinkingConfigDisabled` | Disabled thinking
|
|
1586
|
+
| `ThinkingConfigDisabled` | Disabled thinking |
|
|
1581
1587
|
| `SdkMcpTool` | SDK MCP tool definition with name, description, input_schema, handler, annotations |
|
|
1582
1588
|
| `McpStdioServerConfig` | MCP server config for stdio transport |
|
|
1583
1589
|
| `McpSSEServerConfig` | MCP server config for SSE transport |
|
|
@@ -25,13 +25,15 @@ module ClaudeAgentSDK
|
|
|
25
25
|
STREAM_CLOSE_TIMEOUT_ENV_VAR = 'CLAUDE_CODE_STREAM_CLOSE_TIMEOUT'
|
|
26
26
|
DEFAULT_STREAM_CLOSE_TIMEOUT_SECONDS = 60.0
|
|
27
27
|
|
|
28
|
-
def initialize(transport:, is_streaming_mode:, can_use_tool: nil, hooks: nil, sdk_mcp_servers: nil, agents: nil
|
|
28
|
+
def initialize(transport:, is_streaming_mode:, can_use_tool: nil, hooks: nil, sdk_mcp_servers: nil, agents: nil,
|
|
29
|
+
exclude_dynamic_sections: nil)
|
|
29
30
|
@transport = transport
|
|
30
31
|
@is_streaming_mode = is_streaming_mode
|
|
31
32
|
@can_use_tool = can_use_tool
|
|
32
33
|
@hooks = hooks || {}
|
|
33
34
|
@sdk_mcp_servers = sdk_mcp_servers || {}
|
|
34
35
|
@agents = agents
|
|
36
|
+
@exclude_dynamic_sections = exclude_dynamic_sections
|
|
35
37
|
|
|
36
38
|
# Control protocol state
|
|
37
39
|
@pending_control_responses = {}
|
|
@@ -109,6 +111,7 @@ module ClaudeAgentSDK
|
|
|
109
111
|
hooks: hooks_config.empty? ? nil : hooks_config,
|
|
110
112
|
agents: agents_dict
|
|
111
113
|
}
|
|
114
|
+
request[:excludeDynamicSections] = @exclude_dynamic_sections unless @exclude_dynamic_sections.nil?
|
|
112
115
|
|
|
113
116
|
response = send_control_request(request)
|
|
114
117
|
@initialized = true
|
|
@@ -120,8 +120,7 @@ module ClaudeAgentSDK
|
|
|
120
120
|
end
|
|
121
121
|
|
|
122
122
|
# Thinking configuration (takes precedence over deprecated max_thinking_tokens)
|
|
123
|
-
|
|
124
|
-
cmd.concat(['--max-thinking-tokens', thinking_tokens.to_s]) unless thinking_tokens.nil?
|
|
123
|
+
build_thinking_args(cmd)
|
|
125
124
|
|
|
126
125
|
# Effort level (valid values: low, medium, high, max)
|
|
127
126
|
cmd.concat(['--effort', @options.effort.to_s]) if @options.effort
|
|
@@ -494,8 +493,6 @@ module ClaudeAgentSDK
|
|
|
494
493
|
@ready
|
|
495
494
|
end
|
|
496
495
|
|
|
497
|
-
DEFAULT_ADAPTIVE_THINKING_TOKENS = 32_000
|
|
498
|
-
|
|
499
496
|
private
|
|
500
497
|
|
|
501
498
|
def build_settings_args(cmd)
|
|
@@ -599,18 +596,18 @@ module ClaudeAgentSDK
|
|
|
599
596
|
JSON.parse(File.read(path))
|
|
600
597
|
end
|
|
601
598
|
|
|
602
|
-
def
|
|
599
|
+
def build_thinking_args(cmd)
|
|
603
600
|
if @options.thinking
|
|
604
601
|
case @options.thinking
|
|
605
602
|
when ThinkingConfigAdaptive
|
|
606
|
-
|
|
603
|
+
cmd.concat(['--thinking', 'adaptive'])
|
|
607
604
|
when ThinkingConfigEnabled
|
|
608
|
-
@options.thinking.budget_tokens
|
|
605
|
+
cmd.concat(['--max-thinking-tokens', @options.thinking.budget_tokens.to_s])
|
|
609
606
|
when ThinkingConfigDisabled
|
|
610
|
-
|
|
607
|
+
cmd.concat(['--thinking', 'disabled'])
|
|
611
608
|
end
|
|
612
609
|
elsif @options.max_thinking_tokens
|
|
613
|
-
@options.max_thinking_tokens
|
|
610
|
+
cmd.concat(['--max-thinking-tokens', @options.max_thinking_tokens.to_s])
|
|
614
611
|
end
|
|
615
612
|
end
|
|
616
613
|
end
|
|
@@ -1735,17 +1735,19 @@ module ClaudeAgentSDK
|
|
|
1735
1735
|
|
|
1736
1736
|
# System prompt preset configuration
|
|
1737
1737
|
class SystemPromptPreset
|
|
1738
|
-
attr_accessor :type, :preset, :append
|
|
1738
|
+
attr_accessor :type, :preset, :append, :exclude_dynamic_sections
|
|
1739
1739
|
|
|
1740
|
-
def initialize(preset:, append: nil)
|
|
1740
|
+
def initialize(preset:, append: nil, exclude_dynamic_sections: nil)
|
|
1741
1741
|
@type = 'preset'
|
|
1742
1742
|
@preset = preset
|
|
1743
1743
|
@append = append
|
|
1744
|
+
@exclude_dynamic_sections = exclude_dynamic_sections
|
|
1744
1745
|
end
|
|
1745
1746
|
|
|
1746
1747
|
def to_h
|
|
1747
1748
|
result = { type: @type, preset: @preset }
|
|
1748
1749
|
result[:append] = @append if @append
|
|
1750
|
+
result[:exclude_dynamic_sections] = @exclude_dynamic_sections unless @exclude_dynamic_sections.nil?
|
|
1749
1751
|
result
|
|
1750
1752
|
end
|
|
1751
1753
|
end
|
data/lib/claude_agent_sdk.rb
CHANGED
|
@@ -340,6 +340,10 @@ module ClaudeAgentSDK
|
|
|
340
340
|
# Convert hooks to internal format
|
|
341
341
|
hooks = convert_hooks_to_internal_format(configured_options.hooks) if configured_options.hooks
|
|
342
342
|
|
|
343
|
+
# Extract exclude_dynamic_sections from preset system prompt for the
|
|
344
|
+
# initialize request (older CLIs ignore unknown initialize fields)
|
|
345
|
+
exclude_dynamic_sections = extract_exclude_dynamic_sections(configured_options.system_prompt)
|
|
346
|
+
|
|
343
347
|
# Create Query handler
|
|
344
348
|
@query_handler = Query.new(
|
|
345
349
|
transport: @transport,
|
|
@@ -347,7 +351,8 @@ module ClaudeAgentSDK
|
|
|
347
351
|
can_use_tool: configured_options.can_use_tool,
|
|
348
352
|
hooks: hooks,
|
|
349
353
|
sdk_mcp_servers: sdk_mcp_servers,
|
|
350
|
-
agents: configured_options.agents
|
|
354
|
+
agents: configured_options.agents,
|
|
355
|
+
exclude_dynamic_sections: exclude_dynamic_sections
|
|
351
356
|
)
|
|
352
357
|
|
|
353
358
|
# Start query handler and initialize
|
|
@@ -527,5 +532,19 @@ module ClaudeAgentSDK
|
|
|
527
532
|
end
|
|
528
533
|
internal_hooks
|
|
529
534
|
end
|
|
535
|
+
|
|
536
|
+
def extract_exclude_dynamic_sections(system_prompt)
|
|
537
|
+
if system_prompt.is_a?(SystemPromptPreset)
|
|
538
|
+
eds = system_prompt.exclude_dynamic_sections
|
|
539
|
+
return eds if [true, false].include?(eds)
|
|
540
|
+
elsif system_prompt.is_a?(Hash)
|
|
541
|
+
type = system_prompt[:type] || system_prompt['type']
|
|
542
|
+
if type == 'preset'
|
|
543
|
+
eds = system_prompt.fetch(:exclude_dynamic_sections) { system_prompt['exclude_dynamic_sections'] }
|
|
544
|
+
return eds if [true, false].include?(eds)
|
|
545
|
+
end
|
|
546
|
+
end
|
|
547
|
+
nil
|
|
548
|
+
end
|
|
530
549
|
end
|
|
531
550
|
end
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: claude-agent-sdk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.14.
|
|
4
|
+
version: 0.14.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Community Contributors
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-04-
|
|
10
|
+
date: 2026-04-09 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: async
|