class

Crig::Tool::ToolContext

Inherits Reference < Object

Context passed to every tool execution.

Callers insert typed inbound values with #insert. Tools read those values with #get or #require, and attach host-only result metadata with #insert_result. Result hooks inspect that metadata through #result. Neither inbound values nor result metadata are sent to the model.

Dispatch clones inbound values once per call. Map-level mutations (inserting, replacing, or removing typed slots) affect only that execution.

Constructors

Instance methods

accept_dispatch_result(dispatched : ToolContext)

Publish metadata produced by one dispatch while preserving the caller's inbound values.

Source
clear_dispatch_result

Clear metadata from the previous dispatch before starting another one.

Source
contains?(type : T.class) : Bool forall T

Whether this context contains the inbound type T.

Source
empty?
Source
for_dispatch

Build a fresh execution context with the same inbound values and no result metadata.

Source
get(type : T.class) : T | Nil forall T

Read an inbound typed value.

Source
get_mut(type : T.class) : T | Nil forall T

Mutably access an inbound typed value.

Source
inbound_only

A context carrying only the inbound values, with no result metadata. Used to hand the caller's inbound context to a sub-agent invoked as a tool (upstream ToolContext::inbound_only).

Source
initialize_with_inbound(inbound : Hash(String, String) | Nil)

Internal: construct with pre-populated inbound map.

Source
insert(val : T) : T | Nil forall T

Insert an inbound typed value, returning the displaced value if present.

Source
insert_result(val : T) : T | Nil forall T

Attach host-only metadata to this execution's result.

Source
remove(type : T.class) : T | Nil forall T

Remove an inbound typed value.

Source
require(type : T.class) : T forall T

Require an inbound typed value, raising MissingToolContext if absent.

Source
require_result(type : T.class) : T forall T

Require host-only result metadata.

Source
result(type : T.class) : T | Nil forall T

Read host-only result metadata.

Source
size
Source