Expand description
finish_task tool — structured, schema-validated task completion (#2072, §5.8).
Why: Before this tool, an AgentLoop only recognised completion implicitly —
an assistant turn with NO tool calls (the D3 convention, see
agent_loop::run_inner). That works, but it forces the model to convey
“I’m done, here’s what happened” as free prose the caller must re-parse.
finish_task gives the model an explicit, schema-validated tool call for the
same signal: a status enum, a summary, and optional structured changes/
test-result fields. Malformed arguments (a missing required field, an invalid
status enum value, syntactically broken JSON) flow through the EXACT SAME
llm::tool_call_extractor plumbing #1023 built for every other tool —
ToolCallExtractor::parse_and_validate → schema::validate_args — so no new
validation or repair code is needed here; finish_task is just another
ToolExecutor whose schema happens to describe a completion report.
What: FinishTaskTool implements ToolExecutor with name() equal to
FINISH_TASK_TOOL_NAME. execute deserialises the (already
schema-validated) arguments into FinishTaskArgs and renders them via
render_finish_summary into the tool’s ToolResult. agent_loop::run_inner
(#2072) recognises a successful finish_task dispatch and terminates the loop
immediately, building the final AgentOutput from the SAME FinishTaskArgs /
render_finish_summary this module exposes, instead of waiting for a later
no-tool-call turn.
Test: finish_task::tests::* — schema shape, valid execute, execute with
changes/tests fields, and the defensive (should-be-unreachable given upstream
schema validation) malformed-shape branch. agent_loop::tests::* covers the
loop-termination integration end to end.
Structs§
- Change
Entry - One entry of the optional
changesarray. - Finish
Task Args - Parsed, validated arguments to a
finish_taskcall. - Finish
Task Tool ToolExecutorfor thefinish_tasktool (#2072, §5.8).
Enums§
- Finish
Status - Completion status reported by the model.
Constants§
- FINISH_
TASK_ TOOL_ NAME - The tool’s registered/advertised name.
Functions§
- render_
finish_ summary - Render a
FinishTaskArgsinto human-readable summary text.