Problem
The finish tool currently communicates that an agent has stopped, but the runtime cannot reliably distinguish why it stopped. This becomes increasingly important if Review/subagent execution is moved onto the background path.
Proposal
Add a required reason parameter to finish, alongside the existing description:
finish({
reason: "success" | "subagent_wait" | "failure",
description: string,
})
Semantics
success: the agent completed its assigned work and has a usable result.
subagent_wait: the agent is done with its current turn because progress depends on another subagent; the scheduler/orchestrator should handle the dependency.
failure: the agent could not complete its assigned work successfully.
Requirements
- Make
reason required rather than optional.
- Preserve the existing description/result payload.
- Propagate the reason through the existing finish/result handling instead of inferring it from prose.
- Update the finish tool schema, runtime types, dispatch/termination handling, and relevant tests.
- Ensure background and foreground subagents expose the same termination contract.
- Do not make
subagent_wait equivalent to fire-and-forget; the existing orchestration/scheduler semantics should remain explicit.
- Audit existing callers/tests for the new required field and update them.
- Keep the change focused; do not redesign the entire subagent scheduler as part of this issue.
Motivation
An explicit termination reason gives the runtime a typed state transition instead of forcing it to infer termination semantics from the model's text. This is particularly useful for background Review/subagent execution, recovery from non-terminal model behavior, orchestration between subagents, and future observability.
This issue is related to the Review stagnation recovery work in #171 and the broader finish/liveness work in #140, but should remain independently implementable.
Problem
The
finishtool currently communicates that an agent has stopped, but the runtime cannot reliably distinguish why it stopped. This becomes increasingly important if Review/subagent execution is moved onto the background path.Proposal
Add a required
reasonparameter tofinish, alongside the existing description:Semantics
success: the agent completed its assigned work and has a usable result.subagent_wait: the agent is done with its current turn because progress depends on another subagent; the scheduler/orchestrator should handle the dependency.failure: the agent could not complete its assigned work successfully.Requirements
reasonrequired rather than optional.subagent_waitequivalent to fire-and-forget; the existing orchestration/scheduler semantics should remain explicit.Motivation
An explicit termination reason gives the runtime a typed state transition instead of forcing it to infer termination semantics from the model's text. This is particularly useful for background Review/subagent execution, recovery from non-terminal model behavior, orchestration between subagents, and future observability.
This issue is related to the Review stagnation recovery work in #171 and the broader finish/liveness work in #140, but should remain independently implementable.