Monitor-Poll Loop

loop pattern · maturity: established · risk: low

The agent watches an external process it cannot control (CI, deploy, long job) by polling on a cadence matched to the process's rate of change, acting only on state transitions.

When to use

CI runs, deployments, external queues: anywhere the agent waits on the world.

Steps

StepWhat happensVerification
ObserveQuery current state through the real interface, not cached assumptions.State read from the source of truth with a timestamp.
Compare and decideAct only on transitions; unchanged state means wait.Action log shows transitions, not repeated reactions to the same state.
Wait or escalateSleep the cadence interval; escalate if the process exceeds its expected duration.A maximum-wait bound exists; infinite patience is unbounded risk.

Specification

Verification methodThe external process's own status is the ground truth.
Recovery behaviorescalate-on-timeout
ObservabilityPoll log with states and timestamps.
InputsObservable process, Cadence, Duration bound
OutputsTimely reaction to completion or failure
Risk level / maturitylow / established

Failure modes

  • Polling faster than the process changes burns budget
  • No duration bound means hung processes hang the agent
  • Acting on stale cached state

Assessment

Mundane and universally needed. The cadence decision is the craft: match it to how fast the watched thing actually changes, and always carry a timeout.

Go deeper