Expand description
The agent turn loop.
Implements the standard function-calling loop: call the provider; while it
asks for tools, execute them and feed the results back; repeat until the
model ends its turn. Provider streaming chunks are folded into a turn via
polyc_llm::turn::collect_turn; the assistant/tool messages are
mapped to wire Messages for the control plane.
Re-exports§
pub use approval_resolve::ApprovalOverride;pub use approval_resolve::ResolvedCall;pub use approval_resolve::resolve_approved_call;pub use handoff::DEFAULT_MAX_CARRY;pub use handoff::HANDOFF_TOOL_NAME;pub use handoff::HandoffRequest;pub use handoff::handoff_tool_spec;pub use handoff::parse_handoff_args;pub use llm_summarizer::LlmSummarizer;
Modules§
- approval_
resolve - Resolving an approver’s in-flight edit onto the call that executes.
- extraction
- The provider-agnostic post-turn memory extractor (docs/design/personas.md §5, issue #214).
- handoff
- Handoff (sub-agent transfer) primitive for the agent turn loop.
- identity
- The anchored agent identity block.
- llm_
summarizer - LLM-backed anchored-iterative
Summarizer. - participation
- The provider-agnostic “should the agent speak?” classifier.
- retry
- Bounded retry for the model call with exponential backoff + jitter.
Structs§
- Dispatch
Mutation - A dispatch-time mutation a policy applied to an in-flight call (
#67). - Pending
Approval - One tool call awaiting human-in-the-loop approval.
- RunTurn
Options - Options for a single
run_turninvocation. - Stub
Summarizer - Deterministic placeholder summarizer — formats a tiny excerpt of the transcript so the data path is exercisable without a provider. Real deployments swap in an LLM-backed summarizer (one-trait swap).
- Stub
Tools - Placeholder executor: advertises no tools and reports any call it receives as unhandled (the model shouldn’t call anything without specs, but the guard keeps the loop progressing if it does).
- Turn
Result - Output of one
run_turncall.
Enums§
- Dispatch
Mutation Kind - The specific dispatch mutation carried by a
DispatchMutation. - Tool
Decision - The argument-aware dispatch-policy decision for one tool call (
#67). - Turn
Stream Event - Re-export so callers can build a streaming channel without depending on
polyc-llmdirectly. An incremental event observed while folding a turn, for live streaming.
Traits§
- Dispatch
Recorder - Signs + durably records a dispatch mutation before it applies (
#67). - Summarizer
- Produces a textual summary of a transcript chunk that’s about to be
dropped from the prompt window. Implementations can be deterministic
(the
StubSummarizer) or LLM-backed (a follow-up). - Tool
Executor - Executes a tool call by name, returning a JSON result string. Also advertises the tools it can execute so the provider knows what’s callable.
Functions§
- current_
tool_ call_ id - Returns the provider-assigned id of the tool call currently executing, when
called from within a
run_turn_withtool execution;Noneoutside that scope. - internal_
note_ message - Build an
internal_onlysystemMessagecarrying context an approver (or, later, a policy gate) injected before a tool runs (#67). - llm_
stop_ to_ wire_ i32 - Map an
llm-sideStopReasonto the wire enum value. - llm_
to_ wire - Convert an llm
LlmMessageinto wireMessages for transmission overHarnessService. - run_
turn - Run one agent turn to completion with no caller-supplied options (the
common path; equivalent to
run_turn_with(..., RunTurnOptions::default())). - run_
turn_ with - Run one agent turn to completion with caller-supplied
RunTurnOptions. - text_
message - Build a wire
Messagecarrying a single text content block. - thought_
message - Build a
model-roleMessagecarrying model reasoning as aThoughtContent, NOT as answer text. - tool_
call_ message - Build a wire
Messagecarrying a structured tool call. - tool_
result_ message - Build a wire
Messagecarrying a structured tool result keyed to its originatingcall_id. - wire_
to_ llm - Convert an owned wire
Messageinto an llmLlmMessage. - wire_
to_ llm_ stop - Inverse of
llm_stop_to_wire_i32: lift a wire enum value back. - with_
tool_ call_ id - Runs
futwithcurrent_tool_call_idset toidfor its duration.