pub struct FunctionInvocationContext {
pub function_name: String,
pub arguments: Value,
pub session: Option<AgentSession>,
pub tools: Option<LiveToolList>,
pub metadata: HashMap<String, Value>,
pub result: Option<Value>,
pub terminate: bool,
}Expand description
Context flowing through the function middleware pipeline.
Fields§
§function_name: String§arguments: Value§session: Option<AgentSession>The AgentSession of the agent run
this invocation belongs to, if the call originated from an agent run
with a session. Middleware may read it; tools receive it via
Tool::invoke_in_context
(the hook behind Agent::as_tool with propagate_session). Mirrors
upstream’s FunctionInvocationContext.session.
tools: Option<LiveToolList>The live, mutable tool list of the current agent run, or None when
the function is invoked outside a function-calling loop (e.g. via
Tool::invoke directly). Middleware and
tools may add_tools /
remove_tools; mutations
take effect on the next model iteration, not the in-flight batch.
metadata: HashMap<String, Value>§result: Option<Value>§terminate: boolImplementations§
Source§impl FunctionInvocationContext
impl FunctionInvocationContext
pub fn new( function_name: impl Into<String>, arguments: Value, ) -> FunctionInvocationContext
Sourcepub fn with_session(
self,
session: Option<AgentSession>,
) -> FunctionInvocationContext
pub fn with_session( self, session: Option<AgentSession>, ) -> FunctionInvocationContext
Builder: attach the agent session this invocation belongs to.
Sourcepub fn with_tools(
self,
tools: Option<LiveToolList>,
) -> FunctionInvocationContext
pub fn with_tools( self, tools: Option<LiveToolList>, ) -> FunctionInvocationContext
Builder: attach the run’s live tool list.
Sourcepub fn add_tools(
&self,
tools: impl IntoIterator<Item = ToolDefinition>,
) -> Result<(), Error>
pub fn add_tools( &self, tools: impl IntoIterator<Item = ToolDefinition>, ) -> Result<(), Error>
Add tools to the current agent run (progressive tool exposure); see
LiveToolList::add_tools. Errors when this invocation is not bound
to a live agent run (mirrors upstream’s RuntimeError).
Sourcepub fn remove_tools<'a>(
&self,
names: impl IntoIterator<Item = &'a str>,
) -> Result<(), Error>
pub fn remove_tools<'a>( &self, names: impl IntoIterator<Item = &'a str>, ) -> Result<(), Error>
Remove tools from the current agent run by name; see
LiveToolList::remove_tools. Errors when this invocation is not
bound to a live agent run.