Expand description
Agent loop — the core execution engine for phi-core agents.
This module is split into focused sub-modules:
- [
config] — Hook type aliases andAgentLoopConfig - [
core] — Entry points:agent_loop,agent_loop_continue - [
run] — Core turn engine (run_loop) - [
streaming] — LLM response streaming - [
tools] — Tool execution pipeline - [
parallel] — Evaluational parallelism (agent_loop_parallel) evaluation— Pluggable evaluation strategies for parallel branch selection- [
helpers] — Utilities (input filters, config derivation, etc.)
Re-exports§
pub use evaluation::ElaborateEvaluation;pub use evaluation::LlmJudgeEvaluation;pub use evaluation::PickFirstEvaluation;pub use evaluation::TokenEfficientEvaluation;pub use evaluation::TransparentEvaluation;
Modules§
- evaluation
- Pluggable evaluation strategies for
agent_loop_parallel. - script_
callback - Script-based callbacks — run shell or Python scripts as lifecycle hooks.
Structs§
- Agent
Loop Config - All static settings for a single [
agent_loop] / [agent_loop_continue] call.
Functions§
- agent_
loop - Start an agent loop with new prompt messages.
- agent_
loop_ continue - Resume an agent loop from existing context without new prompts.
- agent_
loop_ parallel - Run multiple agent loop configurations concurrently from a shared base context, evaluate the results with the supplied strategy, and return the selected outcome.
Type Aliases§
- After
Compaction EndFn - Called after compaction completes.
- After
Loop Fn - Called once after the entire agent loop ends (after
AgentEndis emitted). - After
Tool Execution Fn - Called after each tool call (after
ToolExecutionEndis emitted). - After
Tool Execution Update Fn - Called after each incremental tool update (after
ToolExecutionUpdateis emitted). - After
Turn Fn - Called after each LLM turn (after
TurnEndis emitted). - Before
Compaction Start Fn - Called before compaction starts.
- Before
Loop Fn - Called once before the entire agent loop begins (before
AgentStartis emitted). - Before
Tool Execution Fn - Called before each tool call (before
ToolExecutionStartis emitted). - Before
Tool Execution Update Fn - Called before each incremental tool update (before
ToolExecutionUpdateis emitted). - Before
Turn Fn - Called before each LLM turn (before
TurnStartis emitted). - Convert
ToLlm Fn - All hook types use
Arc(shared ownership) so they can be cloned into closures and stored without lifetime complications.Box<dyn Fn>would suffice for single-owner cases butArcmakes it trivially cheap to share across async tasks. ConvertsAgentMessage[]→Message[]before each LLM call. - GetMessages
Fn - Returns pending messages (steering interrupts or follow-up work) when polled.
- Hook
Future - Boxed-future return type used by all 0.9.0 async lifecycle hooks.
Tis the hook’s logical return value (oftenboolfor veto-returning hooks or()for fire-and-forget hooks). - OnError
Fn - Called when the LLM returns
StopReason::Error. Argument: the error message string. - Transform
Context Fn - Transforms the full context before
convert_to_llm(for pruning, reordering, injection).