Skip to content

feat(orchestration): supervisor-enforced hard ceiling — abort runaway agent mid-iteration #476

@windoliver

Description

@windoliver

Summary

Stop conditions (incl. the new token/cost budget in #475) are evaluated between rounds. A single runaway iteration can overshoot any ceiling before the next evaluation. We need a hard backstop: a supervisor/deadline-enforced ceiling that aborts an agent mid-turn when it blows a token or wall-clock limit.

This is the "true hard ceiling" referenced (but not yet tracked) in #475.

Current state

  • Between-round stops: evaluateStopConditions / evaluateBudget (src/core/stop-conditions.ts) — checked at round boundaries only.
  • The supervisor can already kill + respawn: AcpxSupervisor (src/core/acpx-supervisor.ts:165-226).
  • Deadline machinery already exists: DeadlineWatcher fires per-handoff timers and rebuilds them from store on restart (src/core/deadline-watcher.ts:69-147).
  • Gap: neither enforces a per-agent/per-session token or wall-clock ceiling that hard-aborts a live ACP session mid-iteration.

Proposed change

  • Feed a per-agent (and per-session) hard ceiling — maxTokens / maxWallClockSeconds — to the supervisor/deadline layer.
  • On breach: kill the ACP session via AcpxSupervisor (terminal abort, not just a "stop" flag the agent may ignore), record the reason, and surface it in run health.
  • Token signal sourced from runtime/acpx accounting where available (see the self-report trust-boundary caveat in feat(orchestration): token/cost budget stop condition (max_total_tokens, max_cost_usd) #475), falling back to reported usage.

Acceptance criteria

Context

Follow-up to #475 (corrects its inaccurate "tracked separately" line). Related: #376 (Run Health — where abort reasons surface), #347 (Epic F admission + backpressure), deadline-watcher.ts / acpx-supervisor.ts (the enforcement surfaces).

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-orchestrationMulti-agent spawning, coordination, and lifecyclearea-orchestrationEpic D: Controllers + scheduler + GCenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions