Repository navigation
v1.4.0
Added
ClaudeAgentOptions#process_groupstarts the CLI process in a process group of its own (issue #175). In a terminal, Ctrl-C signals the whole foreground process group, so the CLI used to get the SIGINT along with your process and end the turn on its own before your code could decide what to do. Withprocess_group: truethe terminal's Ctrl-C no longer reaches the CLI, and your process owns it: callClient#interruptordisconnectfrom ordinary code (not from inside the signal trap, where Ruby raisesThreadError). Off by default, so nothing changes unless you set it. Sends nothing to the CLI; usespgroup: trueon Unix andnew_pgroup: trueon Windows, where it is untested. Teardown is unchanged: the SDK still signals the CLI process, not its group. Ruby only: the Python SDK's equivalent (PR #617) is unmerged as of 2026-10-25.docs/options.mdcovers the trap pattern, when the CLI stops, and the background-group caveat for tools that read the terminal.
Changed
- README: the Claude Code overview link (it led to a "Page not found" page) and the built-in tools link now point at
code.claude.com. "Rails in a minute" is a section of its own after the Quick Start, and its job turns off auto-memory (CLAUDE_CODE_DISABLE_AUTO_MEMORY) as the Rails guide's does. The hooks example defines the two callbacks it passes, the custom-tool example runs a prompt, and the Examples table listssubagent_status_example.rb. What a session without credentials, or with a rejected key, returns is now described in a new "Authentication Failures" section ofdocs/errors.md.
Usage
interrupts = Thread::Queue.new
previous = trap('INT') { interrupts << :int } # nothing else in here: no SDK calls
begin
options = ClaudeAgentSDK::ClaudeAgentOptions.new(process_group: true)
ClaudeAgentSDK::Client.open(options: options) do |client|
watcher = Thread.new do
client.interrupt if interrupts.pop # on this thread, outside the trap
end
client.query('Refactor the parser')
client.receive_response { |message| puts message }
ensure
interrupts << nil # ends the watcher; the queue stays open for the trap
watcher&.join
end
ensure
trap('INT', previous) # Ctrl-C behaves as before once the session is over
endWhat's changed
- #176 Add ClaudeAgentOptions#process_group: start the CLI in its own process group — @ya-luotao
Full Changelog: v1.3.0...v1.4.0
gem install claude-agent-sdk -v 1.4.0