Skip to main content

Crate polyc_agent

Crate polyc_agent 

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

handoff
Handoff (sub-agent transfer) primitive for the agent turn loop.
llm_summarizer
LLM-backed anchored-iterative Summarizer.
participation
The provider-agnostic “should the agent speak?” classifier.

Structs§

PendingApproval
One tool call awaiting human-in-the-loop approval.
RunTurnOptions
Options for a single run_turn invocation.
StubSummarizer
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).
StubTools
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).
TurnResult
Output of one run_turn call.

Enums§

TurnStreamEvent
Re-export so callers can build a streaming channel without depending on polyc-llm directly. An incremental event observed while folding a turn, for live streaming.

Constants§

SUMMARY_TRIGGER
Trigger threshold for summarization.

Traits§

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).
ToolExecutor
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_with tool execution; None outside that scope.
llm_stop_to_wire_i32
Map an llm-side StopReason to the wire enum value.
llm_to_wire
Convert an llm LlmMessage back to a wire Message for transmission over HarnessService.
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 Message carrying a single text content block.
tool_call_message
Build a wire Message carrying a structured tool call.
tool_result_message
Build a wire Message carrying a structured tool result keyed to its originating call_id.
wire_to_llm
Convert an owned wire Message into an llm LlmMessage.
wire_to_llm_stop
Inverse of llm_stop_to_wire_i32: lift a wire enum value back.
with_tool_call_id
Runs fut with current_tool_call_id set to id for its duration.