You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Clean up on Ctrl-C in the Go, Rust and Ruby clients - #300
Ctrl-C at the prompt or during a query now ends the chat loop the way EOF does: the session is closed, the server shut down, and the client exits with status 0. That matches what the Python and TypeScript clients already do.
Go:signal.NotifyContext cancels the context. Stdin is read on a goroutine so the loop can watch the context too. The server command is now exec.Command instead of exec.CommandContext, because cancelling the context would kill the server before Cleanup closes the session. After the first Ctrl-C the default handler is restored, so a second one force-quits.
Rust: the session future races against tokio::signal::ctrl_c(), then cleanup runs. On that path the client exits explicitly, because tokio reads stdin on a blocking thread that would otherwise stop the runtime from shutting down.
Ruby:rescue Interrupt, which isn't a StandardError, so rescue => e didn't catch it. ensure already ran cleanup; this replaces the backtrace with a quiet exit.
Ruby: ruby -wc (syntax only; no Ruby 3.4 locally).
Go and Rust behaviour: started each client against the Go weather server, waited for the Query: prompt, sent SIGINT to the client process only, then checked that the client exited with status 0 and the server process was gone. Before the Rust exit fix, the client cleaned up the server but then hung on the blocking stdin thread.
Breaking Changes
None.
Types of changes
Bug fix (non-breaking change which fixes an issue)
New feature (non-breaking change which adds functionality)
Breaking change (fix or feature that would cause existing functionality to change)
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The new Ctrl-C paths in Go, Rust, and Ruby lack required SIGINT regression coverage at the prompt and during pending queries, leaving clean exit behavior, server cleanup, and Rust stdin hangs unchecked.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
A blocking Python API call prevents timely Ctrl-C cleanup, while an uncanceled readiness timer keeps successful test helpers alive and adds roughly 15 minutes to the smoke suite.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Closing stdin after submitting a query aborts the signal shared with processQuery, canceling the pending API request or tool call and silently discarding its answer.
This signal is also aborted by readline's close event on stdin EOF. Closing stdin after submitting a query now cancels the pending API request or tool call and silently discards its answer, instead of letting the query finish. Use a separate SIGINT-only signal for processQuery, keeping the readline-close signal for rl.question.
Well, it becomes too complicated for a quickstart tutorial. Let me try in a different branch a simplifeid version, then we can compare and decide which one to use,
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Interactive Ctrl-C is not handled by readline, so pending API requests or tool calls are not cancelled and cleanup may be delayed until completion or timeout.
We went with Option B from #301 and merged #302. The full clean-shutdown version works, and thank you for building both so they could be compared, but the asyncio, goroutine, tokio::select! and abort-signal machinery lands in code the tutorials quote, and quit and Ctrl-D already give readers a clean exit. This one can be closed unless you want to keep it around for reference.
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
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.
Motivation and Context
Closes issue #269, remaining task from PR #290.
Ctrl-C at the prompt or during a query now ends the chat loop the way EOF does: the session is closed, the server shut down, and the client exits with status 0. That matches what the Python and TypeScript clients already do.
signal.NotifyContextcancels the context. Stdin is read on a goroutine so the loop can watch the context too. The server command is nowexec.Commandinstead ofexec.CommandContext, because cancelling the context would kill the server beforeCleanupcloses the session. After the first Ctrl-C the default handler is restored, so a second one force-quits.tokio::signal::ctrl_c(), then cleanup runs. On that path the client exits explicitly, because tokio reads stdin on a blocking thread that would otherwise stop the runtime from shutting down.rescue Interrupt, which isn't aStandardError, sorescue => edidn't catch it.ensurealready ran cleanup; this replaces the backtrace with a quiet exit.How Has This Been Tested?
Locally:
gofmt -l,go vetand build with Go 1.25.cargo fmt --check,cargo clippy --all-targets -D warnings,cargo test.ruby -wc(syntax only; no Ruby 3.4 locally).Query:prompt, sent SIGINT to the client process only, then checked that the client exited with status 0 and the server process was gone. Before the Rust exit fix, the client cleaned up the server but then hung on the blocking stdin thread.Breaking Changes
None.
Types of changes
Checklist
Additional details
Assisted with Claude Code, checked by me.