gadk-agent
The agent API of gadk: the Agent trait and the one agent implementation every agent type
builds on, the three context types (ReadonlyContext, InvocationContext, Context), the
Tool and Toolset traits, the agent, model and tool callbacks, plugins (Plugin,
PluginConfig), RunConfig, the live (bidirectional streaming) request types and the Loader
a server uses to find an agent by application name (SingleLoader, MultiLoader).
It also carries the execution-identity pieces the engine and the analytics plugin rely on:
fibers (fiber), cancel causes (CancelCause, with DeadlineExceeded for agent timeouts) and
the per-invocation teardown registry (Teardowns), through which work started by a component
finishes before the runner's after-run callbacks even when a consumer stops reading early.
This crate defines the API but runs nothing: the LLM agent, the workflow agents and the runner
are in gadk-engine. Most applications use it through the gadk façade (gadk::agent, and
the common types in gadk::prelude).
Example
A custom agent whose behaviour is a function from the invocation context to a stream of events:
use Arc;
use stream;
use ;
use ;
use Event;
let greeter = new_agent?;
new_agent fails when the name is empty or a sub-agent is listed twice. An event with no author
gets the agent's name (or user for user-role content). Run the agent with
gadk_engine::Runner like any other agent.
Tool helpers
filter_toolsetandallowed_tools_predicate/string_predicaterestrict which of a toolset's tools an agent sees.with_confirmationwraps a toolset so its tools' calls need a Human-in-the-Loop confirmation, always or as aConfirmationProviderdecides per call.- Neither toolset wrapper forwards the inner toolset's
process_request.