Expand description
Tool authoring contracts, dispatch context, and canonical execution values.
Tool is the tool trait; each call gets a ToolContext.
use rig_core::tool::ToolOutput;
let output = ToolOutput::json(serde_json::json!({"count": 3}));
assert!(output.as_json().is_some());Re-exports§
pub use context::ContextValue;pub use context::PublishedContext;pub use context::ToolContext;pub use context::ToolContextError;pub use context::ToolResultContext;pub use contextual::DynamicTool;pub use contextual::LivenessFn;pub use contextual::Tool;pub use contextual::ToolEmbedding;pub use contextual::tool_definition;pub use contextual::tool_name;pub use managed::ManagedToolSink;pub use managed::ManagedToolToken;pub use schema::args_schema;
Modules§
- builtin
- Built-in tools shipped with
rigthat agents can use out of the box. - context
- Typed inbound context and explicitly published host-only tool-result metadata.
- contextual
- Contextual tool authoring and JSON-argument dispatch adapters.
ToolContextcarries typed inbound values and host-only result metadata; model-visible outputs retain their text, JSON, or multimodal representation. - feedback
- What the model reads about its tool calls: a tool’s result shaped as a
tool result, the error result of a call that never ran, what a call
that did not finish says (
not_finished), and the feedback for arguments that do not fit a tool. - managed
- Registry contracts for refreshable external tool sources.
Generation tokens protect newer registrations from stale refreshes, while
DynamicTool::is_livereports disconnection without tool execution. - schema
- A tool’s parameters derived from its arguments type, so the schema the model sees and the type its arguments are parsed into cannot disagree:
- validate
- Whether a value fits a JSON schema, and where it does not: the check a
tool call’s arguments pass before the tool runs
(
arguments_refusal).
Structs§
- Content
Hash - The SHA-256 of a file’s bytes, as lowercase hex: which content a tool
read or left (
content_hash). - File
Change - One file a tool call changed.
- File
Read - One file a tool call read.
- File
State - A file on one side of a
FileChange: as it was before the change, or as the change left it. - Files
Changed - The files a tool call changed, in the order it changed them.
- Files
Read - The files a tool call read, in the order it read them, each once: a file it showed the model, or one it found matches in.
- Hunk
- One run of a
FileChange: the lines it removed and added, between the lines around them it kept. - Lines
- Lines of a file that a
Hunkspans:countlines from linestart, counted from 1. An empty span starts at the line it comes before. Shown as a unified diff’s range (3,2;3;2,0for an empty one before line 3). - Lines
Shown - The lines of a file a tool showed:
countlines from linefirst, of thetotalit has. - Output
Cut - A tool’s output was cut to fit: the model’s text keeps one end, or both ends and some lines from between, and says so in a line of its own. A front reads this fact, not that line’s wording, to draw and count the cut.
- Tool
Execution Error - One public envelope for every tool execution failure.
- Tool
Output - The canonical model-visible output produced by a tool.
- Tool
Result - The single structured execution view used by dispatch, hooks, and telemetry.
Enums§
- Change
Kind - What a tool call did to a file.
- Exit
Status - How a process a tool call ran ended.
- Hunk
Line - A line of a
Hunk, with its ending. Its wire form is the line as a unified diff shows it: its sign (,-or+), then its text. - KeptEnd
- Which part of a cut output a tool kept (
OutputCut::kept). - Scope
- What a footprint names: these paths (absolute; a directory covers what
is under it), or anything at all. A guard compares paths as they are,
so a host makes a footprint
normalizedbefore any guard sees it; the rig kernel does so for every tool call. - Tool
Error Kind - Normalized classification for a tool execution error.
- Touches
- What a tool call may read and change, so calls that touch different things run side by side.
Traits§
- Into
Tool Output - Conversion into Rig’s canonical tool output.
Functions§
- content_
hash - The
ContentHashofbytes.