Skip to content

feat(core): event monitor tool (Phase C from #3634) #3666

@doudouOUC

Description

@doudouOUC

Status update (2026-05-08)

The main Phase C work for this issue has landed through #3684 and follow-ups:

One important correctness gap remained for subagent usage: when a subagent started a monitor, monitor notifications were routed to the parent agent instead of the subagent that owned the monitor. That is tracked by #3925 and fixed in #3933.

After #3933 merges, this issue's core requirement — long-running monitor output being pushed back to the agent that started the monitor — should be covered for top-level agents, foreground/background subagents, forked agents, and resumed background agents.

Explicitly not treated as a blocker for this issue: extending send_message to monitor entries. Per the #3634 roadmap discussion, monitor/shell entries do not currently have a receiver-side message protocol, so send_message remains agent-only in v1. task_stop already covers monitor cancellation.

Recommended closure condition: close this issue once #3933 is merged.


Parent

Phase C from the background task management roadmap: #3634

Motivation

Today the agent has no way to run a long-lived watcher (tail -F, inotifywait, polling loops) and receive events back asynchronously. It either blocks the turn with a foreground bash or fire-and-forgets a background shell. The event monitor fills this gap: a new Monitor tool whose stdout lines push events back to the agent with sensible throttling.

Scope

Core (no PR dependencies — can start now)

Follow-up (gated on #3471 / #3488 landing)

  • Wire monitor entries into unified pill / dialog / task_stop (~100-200 LOC)
  • BashTool ergonomics: detect tail -f / polling-loop intents and suggest Monitor instead

Design points

Per the aligned design in #3634:

  1. BackgroundTaskEntry with kind: 'monitor'
  2. Same task_stop cancellation path (follow-up)
  3. Same send_message steering path where applicable (follow-up)
  4. Unified transcript path: <projectDir>/tasks/<sessionId>/monitor-<id>.jsonl
  5. Two-layer PR cleavage: core plumbing PR + per-kind UI integration follow-up

Related

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions