Expand description
Typed inbound context and explicitly published host-only tool-result metadata.
use rig_core::tool::{ContextValue, ToolContext};
#[derive(serde::Serialize, serde::Deserialize)]
struct Session(String);
impl ContextValue for Session { const KEY: &'static str = "session"; }
let mut context = ToolContext::new();
context.insert(Session("example".into()))?;
assert_eq!(context.require::<Session>()?.0, "example");Structs§
- Published
Context - What one dispatch published beside its answer, passed back beside the
sink rather than on the wire. A tool’s adapter fills it with the tool’s
whole context (a second publish replaces the first); any other layer,
such as a stream rewrite
(
ErasedHandler::map_stream), adds single facts withinsert. - Tool
Context - Context passed to every tool execution.
- Tool
Result Context - Explicitly published, durable tool-result metadata. Unlike
ToolContext, this contains no inbound credentials or live runtime scopes. Values are keyed byContextValue::KEY; applications own their schema versions.
Enums§
- Tool
Context Error - A
ToolContextslot could not be read or written.
Traits§
- Context
Value - Serializable context data with a stable slot key. Distinct value types must
use distinct keys, and persisted keys must remain stable across schema changes.
The derive macro defaults to the type name;
#[context(key = "…")]overrides it.