adk_core/agent.rs
1use crate::{Content, InvocationContext, Result, RunConfig, event::Event};
2use async_trait::async_trait;
3use futures::stream::Stream;
4use serde::{Deserialize, Serialize};
5use std::pin::Pin;
6use std::sync::Arc;
7
8/// A pinned, boxed stream of [`Event`] results emitted by an agent during execution.
9pub type EventStream = Pin<Box<dyn Stream<Item = Result<Event>> + Send>>;
10
11/// What kind of agent an agent is, as [`Agent::profile`] reports it.
12#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
13pub enum AgentKind {
14 /// An agent that calls a model (`LlmAgent`).
15 Llm,
16 /// Runs its sub-agents one after another (`SequentialAgent`).
17 Sequential,
18 /// Runs its sub-agents at the same time (`ParallelAgent`).
19 Parallel,
20 /// Runs its sub-agents in a loop (`LoopAgent`), at most `max_iterations` times when set.
21 Loop {
22 /// The most iterations the loop runs; `None` for no limit.
23 max_iterations: Option<u32>,
24 },
25 /// Any other agent.
26 #[default]
27 Custom,
28}
29
30/// A tool an agent offers, as [`Agent::profile`] reports it.
31#[derive(Debug, Clone, PartialEq, Eq, Default)]
32pub struct ToolProfile {
33 /// The tool's name.
34 pub name: String,
35 /// What the tool does.
36 pub description: String,
37}
38
39/// What an agent tells callers about itself when they list its skills, such as an A2A
40/// agent card ([`Agent::profile`]).
41#[derive(Debug, Clone, PartialEq, Eq, Default)]
42pub struct AgentProfile {
43 /// The kind of agent.
44 pub kind: AgentKind,
45 /// The agent's fixed instruction, when it has one.
46 pub instruction: Option<String>,
47 /// The agent's fixed global instruction, when it has one.
48 pub global_instruction: Option<String>,
49 /// The tools the agent always offers, in declaration order.
50 pub tools: Vec<ToolProfile>,
51}
52
53/// Runtime composition features an [`Agent`] can consume or enforce.
54///
55/// The declaration is intentionally separate from an agent's domain-specific
56/// skills. It lets portable composition validate that a coordinator can accept
57/// invocation-scoped tools, emit governed transfers, and participate in safe
58/// resume before execution starts.
59#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
60#[serde(rename_all = "camelCase")]
61pub struct AgentCapabilities {
62 /// The agent consumes [`RunConfig::runtime_toolsets`].
63 pub runtime_tools: bool,
64 /// The agent can emit agent-to-agent transfer actions.
65 pub handoff: bool,
66 /// Runtime-injected tools can use exact-call confirmation policy.
67 pub relationship_confirmation: bool,
68 /// The agent can safely resume an unresolved operation from a durable checkpoint.
69 pub checkpoint_resume: bool,
70 /// The agent observes invocation shared state when it is supplied.
71 pub shared_state: bool,
72 /// The agent forwards cancellation and authenticated request metadata.
73 pub invocation_metadata: bool,
74}
75
76/// Primary interaction pattern exposed by an [`Agent`].
77///
78/// This describes how a runtime should present the agent, not how the agent is
79/// composed. Teams and workflows therefore retain their existing agent
80/// primitives while a realtime implementation can advertise audio-oriented
81/// interaction to generic servers and user interfaces.
82#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
83#[serde(rename_all = "camelCase")]
84pub enum AgentInteractionMode {
85 /// A bounded request produces a bounded stream of response events.
86 #[default]
87 RequestResponse,
88 /// A long-lived bidirectional session may emit audio and transcript events.
89 Realtime,
90}
91
92/// Portable description of a member in an agent composition.
93#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
94#[serde(rename_all = "camelCase")]
95pub struct AgentTopologyMember {
96 /// Stable member name used by the runtime.
97 pub name: String,
98 /// Human-readable member purpose.
99 pub description: String,
100 /// Whether this member receives the initial request.
101 pub coordinator: bool,
102 /// Runtime capabilities declared by the bound member.
103 pub capabilities: AgentCapabilities,
104}
105
106/// Control-flow semantics for one portable composition relationship.
107#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
108#[serde(rename_all = "camelCase")]
109pub enum AgentRelationshipKind {
110 /// Deterministic workflow control flows from the source node to the target node.
111 Flow,
112 /// Invoke the target and return its result to the caller.
113 Delegate,
114 /// Transfer active control to the target.
115 Handoff,
116}
117
118/// One exact directed relationship in a portable agent composition.
119#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
120#[serde(rename_all = "camelCase")]
121pub struct AgentTopologyRelationship {
122 /// Calling or transferring member.
123 pub from: String,
124 /// Exact target member.
125 pub to: String,
126 /// Relationship execution semantics.
127 pub kind: AgentRelationshipKind,
128}
129
130/// Portable topology metadata for a composed agent root.
131///
132/// The metadata is deliberately execution-provider neutral. Runtimes and user
133/// interfaces can inspect a composition without depending on a concrete team,
134/// graph, workflow, or model implementation.
135#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
136#[serde(rename_all = "camelCase")]
137pub struct AgentTopology {
138 /// Stable executable root name.
139 pub root: String,
140 /// Member that receives the initial request.
141 pub coordinator: String,
142 /// Members bound to the composition.
143 pub members: Vec<AgentTopologyMember>,
144 /// Exact directed relationships between members.
145 pub relationships: Vec<AgentTopologyRelationship>,
146}
147
148/// One proposed agent-to-agent transfer presented to a composite root.
149#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
150#[serde(rename_all = "camelCase")]
151pub struct AgentTransferRequest {
152 /// Root invocation that owns the transfer chain.
153 pub invocation_id: String,
154 /// Member requesting the transfer.
155 pub from: String,
156 /// Proposed target member.
157 pub to: String,
158 /// One-based transfer depth if the transfer is accepted.
159 pub depth: u32,
160}
161
162/// Result of asynchronous transfer governance.
163#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
164#[serde(rename_all = "camelCase", tag = "decision")]
165pub enum AgentTransferDecision {
166 /// Accept the exact proposed target.
167 Allow,
168 /// Reject the transfer with an auditable reason.
169 Deny {
170 /// Human-readable policy reason.
171 reason: String,
172 },
173}
174
175/// The fundamental trait for all ADK agents.
176///
177/// Every agent — whether a simple LLM wrapper, a multi-step workflow, or a
178/// composite orchestrator — implements this trait. The runtime invokes
179/// [`run`](Self::run) with an [`InvocationContext`] and consumes the returned
180/// [`EventStream`].
181#[async_trait]
182pub trait Agent: Send + Sync {
183 /// Returns the unique name of this agent.
184 fn name(&self) -> &str;
185 /// Returns a human-readable description of this agent's purpose.
186 fn description(&self) -> &str;
187 /// Returns the child agents managed by this agent.
188 fn sub_agents(&self) -> &[Arc<dyn Agent>];
189
190 /// Returns the agent's primary interaction pattern.
191 ///
192 /// Existing agents remain request/response by default. Realtime agents
193 /// override this without introducing a new atomic agent kind or changing
194 /// composition semantics.
195 fn interaction_mode(&self) -> AgentInteractionMode {
196 AgentInteractionMode::RequestResponse
197 }
198
199 /// Whether this agent participates in LLM-driven agent transfer and may be
200 /// resumed directly across conversation turns.
201 ///
202 /// When a session persists across turns, the runner inspects history to
203 /// decide which agent should handle the next user message. LLM-based and
204 /// custom agents return the default `true`, so the runner can hand a new
205 /// turn back to whichever agent responded last.
206 ///
207 /// Deterministic workflow agents (sequential, parallel, loop, conditional)
208 /// override this to return `false`. Their sub-agents must not be resumed
209 /// individually: doing so would skip the workflow's other sub-agents on
210 /// subsequent turns. Returning `false` makes the runner resume the workflow
211 /// root instead, so every sub-agent runs again on each turn.
212 fn supports_agent_transfer(&self) -> bool {
213 true
214 }
215
216 /// Declares the execution-plane capabilities this agent supports.
217 ///
218 /// The default remains compatible with existing custom agents: transfer,
219 /// shared-state, cancellation, and request metadata follow the established
220 /// [`Agent`] and [`InvocationContext`] contracts. Runtime tool injection and
221 /// exact-call relationship confirmation are opt-in because an implementation
222 /// must actively consume those facilities.
223 fn capabilities(&self) -> AgentCapabilities {
224 AgentCapabilities {
225 runtime_tools: false,
226 handoff: self.supports_agent_transfer(),
227 relationship_confirmation: false,
228 checkpoint_resume: false,
229 shared_state: true,
230 invocation_metadata: true,
231 }
232 }
233
234 /// Cancels `task_id`, a task this agent started on another agent, for `acting`: the
235 /// task that waited on it was cancelled, so the input it waits for will never come.
236 ///
237 /// The default does nothing: only an agent that starts tasks elsewhere, such as an A2A
238 /// remote agent, has any to cancel.
239 ///
240 /// # Errors
241 ///
242 /// Returns an error when the other agent cannot be reached or refuses the cancel.
243 async fn cancel_remote_task(
244 &self,
245 _task_id: &str,
246 _acting: &crate::ActingContext,
247 ) -> Result<()> {
248 Ok(())
249 }
250
251 /// What the agent tells callers about itself when they list its skills, such as an A2A
252 /// agent card: its kind, its fixed instructions and its tools.
253 ///
254 /// The default is a [`AgentKind::Custom`] agent with nothing more to say. `LlmAgent`
255 /// and the workflow agents describe themselves.
256 fn profile(&self) -> AgentProfile {
257 AgentProfile::default()
258 }
259
260 /// Returns portable composition metadata when this agent owns an explicit topology.
261 ///
262 /// Leaf agents and legacy composites return `None`. The default keeps this
263 /// additive API backward compatible for existing [`Agent`] implementations.
264 fn topology(&self) -> Option<AgentTopology> {
265 None
266 }
267
268 /// Applies agent-composition policy to a run before the runtime creates the
269 /// invocation context for `agent_name`.
270 ///
271 /// Composite agents can use this hook to inject invocation-scoped tools,
272 /// constrain transfer targets, or tighten depth and concurrency limits.
273 /// The default is a no-op, preserving the behavior of existing agents.
274 fn configure_run(&self, _agent_name: &str, _config: &mut RunConfig) {}
275
276 /// Returns the exact handoff targets allowed for `agent_name`, when this
277 /// agent owns an explicit transfer topology.
278 ///
279 /// `None` asks the runtime to retain its legacy parent/peer discovery.
280 /// `Some(vec![])` explicitly forbids handoff from the named agent.
281 fn transfer_targets_for(&self, _agent_name: &str) -> Option<Vec<String>> {
282 None
283 }
284
285 /// Whether transfer-policy violations should fail the run.
286 ///
287 /// Legacy agent trees return `false`, so missing targets and exceeded depth
288 /// retain their historical warn-and-stop behavior. Validated composites
289 /// return `true` to make topology violations observable errors.
290 fn strict_transfer_policy(&self) -> bool {
291 false
292 }
293
294 /// Applies asynchronous policy to an otherwise valid transfer.
295 ///
296 /// Runner calls this after exact target validation and before control moves
297 /// to the target. Ordinary agents allow transfers, preserving legacy
298 /// behavior; validated composites can attach authorization, lifecycle hooks,
299 /// audit logging, or other policy without teaching Runner their schema.
300 async fn govern_transfer(
301 &self,
302 _request: &AgentTransferRequest,
303 ) -> Result<AgentTransferDecision> {
304 Ok(AgentTransferDecision::Allow)
305 }
306
307 /// Whether this agent may hand control back to the agent that lists it as a sub-agent.
308 ///
309 /// The runner checks every transfer an agent's events request, whether its model or one
310 /// of its tools set [`EventActions::transfer_to_agent`](crate::EventActions), against the
311 /// agents it may transfer to: its sub-agents, its parent when this returns `true`, and
312 /// its parent's other sub-agents when
313 /// [`allows_transfer_to_peers`](Self::allows_transfer_to_peers) returns `true`. Defaults
314 /// to `true`.
315 fn allows_transfer_to_parent(&self) -> bool {
316 true
317 }
318
319 /// Whether this agent may hand control to the other sub-agents of its parent.
320 ///
321 /// See [`allows_transfer_to_parent`](Self::allows_transfer_to_parent). Defaults to `true`.
322 fn allows_transfer_to_peers(&self) -> bool {
323 true
324 }
325
326 /// Releases the resources this agent and its sub-agents hold, such as toolset
327 /// connections.
328 ///
329 /// `adk_runner::Runner::close` calls this on its root agent when the application shuts
330 /// down. The default closes each of [`sub_agents`](Self::sub_agents); an agent that owns
331 /// toolsets or plugins closes them, then its sub-agents.
332 ///
333 /// # Example
334 ///
335 /// ```rust
336 /// use adk_core::{Agent, EventStream, InvocationContext, Result};
337 /// use async_trait::async_trait;
338 /// use std::sync::Arc;
339 ///
340 /// struct Indexer {
341 /// connection: tokio::sync::Mutex<Option<String>>,
342 /// }
343 ///
344 /// #[async_trait]
345 /// impl Agent for Indexer {
346 /// fn name(&self) -> &str {
347 /// "indexer"
348 /// }
349 ///
350 /// fn description(&self) -> &str {
351 /// "indexes documents"
352 /// }
353 ///
354 /// fn sub_agents(&self) -> &[Arc<dyn Agent>] {
355 /// &[]
356 /// }
357 ///
358 /// async fn close(&self) {
359 /// self.connection.lock().await.take();
360 /// }
361 ///
362 /// async fn run(&self, _ctx: Arc<dyn InvocationContext>) -> Result<EventStream> {
363 /// Ok(Box::pin(futures::stream::empty()))
364 /// }
365 /// }
366 /// ```
367 async fn close(&self) {
368 for agent in self.sub_agents() {
369 agent.close().await;
370 }
371 }
372
373 /// Readies what this agent's first turn would otherwise start, such as its model's
374 /// connection and its toolsets' servers, so the turn starts without that wait.
375 ///
376 /// `adk_runner::Runner::prewarm` calls this on its root agent. It sends no prompt and
377 /// runs no tool. The default prewarms each of [`sub_agents`](Self::sub_agents); an agent
378 /// that owns a model or toolsets readies them, then its sub-agents.
379 ///
380 /// # Errors
381 ///
382 /// Returns the first error a model or toolset gave; a turn would meet the same error.
383 ///
384 /// # Example
385 ///
386 /// ```rust
387 /// use adk_core::{Agent, EventStream, InvocationContext, Result};
388 /// use async_trait::async_trait;
389 /// use std::sync::Arc;
390 ///
391 /// struct Leaf;
392 ///
393 /// #[async_trait]
394 /// impl Agent for Leaf {
395 /// fn name(&self) -> &str {
396 /// "leaf"
397 /// }
398 /// fn description(&self) -> &str {
399 /// "does nothing"
400 /// }
401 /// fn sub_agents(&self) -> &[Arc<dyn Agent>] {
402 /// &[]
403 /// }
404 /// async fn run(&self, _ctx: Arc<dyn InvocationContext>) -> Result<EventStream> {
405 /// Ok(Box::pin(futures::stream::empty()))
406 /// }
407 /// }
408 ///
409 /// # futures::executor::block_on(async {
410 /// Leaf.prewarm().await?;
411 /// # Ok::<(), adk_core::AdkError>(())
412 /// # }).unwrap();
413 /// ```
414 async fn prewarm(&self) -> Result<()> {
415 for agent in self.sub_agents() {
416 agent.prewarm().await?;
417 }
418 Ok(())
419 }
420
421 /// Screens a user message with the input guardrails of this agent and of every agent
422 /// below it.
423 ///
424 /// The runner calls this on its root agent before it saves a user message, and saves
425 /// only what it returns, so the session and every later model request hold only the
426 /// screened message. It also screens, before any model call, a saved user message that
427 /// carries no [`EventActions::input_screened`](crate::EventActions::input_screened)
428 /// marker. `Ok(None)` means no agent in the tree screens input; `Ok(Some(content))` is
429 /// the screened message, transformed when a guardrail redacts it.
430 ///
431 /// The default screens the message with each of [`sub_agents`](Self::sub_agents) in
432 /// order. An agent with input guardrails applies its own first, then its sub-agents'.
433 /// An agent that wraps another agent without listing it in `sub_agents` delegates to it.
434 ///
435 /// # Example
436 ///
437 /// ```rust
438 /// use adk_core::{Agent, Content, EventStream, InvocationContext, Result};
439 /// use async_trait::async_trait;
440 /// use std::sync::Arc;
441 ///
442 /// /// Runs `inner` without listing it as a sub-agent.
443 /// struct Wrapper {
444 /// inner: Arc<dyn Agent>,
445 /// }
446 ///
447 /// #[async_trait]
448 /// impl Agent for Wrapper {
449 /// fn name(&self) -> &str {
450 /// "wrapper"
451 /// }
452 ///
453 /// fn description(&self) -> &str {
454 /// "runs its inner agent"
455 /// }
456 ///
457 /// fn sub_agents(&self) -> &[Arc<dyn Agent>] {
458 /// &[]
459 /// }
460 ///
461 /// async fn screen_user_input(&self, content: &Content) -> Result<Option<Content>> {
462 /// self.inner.screen_user_input(content).await
463 /// }
464 ///
465 /// async fn run(&self, ctx: Arc<dyn InvocationContext>) -> Result<EventStream> {
466 /// self.inner.run(ctx).await
467 /// }
468 /// }
469 /// ```
470 ///
471 /// # Errors
472 ///
473 /// Returns the guardrail's error when it blocks the message, which is then neither
474 /// saved nor sent to a model.
475 async fn screen_user_input(&self, content: &Content) -> Result<Option<Content>> {
476 screen_user_input_with(self.sub_agents(), content).await
477 }
478
479 /// Executes the agent and returns a stream of events.
480 async fn run(&self, ctx: Arc<dyn InvocationContext>) -> Result<EventStream>;
481}
482
483/// Screens a user message with each agent's [`Agent::screen_user_input`] in order, each
484/// agent receiving the previous agent's output.
485///
486/// Returns `Ok(None)` when none of the agents screens input. An [`Agent`] with its own
487/// input guardrails calls this on its sub-agents after applying them.
488///
489/// # Example
490///
491/// ```rust
492/// use adk_core::{Agent, Content, screen_user_input_with};
493/// use std::sync::Arc;
494///
495/// # async fn demo() -> adk_core::Result<()> {
496/// let agents: Vec<Arc<dyn Agent>> = Vec::new();
497/// let message = Content::new("user").with_text("hello");
498/// assert!(screen_user_input_with(&agents, &message).await?.is_none());
499/// # Ok(())
500/// # }
501/// ```
502///
503/// # Errors
504///
505/// Returns the first error an agent returns, which is a guardrail blocking the message.
506pub async fn screen_user_input_with(
507 agents: &[Arc<dyn Agent>],
508 content: &Content,
509) -> Result<Option<Content>> {
510 let mut screened: Option<Content> = None;
511 for agent in agents {
512 if let Some(next) = agent.screen_user_input(screened.as_ref().unwrap_or(content)).await? {
513 screened = Some(next);
514 }
515 }
516 Ok(screened)
517}
518
519/// A validated context containing engineered instructions and resolved tool instances.
520///
521/// This structure serves as the "Atomic Unit of Capability" for an agent. It guarantees
522/// that the agent's cognitive frame (the instructions telling it what it can do) is
523/// perfectly aligned with its physical capabilities (the binary tool instances bound
524/// to the session).
525///
526/// By using `ResolvedContext`, the framework eliminates "Phantom Tool" hallucinations,
527/// where an agent tries to call a tool that was mentioned in its prompt but never
528/// actually registered in the runtime.
529#[derive(Clone)]
530pub struct ResolvedContext {
531 /// The engineered system instruction.
532 pub system_instruction: String,
533 /// The resolved, executable tools.
534 pub active_tools: Vec<Arc<dyn crate::Tool>>,
535}
536
537impl std::fmt::Debug for ResolvedContext {
538 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
539 f.debug_struct("ResolvedContext")
540 .field("system_instruction_len", &self.system_instruction.len())
541 .field("active_tools_count", &self.active_tools.len())
542 .finish()
543 }
544}
545
546#[cfg(test)]
547mod tests {
548 use super::*;
549 use crate::{Content, ReadonlyContext, RunConfig};
550 use async_stream::stream;
551
552 struct TestAgent {
553 name: String,
554 }
555
556 use crate::{CallbackContext, Session, State};
557 use std::collections::HashMap;
558
559 struct MockState;
560 impl State for MockState {
561 fn get(&self, _key: &str) -> Option<serde_json::Value> {
562 None
563 }
564 fn set(&mut self, _key: String, _value: serde_json::Value) {}
565 fn all(&self) -> HashMap<String, serde_json::Value> {
566 HashMap::new()
567 }
568 }
569
570 struct MockSession;
571 impl Session for MockSession {
572 fn id(&self) -> &str {
573 "session"
574 }
575 fn app_name(&self) -> &str {
576 "app"
577 }
578 fn user_id(&self) -> &str {
579 "user"
580 }
581 fn state(&self) -> &dyn State {
582 &MockState
583 }
584 fn conversation_history(&self) -> Vec<Content> {
585 Vec::new()
586 }
587 }
588
589 #[allow(dead_code)]
590 struct TestContext {
591 content: Content,
592 config: RunConfig,
593 session: MockSession,
594 }
595
596 #[allow(dead_code)]
597 impl TestContext {
598 fn new() -> Self {
599 Self {
600 content: Content::new("user"),
601 config: RunConfig::default(),
602 session: MockSession,
603 }
604 }
605 }
606
607 #[async_trait]
608 impl ReadonlyContext for TestContext {
609 fn invocation_id(&self) -> &str {
610 "test"
611 }
612 fn agent_name(&self) -> &str {
613 "test"
614 }
615 fn user_id(&self) -> &str {
616 "user"
617 }
618 fn app_name(&self) -> &str {
619 "app"
620 }
621 fn session_id(&self) -> &str {
622 "session"
623 }
624 fn branch(&self) -> &str {
625 ""
626 }
627 fn user_content(&self) -> &Content {
628 &self.content
629 }
630 }
631
632 #[async_trait]
633 impl CallbackContext for TestContext {
634 fn artifacts(&self) -> Option<Arc<dyn crate::Artifacts>> {
635 None
636 }
637 }
638
639 #[async_trait]
640 impl InvocationContext for TestContext {
641 fn agent(&self) -> Arc<dyn Agent> {
642 unimplemented!()
643 }
644 fn memory(&self) -> Option<Arc<dyn crate::Memory>> {
645 None
646 }
647 fn session(&self) -> &dyn Session {
648 &self.session
649 }
650 fn run_config(&self) -> &RunConfig {
651 &self.config
652 }
653 fn end_invocation(&self) {}
654 fn ended(&self) -> bool {
655 false
656 }
657 }
658
659 #[async_trait]
660 impl Agent for TestAgent {
661 fn name(&self) -> &str {
662 &self.name
663 }
664
665 fn description(&self) -> &str {
666 "test agent"
667 }
668
669 fn sub_agents(&self) -> &[Arc<dyn Agent>] {
670 &[]
671 }
672
673 async fn run(&self, _ctx: Arc<dyn InvocationContext>) -> Result<EventStream> {
674 let s = stream! {
675 yield Ok(Event::new("test"));
676 };
677 Ok(Box::pin(s))
678 }
679 }
680
681 #[test]
682 fn test_agent_trait() {
683 let agent = TestAgent { name: "test".to_string() };
684 assert_eq!(agent.name(), "test");
685 assert_eq!(agent.description(), "test agent");
686 assert!(agent.capabilities().handoff);
687 assert!(!agent.capabilities().runtime_tools);
688 assert_eq!(agent.interaction_mode(), AgentInteractionMode::RequestResponse);
689 assert_eq!(agent.topology(), None);
690 }
691
692 #[tokio::test]
693 async fn default_transfer_governance_is_backward_compatible() {
694 let agent = TestAgent { name: "test".to_string() };
695 let request = AgentTransferRequest {
696 invocation_id: "inv-1".to_string(),
697 from: "test".to_string(),
698 to: "peer".to_string(),
699 depth: 1,
700 };
701 assert_eq!(agent.govern_transfer(&request).await.unwrap(), AgentTransferDecision::Allow);
702 }
703}