Skip to content

Wait for a background task with monitor_command - #263

Merged
setoelkahfi merged 1 commit into
developmentfrom
feature/monitor-command-tool
Oct 26, 2026
Merged

setoelkahfi merged 1 commit into
developmentfrom
feature/monitor-command-tool

Conversation

@setoelkahfi

Copy link
Copy Markdown
Collaborator

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.

Testing

  • cargo fmt -- --check
  • cargo clippy --tests -- -D warnings
  • cargo test --locked

🤖 Generated with siGit Code

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>

@sigit-code-review sigit-code-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@setoelkahfi setoelkahfi self-assigned this Oct 26, 2026
@setoelkahfi
setoelkahfi requested a review from paydii October 26, 2026 07:32
@setoelkahfi
setoelkahfi merged commit 683dfb9 into development Oct 26, 2026
9 checks passed
@setoelkahfi
setoelkahfi deleted the feature/monitor-command-tool branch October 26, 2026 18:50
@setoelkahfi setoelkahfi added this to the v1.7.6 milestone Oct 26, 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