You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Migrate specials.rs (History, ToolCall, NoTool) to typed architecture #72
ToolCall — schemars-derived placeholder (name-collides with rig::message::ToolCall)
NoTool / NoToolError — rig::Tool impl placeholder
These are features, not dead code — History and Tools are important for the DSPy programming model. But they're wired to the old schemars plumbing, not the BamlType/Facet/SignatureSchema typed path.
DSPy Python has:
dspy.Tool — wraps Python functions, auto-extracts name + args schema from type hints
dspy.ToolCalls — output field type for tool call results
list[dspy.Tool] as an input field type recognized by the Adapter
Native function calling detection: if model supports it, tools go via LM API; otherwise formatted in prompt text
What's needed
Migrate types to BamlType + Facet
History → #[derive(BamlType, Facet)] instead of #[derive(Serialize, JsonSchema)]
ToolCall → rename to avoid collision with rig's ToolCall, derive BamlType + Facet
These should be recognizable as special field types in SignatureSchema
Adapter-level tool awareness
ChatAdapter should detect Tool/ToolCalls fields in a signature
If model supports native function calling → route via LM API tools
Otherwise → format tool descriptions in prompt text (like DSPy's fallback)
Wire NoTool properly
Or remove it if rig's tool abstraction is sufficient
Current NoTool is a rig::Tool impl that returns "No tool" — placeholder
Post-schemars
Once this + field!/sign! macros are migrated, schemars dep can be dropped
// core/specials.rs — 44 lines totaluse schemars::JsonSchema;use serde::{Deserialize,Serialize};#[derive(Serialize,JsonSchema,Clone)]pubstructHistory;#[derive(Deserialize,JsonSchema,Clone)]pubstructToolCall;// name-collides with rig::message::ToolCallpubstructNoTool;// ... rig::tool::Tool impl that returns "No tool"
What needs to happen:
History → #[BamlType] derive. Needs to be recognizable by ChatAdapter as a special field type that gets formatted as conversation history in the prompt (DSPy injects few-shot demos here).
ToolCall → rename to DsrsToolCall or ToolCallOutput to avoid collision with rig::message::ToolCall. Derive #[BamlType]. Should represent the output type when tools are used.
NoTool → evaluate if still needed. The rig::Tool impl is a placeholder. If LM::call() already handles the no-tools case (it does — tools param is Vec<Arc<dyn ToolDyn>>), then NoTool might be deletable.
Adapter-level tool awareness — ChatAdapter should detect when a signature has Tool/ToolCall fields and:
If model supports native function calling → route via API tools param
Otherwise → format tool descriptions as text in the prompt (DSPy's fallback path)
This is small but has design implications for how tools integrate with the typed signature system. The type itself is easy to migrate; the adapter integration is the real work.
Activity
darinkishore commentedon Feb 12, 2026
Codebase audit — current state of specials.rs
What needs to happen:
History→#[BamlType]derive. Needs to be recognizable byChatAdapteras a special field type that gets formatted as conversation history in the prompt (DSPy injects few-shot demos here).ToolCall→ rename toDsrsToolCallorToolCallOutputto avoid collision withrig::message::ToolCall. Derive#[BamlType]. Should represent the output type when tools are used.NoTool→ evaluate if still needed. Therig::Toolimpl is a placeholder. IfLM::call()already handles the no-tools case (it does —toolsparam isVec<Arc<dyn ToolDyn>>), thenNoToolmight be deletable.Adapter-level tool awareness —
ChatAdaptershould detect when a signature hasTool/ToolCallfields and:toolsparamThis is small but has design implications for how tools integrate with the typed signature system. The type itself is easy to migrate; the adapter integration is the real work.