Repository navigation
Stop a paused script's tool calls at the call, not at the next look - #691
Merged
Merged
Conversation
An end-to-end test (a real exec script calling the stand-in MCP server) showed that a pause during a slow read did not stop the script's next call: the stop flag was looked at every 50 ms and by QuickJS's interrupt every few thousand instructions, so a read answered just after the pause let the script call its next tool, which reached the server. The flag is now a Halt: stopping it wakes the run at once, and every tool call and store() looks at it as it is about to happen, so a stopped script makes none whatever its JavaScript does before the interrupt ends it. The stand-in MCP server notes each call as it arrives ($MCP_CALLS) and its `slow` can wait for a file (`until`), so the test pauses during the read, lets it answer right after, and checks the server saw only the read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013jkdGG873rfqV9CdHz7KrE
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Merged
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.
What
#675's pause test used a Tokio sleep and a counter. This PR adds the end-to-end version: a real
execscript calling the stand-in MCP server, paused during a slow read that answers right after the pause.On main the test fails. After the pause, the server still received the script's next call (
echo). The reason is that nothing looked at the stop flag at the moment of a call:select!checked the flag only every 50 ms.So a read answered just after the pause let the script make its next tool call before anything noticed.
Fix
The flag becomes a
Haltinsonny/src/exec.rs:stop()sets it and wakes the run at once through aNotify, which replaces the 50 ms polling loop.tools.X refused: its turn ended.store()checks it too, so a stopped script writes nothing.The interrupt handler and the end-of-run classification read the same
Halt.Test
a_pause_stops_a_script_s_tool_calls_even_one_answered_right_after_it(served.rs) runs these steps:sweep.slow.slowanswer immediately.slowstore()wrote nothingdaemon_pausedIt passed 6 of 6 runs here. With main's
exec.rsit fails withleft: "slow\necho\n".The stand-in server (
tests/mcp_server.py) gained two things:$MCP_CALLS, a log of each call's tool name as it arrivesuntilargument onslow, which makes it wait for a fileexec::runis nowpub(crate)so the served test can run a real script.cargo test -p sonny: 1031 passed. Clippy is clean with-D warnings. There is no protocol or schema change. The FEATURESexecrow has a new 11-05 note.Generated by Claude Code