Skip to main content

GraphAgent

Struct GraphAgent 

Source
pub struct GraphAgent { /* private fields */ }
Expand description

GraphAgent wraps a CompiledGraph as an ADK Agent

§Turns and checkpoints

Each Agent::run call is one turn on a thread whose id is the session id. With a checkpointer configured:

Thread’s latest checkpointWhat the turn does
NoneRuns the graph from its entry nodes.
Paused (non-empty frontier)Resumes the paused run, with the turn’s input merged into its state.
Finished (empty frontier)Runs the graph again from its entry nodes, starting from the previous turn’s final state with the turn’s input merged on top.

The recursion limit applies to each turn separately. GraphAgent::invoke keeps the direct-graph behaviour, where re-invoking a finished thread returns its final state without running anything.

Implementations§

Source§

impl GraphAgent

Source

pub fn builder(name: &str) -> GraphAgentBuilder

Create a new GraphAgent builder

Source

pub fn from_graph(name: &str, graph: CompiledGraph) -> Self

Create directly from a compiled graph

Source

pub fn graph(&self) -> &CompiledGraph

Get the underlying compiled graph

Source

pub async fn invoke( &self, input: State, config: ExecutionConfig, ) -> Result<State>

Execute the graph directly (bypassing Agent trait)

Source

pub fn stream( &self, input: State, config: ExecutionConfig, mode: StreamMode, ) -> impl Stream<Item = Result<StreamEvent>> + '_

Stream execution

Trait Implementations§

Source§

impl Agent for GraphAgent

Source§

fn name(&self) -> &str

Returns the unique name of this agent.
Source§

fn description(&self) -> &str

Returns a human-readable description of this agent’s purpose.
Source§

fn sub_agents(&self) -> &[Arc<dyn Agent>]

Returns the child agents managed by this agent.
Source§

fn supports_agent_transfer(&self) -> bool

Whether this agent participates in LLM-driven agent transfer and may be resumed directly across conversation turns. Read more
Source§

fn capabilities(&self) -> AgentCapabilities

Declares the execution-plane capabilities this agent supports. Read more
Source§

fn topology(&self) -> Option<AgentTopology>

Returns portable composition metadata when this agent owns an explicit topology. Read more
Source§

fn run<'life0, 'async_trait>( &'life0 self, ctx: Arc<dyn InvocationContext>, ) -> Pin<Box<dyn Future<Output = Result<EventStream>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Executes the agent and returns a stream of events.
Source§

fn interaction_mode(&self) -> AgentInteractionMode

Returns the agent’s primary interaction pattern. Read more
Source§

fn configure_run(&self, _agent_name: &str, _config: &mut RunConfig)

Applies agent-composition policy to a run before the runtime creates the invocation context for agent_name. Read more
Source§

fn transfer_targets_for(&self, _agent_name: &str) -> Option<Vec<String>>

Returns the exact handoff targets allowed for agent_name, when this agent owns an explicit transfer topology. Read more
Source§

fn strict_transfer_policy(&self) -> bool

Whether transfer-policy violations should fail the run. Read more
Source§

fn govern_transfer<'life0, 'life1, 'async_trait>( &'life0 self, _request: &'life1 AgentTransferRequest, ) -> Pin<Box<dyn Future<Output = Result<AgentTransferDecision, AdkError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Applies asynchronous policy to an otherwise valid transfer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more