Expand description
Conversation-protocol policy: the seam between the generic loop and a product’s tool vocabulary.
The core loop is provider-agnostic, sandbox-agnostic, and
tooling-agnostic. It must not know the names of any particular
product’s tools — there is no message_result, no plan, no
capability profile baked into the runtime. But three behaviors
genuinely need product-specific knowledge to do their job well:
- Plain-text recovery. When a provider returns prose instead of a structured tool call, the loop nudges it back onto the protocol. A good nudge names the product’s actual delivery / ask tools.
- Tool-call alias repair. Models sometimes emit a tool name the
product folds into a canonical tool (e.g.
advance(...)→plan(action="advance", ...)). The product knows its aliases; the core does not. - Hidden-tool errors. When a per-turn
crate::plugin::ToolGatenarrows the catalog and the model calls a tool that isn’t advertised, the most useful error names the product concept that hid it (“callplan(action=\"set\")first”). The core can only say “that tool isn’t available this turn.”
Rather than hardcode any product’s vocabulary, the loop delegates all
three to a ProtocolPolicy. The core ships DefaultProtocolPolicy,
whose methods all return generic, vocabulary-free behavior. Downstream
product crates implement their own policy and install it via
crate::AgentBuilder::protocol_policy. This keeps product tool names
out of the open-source core entirely.
Structs§
- Default
Protocol Policy - The generic, vocabulary-free policy installed when a caller does not supply one. Every method takes its trait default.
- Hidden
Tool Context - Context for
ProtocolPolicy::hidden_tool_error. - Hidden
Tool Error - A rendered hidden-tool error: prose the model reads plus a structured
detailspayload for typed downstream handling. - Plain
Text Recovery Context - Context for
ProtocolPolicy::plain_text_recovery_prompt.
Constants§
- DEFAULT_
PLAIN_ TEXT_ RECOVERY_ PROMPT - Generic, product-agnostic plain-text recovery prose. Used when the
active
ProtocolPolicyreturnsNonefromProtocolPolicy::plain_text_recovery_prompt.
Traits§
- Protocol
Policy - Product-specific conversation-protocol policy.