Expand description
Owned (in-band) tool-calling dialects — tool calls as text for models
without native tool support (omp pi-ai/dialect port).
Owned (in-band) tool-calling dialects.
This module is the Rust port of omp’s @oh-my-pi/pi-ai/dialect package. It
lets a model that has no native tool-calling support still drive the
agent loop: the tool catalog is injected into the system prompt as text,
prior tool calls/results are re-encoded as text in the history, and the
model’s text output is parsed back into canonical ToolCall blocks.
§Architecture (omp three-piece contract)
- Prompt injection —
render_inband_tool_promptappends the tool catalog plus the dialect’s format guide to the system prompt. - History encoding —
encode_inband_tool_historyrewrites prior assistant tool calls and tool results into the dialect’s text form so the model sees a coherent transcript (and prefix caching stays stable). - Output parsing —
Dialect::parseturns the model’s text back intoScanSegments (text / thinking / tool calls) the loop can execute.
§Dialects
Dialect enumerates the 11 wire dialects omp knows. This first delivery
implements the XML dialect fully (the documented fallback,
FALLBACK_DIALECT in omp). Dialects without a dedicated implementation
fall back to XML — this mirrors omp’s fallback semantics rather than being a
placeholder: XML’s <invoke>/<parameter> grammar is the generic envelope.
Streaming scanners and agent-loop wiring land in a follow-up.
Structs§
- Rendered
Tool Result - A tool result flattened to text for dialect rendering.
- Tool
ArgShape - Per-tool argument shape derived from its JSON Schema.
Enums§
- Dialect
- An owned tool-calling dialect.
- Scan
Segment - A parsed segment of in-band model output.
Constants§
- FALLBACK_
DIALECT - The dialect used when a model family has no dedicated grammar.
Functions§
- build_
arg_ shapes - Build argument shapes for a set of tools.
- encode_
inband_ tool_ history - Re-encode a message history for an owned-dialect (tools-less) request.
- is_
string_ only_ schema - Whether a schema denotes a string-only value (string, ignoring
null). - render_
inband_ tool_ prompt - Render the full in-band tool prompt: catalog + dialect format guide.
- render_
tool_ catalog - Render the tool catalog — one JSON object per line.