Expand description
Multi-step text generation (generate_text).
The loop converts the prompt, calls the model, parses tool calls, resolves approvals, executes client tools and repeats until no client tool calls remain or a stop condition is met.
Design: docs/01-architecture/07-generation-loop-and-streaming.md,
docs/01-architecture/06-tool-system.md.
Structs§
- Approval
Context - Information available to an
ApprovalPolicy. - Approval
Policy Fn - Adapter turning a synchronous closure into an
ApprovalPolicy. - Chunk
Timing Stats - Statistics over the gaps between consecutive content parts.
- Generate
Text - Builder and future of a
generate_textcall. - Generate
Text Result - Result of a completed generation loop.
- Generated
File - A generated file.
- HasTool
Call - Stops when the last step called one of the listed tools.
- Include
- Which large payloads are copied into step results.
- Never
- Never stops on its own (the loop ends when no tool calls remain).
- Parsed
Tool Call - A tool call after parsing and validation.
- Prepare
Step Context - Information available to a
PrepareStepcallback. - Refine
Tool Inputs - Refinement functions by tool name.
- Repair
Request - Information handed to a
ToolCallRepair. - Step
Count - Stops when the number of completed steps equals
n. - Step
Overrides - Overrides returned by a
PrepareStepcallback. Unset fields keep the prior state for messages, instructions and contexts; other fields keep call defaults. - Step
Performance - Timing and throughput of a step.
- Step
Request - Request metadata of a step.
- Step
Response - Response metadata of a step.
- Step
Result - The result of one step: a model call plus the tool executions it caused.
- Tool
Approval Request Content - A request to approve a tool call before it executes.
- Tool
Approval Response Content - An approval decision made automatically by the approval policy.
- Tool
Execution Error - A failed tool execution (non-fatal: reported back to the model).
- Tool
Output Denied - A tool call whose execution was denied.
- Tool
Result - A tool result.
Enums§
- Approval
Status - Outcome of approval resolution for one tool call.
- Step
Content - A content part of a step.
- Tool
Error Info - Serializable description of a tool error.
Constants§
- SIGNATURE_
DOMAIN - Domain separator of the signature payload.
Traits§
- Approval
Policy - Decides whether a tool call needs approval.
- Prepare
Step - Computes overrides before each step.
- Stop
Condition - Decides after each step whether the loop stops.
- Tool
Call Repair - Repairs tool calls the model got wrong (unknown tool or invalid input).
Functions§
- approval_
policy - Wraps a synchronous closure as an approval policy.
- generate_
text - Starts building a non-streaming text generation call.
- has_
any_ tool_ call - Stops when the last step contains a call to any of
tool_names. - has_
tool_ call - Stops when the last step contains a call to
tool_name. - never
- A condition that never stops the loop.
- step_
count - Stops when
nsteps have been completed.
Type Aliases§
- Refine
Tool Input Fn - Rewrites a validated tool input before execution.