Skip to content

Watchdog

Idle detection shared by the providers. Feed it every event a session emits; it reports a running turn that has gone quiet for too long. Any event counts as activity, including Heartbeat, so a model that is thinking is not idle. While a tool call is open the toolIdle limit applies instead, since a long build or test run can be silent.

Since v0.1.0

Start a watchdog. It checks for idle turns until the Scope closes.

Signature

declare const make: (options: Options) => Effect.Effect<Watchdog, never, Scope.Scope>

Source

Since v0.1.0

The stall policy every provider follows, until the Scope closes: a turn that goes quiet is interrupted; if it hasn’t ended grace later, the agent process is killed. The interrupt runs on its own, so one that hangs (the process is wedged) can’t hold up the kill.

Signature

declare const supervise: (
watchdog: Watchdog,
supervisor: Supervisor,
) => Effect.Effect<void, never, Scope.Scope>

Source

Since v0.2.0

A running turn that went quiet: for how long, and whether a tool call was open.

Signature

export interface Expiry {
readonly turnId: TurnId
readonly idleMs: number
readonly inTool: boolean
}

Source

Since v0.1.0

Idle limits; toolIdle defaults to idle.

Signature

export interface Options {
readonly idle: Duration.Input
readonly toolIdle?: Duration.Input
}

Source

Since v0.1.0

How a provider stops a stalled turn, for supervise.

Signature

export interface Supervisor {
/** How long an interrupted turn has to end before the agent process is killed. */
readonly grace: Duration.Input
/**
* Mark the turn as stalled (so it ends `Stalled`). False if it is no longer running:
* nothing to do.
*/
readonly stall: (expiry: Expiry) => Effect.Effect<boolean>
readonly interrupt: (expiry: Expiry) => Effect.Effect<unknown, unknown>
/** Waits for the turn to end (failing counts: the session ended). */
readonly turnEnded: (turnId: TurnId) => Effect.Effect<unknown, unknown>
/** Kill the agent process, which ends the turn (and the session). */
readonly kill: Effect.Effect<void>
}

Source

Since v0.2.0

Signature

export interface Watchdog {
readonly observe: (event: AgentEvent) => Effect.Effect<void>
/** At most one per turn. */
readonly expirations: Stream.Stream<Expiry>
}

Source

Since v0.1.0