Repository navigation
Wait for a background task with monitor_command - #263
Conversation
command_output only takes a quick look, so waiting for a build, a test run or a release meant calling it over and over: one card per call, and each call spent a turn's tool round on a poll. monitor_command covers the whole wait in a single call. It follows a background task until the task exits, a line of new output matches an optional "until" pattern, or the timeout passes (300s by default, 600s at most), and reports the exit code, whether the task is still running, and the output gathered while watching. The task keeps running when the watch ends first, and a cancelled turn ends the watch too. In an editor the call is one live-updating card: tools.rs reports progress through the new ToolProgress seam, and main.rs sends it as a tool_call_update that replaces the card's content. The TUI and headless ignore it. The tool is read-only for permissions (it watches, it does not change anything) and is exempt from the repeated-tool-call guard, since waiting is the point. Cards for command_output, monitor_command and kill_command now name the task and its command. Co-Authored-By: siGit Code v1.7.5-acp <noreply@sigit.si>
There was a problem hiding this comment.
This change introduces the monitor_command tool, which allows following a background task until it exits, a line matches an optional regex, or a timeout occurs. Unlike command_output, which requires repeated polling, monitor_command handles the entire wait in one call and provides live progress updates through a new ToolProgress trait. The ACP editor surface implements this for live-updating cards, while TUI/headless ignore updates. The tool is classified as read-only and is exempt from the repeated-tool-call guard. Cards for command_output, monitor_command, and kill_command now include the task and its command in their titles. The change is covered by comprehensive tests for correct behavior, edge cases, and integration with permissions and UI. Documentation and schema updates reflect the new tool and its usage.
Automated review by siGit Code Review · commit 7201f52 · see the review dashboard
command_outputonly takes a quick look, so waiting for a build, a test run or a release meant calling it over and over: one card per call, and each call spent a turn's tool round on a poll.monitor_commandcovers the whole wait in a single call. It follows a background task until the task exits, a line of new output matches an optionaluntilpattern, or the timeout passes (300s by default, 600s at most), and reports the exit code, whether the task is still running, and the output gathered while watching. The task keeps running when the watch ends first, and a cancelled turn ends the watch too.In an editor the call is one live-updating card:
tools.rsreports progress through the newToolProgressseam, andmain.rssends it as atool_call_updatethat replaces the card's content. The TUI and headless ignore it.The tool is read-only for permissions (it watches, it does not change anything) and is exempt from the repeated-tool-call guard, since waiting is the point. Cards for
command_output,monitor_commandandkill_commandnow name the task and its command.Testing
cargo fmt -- --checkcargo clippy --tests -- -D warningscargo test --locked🤖 Generated with siGit Code