claude-agent-sdk 0.6.1 → 0.6.2
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 +6 -0
- data/lib/claude_agent_sdk/subprocess_cli_transport.rb +34 -6
- data/lib/claude_agent_sdk/version.rb +1 -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: 8044b53b9c1c89e75c789b94a1ca000bb4a4a6e94d380bef3ded209585517b29
|
|
4
|
+
data.tar.gz: a3effbef7a3cbf1faed47cecb6f69df37e17266eabae7e56a556855b85707c4f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3c9360caa6e3fc1ffa7d359e4d2195aecf003e1fc37655bfe15355efc2dce3cfd896f30a0b7bdc504a88d90056bab05b7ad2a90c33f0ad03867abcaf0ccb16a7
|
|
7
|
+
data.tar.gz: 68059199d80d3f10ff03b18b6fbb505348070f8a1a53d8d00cd56550fdfe7c337a4b53d39d7e41d0238c954dd2106656c6f8eaf6e39b5ac516278ac4c7c57ff4
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,12 @@ 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.6.2] - 2026-02-17
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
- **Large prompt `Errno::E2BIG` crash:** Prompts exceeding 200KB are now piped via stdin instead of passed as CLI arguments, avoiding the OS `ARG_MAX` limit (typically 1MB on macOS/Linux). This fixes `CLIConnectionError: Failed to start Claude Code: Argument list too long` when using `query()` with large prompts.
|
|
12
|
+
- **Stderr pipe deadlock (`Errno::EPIPE`):** Always drain stderr in a background thread, even when `stderr` option is not set. Without this, `--verbose` output fills the 64KB OS pipe buffer, the subprocess blocks on write, and all pipes stall. Previously only manifested with long-running Opus sessions.
|
|
13
|
+
|
|
8
14
|
## [0.6.0] - 2026-02-13
|
|
9
15
|
|
|
10
16
|
### Added
|
|
@@ -13,6 +13,11 @@ module ClaudeAgentSDK
|
|
|
13
13
|
DEFAULT_MAX_BUFFER_SIZE = 1024 * 1024 # 1MB buffer limit
|
|
14
14
|
MINIMUM_CLAUDE_CODE_VERSION = '2.0.0'
|
|
15
15
|
|
|
16
|
+
# Prompts larger than this are piped via stdin instead of CLI args
|
|
17
|
+
# to avoid Errno::E2BIG (ARG_MAX is typically 1MB on macOS/Linux,
|
|
18
|
+
# shared with environment variables).
|
|
19
|
+
PROMPT_STDIN_THRESHOLD = 200 * 1024 # 200KB
|
|
20
|
+
|
|
16
21
|
def initialize(prompt, options)
|
|
17
22
|
@prompt = prompt
|
|
18
23
|
@is_streaming = !prompt.is_a?(String)
|
|
@@ -27,6 +32,7 @@ module ClaudeAgentSDK
|
|
|
27
32
|
@exit_error = nil
|
|
28
33
|
@max_buffer_size = options.max_buffer_size || DEFAULT_MAX_BUFFER_SIZE
|
|
29
34
|
@stderr_task = nil
|
|
35
|
+
@pipe_prompt_via_stdin = false
|
|
30
36
|
end
|
|
31
37
|
|
|
32
38
|
def find_cli
|
|
@@ -245,6 +251,11 @@ module ClaudeAgentSDK
|
|
|
245
251
|
# Prompt handling
|
|
246
252
|
if @is_streaming
|
|
247
253
|
cmd.concat(['--input-format', 'stream-json'])
|
|
254
|
+
elsif @prompt.to_s.bytesize > PROMPT_STDIN_THRESHOLD
|
|
255
|
+
# Large prompts are piped via stdin to avoid OS argument size limits.
|
|
256
|
+
# Claude CLI reads from stdin when --print is used without a trailing argument.
|
|
257
|
+
cmd << '--print'
|
|
258
|
+
@pipe_prompt_via_stdin = true
|
|
248
259
|
else
|
|
249
260
|
cmd.concat(['--print', '--', @prompt.to_s])
|
|
250
261
|
end
|
|
@@ -277,15 +288,32 @@ module ClaudeAgentSDK
|
|
|
277
288
|
|
|
278
289
|
@stdin, @stdout, @stderr, @process = Open3.popen3(process_env, *cmd, opts)
|
|
279
290
|
|
|
280
|
-
#
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
291
|
+
# Always drain stderr to prevent pipe buffer deadlock.
|
|
292
|
+
# Without this, --verbose output fills the OS pipe buffer (~64KB),
|
|
293
|
+
# the subprocess blocks on write, and all pipes stall → EPIPE.
|
|
294
|
+
if @stderr
|
|
295
|
+
if should_pipe_stderr
|
|
296
|
+
@stderr_task = Thread.new do
|
|
297
|
+
handle_stderr
|
|
298
|
+
rescue StandardError
|
|
299
|
+
# Ignore errors during stderr reading
|
|
300
|
+
end
|
|
301
|
+
else
|
|
302
|
+
# Silently drain stderr so the subprocess never blocks
|
|
303
|
+
@stderr_task = Thread.new do
|
|
304
|
+
@stderr.each_line { |_| } # discard
|
|
305
|
+
rescue StandardError
|
|
306
|
+
# Ignore — process may have already exited
|
|
307
|
+
end
|
|
286
308
|
end
|
|
287
309
|
end
|
|
288
310
|
|
|
311
|
+
# For large prompts, pipe the prompt text to stdin before closing.
|
|
312
|
+
# This avoids Errno::E2BIG when the prompt exceeds ARG_MAX.
|
|
313
|
+
if @pipe_prompt_via_stdin && @stdin
|
|
314
|
+
@stdin.write(@prompt.to_s)
|
|
315
|
+
end
|
|
316
|
+
|
|
289
317
|
# Close stdin for non-streaming mode
|
|
290
318
|
@stdin.close unless @is_streaming
|
|
291
319
|
@stdin = nil unless @is_streaming
|
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.6.
|
|
4
|
+
version: 0.6.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Community Contributors
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-02-
|
|
10
|
+
date: 2026-02-16 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: async
|