Expand description
Provider tool formatters.
Each provider (or family) shapes ToolDefinition into the JSON it expects on the
wire. Historically, this logic was scattered across the request builders of each
provider crate, making it hard to verify cross-provider invariants (e.g. that
defer_loading, strict, input_examples, allowed_callers are preserved when
they apply). This module introduces a single trait that all providers can
implement, plus ready-made implementations for the most common cases.
The trait is intentionally additive: existing callers can keep using the
per-provider helpers (e.g. serialize_tools_openai_format,
anthropic::request_builder::tools::build_tools). New callers should reach for
formatter_for(provider_id, model) instead.
See The Hitchhiker’s Guide to Agentic AI §18.4.1 for the underlying model (separate OpenAI / Anthropic / Gemini / MCP wire shapes) and §18.4.2 for the selection / routing concerns that sit above this layer.
Structs§
- Anthropic
Formatter - Anthropic formatter — extracts logic from
crates/codegen/vtcode-llm/src/providers/anthropic/request_builder/tools.rs::build_tools. - Gemini
Formatter - Gemini formatter — uses
function_declarationsplus native hosted tool shapes. - OpenAI
Chat Formatter - OpenAI Chat Completions formatter — extracts logic from
crates/codegen/vtcode-llm/src/providers/common.rs::serialize_tools_openai_format. - OpenAI
Compatible Formatter - Generic OpenAI-compatible formatter. Unlike
OpenAIChatFormatter, this one is intentionally conservative: it only emits function-shaped tools and silently drops hosted / native tool types because most compatible providers don’t support them. - OpenAI
Responses Formatter - OpenAI Responses API formatter — model-aware, preserves
defer_loading.
Enums§
- Provider
Family - Identifies a provider family for the purpose of tool formatting.
- Provider
Formatter - Static-dispatch formatter covering every provider family.
Traits§
- Provider
Tool Formatter - Trait implemented by every provider tool formatter.
Functions§
- formatter
- Build a formatter for a given provider family without heap allocation or dynamic dispatch.
- formatter_
for - Convenience: resolve a formatter using the explicit
ProviderFamily. Useful in tests or when the runloop already knows the family without parsing the provider string.