Skip to content

Add an explicit termination reason to the finish tool #172

Description

@mdev34-lab

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions