Repository navigation
Conversation
Adds a `monitor` tool (gated behind the Monitor feature) that runs a shell command as a long-lived background watcher and delivers each output line back to the model as a notification, so the agent can react to events (a log line, a file change, a CI check, a build going green) without polling. It reuses the existing unified_exec machinery: the watcher is a unified_exec process and a delivery task subscribes to its output, coalesces lines, bounds them, and wakes an idle session. A flood guard auto-stops a runaway command. action=start returns a monitor id, action=stop ends a watch, and action=list shows active watches. Covered by an end-to-end suite in core/tests/suite/monitor.rs.
The monitor watcher previously ran under a hard-coded default sandbox, so it could not see permissions the user granted for the turn (e.g. a write path approved via request_permissions or an exec approval). It would silently fail to write or read paths the rest of the turn could already reach. Resolve the turn's effective permissions the same way exec does — via apply_granted_turn_permissions over the session and turn environment, anchored at the native turn cwd when available and the config cwd otherwise — and pass the resulting sandbox permissions, additional permissions, and pre-approval flag into the watcher's exec request. The watcher now inherits exactly the access the session has granted, no more and no less. Adds request_permissions_grant_applies_to_monitor: a turn-scoped write grant lets the watcher write a path the base sandbox forbids; it fails under the old default sandbox and passes with the inherited grant.
hassaans
force-pushed
the
feat/monitor-tool
branch
from
June 29, 2026 22:36
88a3aae to
2abf184
Compare
Owner
Author
|
Closing as part of a backlog cleanup: this has been open since 2026-06-28, more than two weeks, so it is being cleared out by age rather than on its merits. Note: this one was deliberately parked rather than abandoned, so it is being closed only because of the age sweep. If the thing it was waiting on has landed, reopen it. The branch is preserved and this reopens in one click. |
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.
Summary
Adds the
monitortool from openai#29922 on currentmain, and runs its watcher with the same sandbox access the session has already granted.monitorruns a shell command as a long-lived background watcher. Every line it writes to stdout or stderr comes back to the model as a notification, so the agent reacts to output as it arrives instead of polling. It builds on the existingunified_execplumbing: the watcher is aunified_execprocess. A delivery task subscribes to its output and batches lines that come in close together, then wakes an idle session withtry_start_turn_if_idle. A flood guard stops a runaway command.startbegins a watch and returns its idstopends the watch for a given idlistshows the active watchesThe watcher used to build its exec request with
sandbox_permissions: Default::default()and never resolved granted permissions, so it stayed on the turn's default sandbox even after the session was granted more access. It now goes throughapply_granted_turn_permissions, the same pathexec_command.rsuses, so a watched command runs with the granted access too.Porting notes
The reference targeted
rust-v0.142.0. Two things needed adjusting against currentmain: a conflict in the feature-flag list, andresolve_tool_environmentnow takes a&TurnEnvironmentSnapshotinstead of a&TurnContext, so the handler passesstep_context.environmentsintostart().Testing
core/tests/suite/monitor.rscovers the watch behavior: per-line wake on stdout and stderr, output captured before the first yield, an unterminated final line, the flood-guard auto-stop, a newline-free flood getting truncated, the "watcher exited" notice, and registry pruning when the command exits.core/tests/suite/request_permissions.rshas a regression test for the permission change. It grants a turn-scoped write, has the watcher write a path the base sandbox blocks, and checks the write lands. The test fails against the old default-sandbox behavior and passes once the watcher inherits the grant.