Skip to content

Stop a paused script's tool calls at the call, not at the next look - #691

Merged
lydakis merged 1 commit into
mainfrom
claude/wave1-pause-exec
Nov 5, 2026
Merged

lydakis merged 1 commit into
mainfrom
claude/wave1-pause-exec

Conversation

@lydakis

@lydakis lydakis commented Nov 5, 2026

Copy link
Copy Markdown
Owner

What

#675's pause test used a Tokio sleep and a counter. This PR adds the end-to-end version: a real exec script 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:

  • The run's select! checked the flag only every 50 ms.
  • QuickJS's interrupt handler runs only every few thousand instructions.

So a read answered just after the pause let the script make its next tool call before anything noticed.

Fix

The flag becomes a Halt in sonny/src/exec.rs:

  • stop() sets it and wakes the run at once through a Notify, which replaces the 50 ms polling loop.
  • Every nested tool call checks it twice: on entry, and again right before the call is spawned toward its server, after any gate approval and wait for a place. A stopped script gets 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:

  1. Starts the script through sweep.
  2. Waits until the server has seen slow.
  3. Pauses.
  4. Lets slow answer immediately.
  5. Checks:
    • the server saw only slow
    • store() wrote nothing
    • the call is answered daemon_paused
    • while the pause holds, a fresh listing starts nothing

It passed 6 of 6 runs here. With main's exec.rs it fails with left: "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 arrives
  • an until argument on slow, which makes it wait for a file

exec::run is now pub(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 FEATURES exec row has a new 11-05 note.


Generated by Claude Code

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
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-05T03:48:26.996818Z 374f01e PR opened
🔒 Security Review ✅ Completed 2026-11-05T03:50:26.564756Z 374f01e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@lydakis
lydakis merged commit eebef3f into main Nov 5, 2026
10 checks passed
@lydakis
lydakis deleted the claude/wave1-pause-exec branch November 5, 2026 04:20
@lydakis lydakis mentioned this pull request Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants