Skip to main content

Module finish_task

Module finish_task 

Source
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§

ChangeEntry
One entry of the optional changes array.
FinishTaskArgs
Parsed, validated arguments to a finish_task call.
FinishTaskTool
ToolExecutor for the finish_task tool (#2072, §5.8).

Enums§

FinishStatus
Completion status reported by the model.

Constants§

FINISH_TASK_TOOL_NAME
The tool’s registered/advertised name.

Functions§

render_finish_summary
Render a FinishTaskArgs into human-readable summary text.