pub struct ToolGateContext<'a> {
pub iteration: usize,
pub messages: &'a [AgentMessage],
pub conversation_id: Option<&'a str>,
pub available_tool_names: &'a [&'a str],
}Expand description
Read-only loop state handed to a ToolGate so its decision is a
pure function of observables, not of internal flag bookkeeping.
New fields are additive — gates that don’t care can ignore them.
Fields§
§iteration: usizeZero-indexed iteration within the current run. The very first
LLM call after the user message has iteration == 0. Increments
once per stream_assistant_response.
messages: &'a [AgentMessage]Full message history that will be sent on the next request,
after any ContextTransform reshaping. Use this to derive
signals like “have we seen a terminator yet” or “how many tool
results in a row didn’t make progress”.
conversation_id: Option<&'a str>Conversation identifier when the host runtime knows one (a
session runner threads it through). None for embeddings of the
loop that don’t carry conversation identity (tests, isolated
subagent runs). Gates can use this for diagnostics or
conversation-scoped policy.
available_tool_names: &'a [&'a str]Names of every tool the loop is about to advertise on the next request, in registration order. Lets gates compute denylist-style allowlists (“everything except these terminators”) without hardcoding the catalog or extending the trait. Empty in tests that don’t care about the universe.