Skip to content

Monitoring API

The Monitor feature lets the agent watch a long-lived command and react to new output without polling. Enabled via include_monitoring=True on create_deep_agent. See Monitor — watch & react for the overview.

MonitorManager

pydantic_deep.features.monitoring.MonitorManager

Owns active monitors and their background drain loops.

Parameters:

Name Type Description Default
backend Any

An async background-capable backend (exposes execute_background / read_background / kill_background).

required
on_event EventSink | None

Async callback invoked for each :class:MonitorEvent. When omitted, events are still buffered (visible via :meth:list).

None
poll_interval float

Seconds between output polls.

_DEFAULT_POLL_INTERVAL

set_sink(on_event)

Set or replace the react sink (used when wiring after construction).

start(command, *, label=None, match=None) async

Spawn command in the background and begin watching its output.

stop(monitor_id) async

Stop a monitor and kill its process. False if unknown.

stop_all() async

Stop every monitor (e.g. on session end).

list_monitors()

Snapshot of all tracked monitors.

recent_events(monitor_id)

Buffered recent events for a monitor (empty if unknown).

MonitorEvent

pydantic_deep.features.monitoring.MonitorEvent dataclass

A batch of new output from a monitored process, pushed to the agent.

lines holds the new matching output lines since the last poll. A final event with running=False is emitted once the process exits (its lines may be empty — it signals completion).

MonitorInfo

pydantic_deep.features.monitoring.MonitorInfo dataclass

Snapshot of a monitor's state for list_monitors and tool results.

create_monitor_toolset

pydantic_deep.features.monitoring.create_monitor_toolset(*, id=None, descriptions=None)

Build the monitor toolset (start_monitor / list_monitors / stop_monitor).