Skip to main content

Module dialect

Module dialect 

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

  1. Prompt injectionrender_inband_tool_prompt appends the tool catalog plus the dialect’s format guide to the system prompt.
  2. History encodingencode_inband_tool_history rewrites 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).
  3. Output parsingDialect::parse turns the model’s text back into ScanSegments (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§

RenderedToolResult
A tool result flattened to text for dialect rendering.
ToolArgShape
Per-tool argument shape derived from its JSON Schema.

Enums§

Dialect
An owned tool-calling dialect.
ScanSegment
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.