pub struct Runner { /* private fields */ }runner only.Implementations§
Source§impl Runner
impl Runner
Sourcepub fn builder() -> RunnerConfigBuilder<NoAppName, NoAgent, NoSessionService>
pub fn builder() -> RunnerConfigBuilder<NoAppName, NoAgent, NoSessionService>
Create a typestate builder for constructing a Runner.
The builder enforces at compile time that the three required fields
(app_name, agent, session_service) are set before build() is
callable.
§Example
let runner = Runner::builder()
.app_name("my-app")
.agent(agent)
.session_service(session_service)
.build()?;pub fn new(config: RunnerConfig) -> Result<Runner, AdkError>
Sourcepub fn with_skill_injector(self, injector: SkillInjector) -> Runner
Available on crate feature skills only.
pub fn with_skill_injector(self, injector: SkillInjector) -> Runner
skills only.Enable skill injection using a pre-built injector.
Skill injection runs before plugin on_user_message callbacks.
Sourcepub fn with_auto_skills(
self,
root: impl AsRef<Path>,
config: SkillInjectorConfig,
) -> Result<Runner, SkillError>
👎Deprecated: Use with_auto_skills_mut instead
Available on crate feature skills only.
pub fn with_auto_skills( self, root: impl AsRef<Path>, config: SkillInjectorConfig, ) -> Result<Runner, SkillError>
Use with_auto_skills_mut instead
skills only.Enable skill injection by auto-loading .skills/ from the given root path.
Sourcepub fn with_auto_skills_mut(
&mut self,
root: impl AsRef<Path>,
config: SkillInjectorConfig,
) -> Result<(), SkillError>
Available on crate feature skills only.
pub fn with_auto_skills_mut( &mut self, root: impl AsRef<Path>, config: SkillInjectorConfig, ) -> Result<(), SkillError>
skills only.Enable skill injection by auto-loading .skills/ from the given root path.
Unlike with_auto_skills, this method borrows
the Runner mutably instead of consuming it. On error, the Runner remains
valid with no skill injector configured.
pub async fn run( &self, user_id: UserId, session_id: SessionId, user_content: Content, ) -> Result<Pin<Box<dyn Stream<Item = Result<Event, AdkError>> + Send>>, AdkError>
Sourcepub async fn run_str(
&self,
user_id: &str,
session_id: &str,
user_content: Content,
) -> Result<Pin<Box<dyn Stream<Item = Result<Event, AdkError>> + Send>>, AdkError>
pub async fn run_str( &self, user_id: &str, session_id: &str, user_content: Content, ) -> Result<Pin<Box<dyn Stream<Item = Result<Event, AdkError>> + Send>>, AdkError>
Sourcepub fn interrupt(&self, session_id: &str) -> bool
pub fn interrupt(&self, session_id: &str) -> bool
Interrupt a running agent for the given session.
Cancels the agent’s current execution within the event loop. Events
already produced and appended to the session are preserved — only
future events are stopped. The caller can then issue a new run()
call with a different instruction to redirect the agent.
Returns true if a running session was found and interrupted,
false if no active run exists for that session ID.
§Example
// Start a run in the background
let mut stream = runner.run(user_id, session_id, content).await?;
tokio::spawn(async move { while stream.next().await.is_some() {} });
// Later, interrupt it
let was_running = runner.interrupt("session-1");
assert!(was_running);
// Redirect with a new instruction
let mut stream = runner.run(user_id, session_id, new_content).await?;Sourcepub fn active_session_ids(&self) -> Vec<String>
pub fn active_session_ids(&self) -> Vec<String>
Returns the session IDs of all currently running agent executions.
Sourcepub fn find_agent_to_run(
root_agent: &Arc<dyn Agent>,
session: &dyn Session,
) -> Arc<dyn Agent> ⓘ
pub fn find_agent_to_run( root_agent: &Arc<dyn Agent>, session: &dyn Session, ) -> Arc<dyn Agent> ⓘ
Find which agent should handle the request based on session history
Sourcepub fn find_agent(
current: &Arc<dyn Agent>,
target_name: &str,
) -> Option<Arc<dyn Agent>>
pub fn find_agent( current: &Arc<dyn Agent>, target_name: &str, ) -> Option<Arc<dyn Agent>>
Recursively search agent tree for agent with given name
Sourcepub fn compute_transfer_context(
root: &Arc<dyn Agent>,
target_name: &str,
) -> (Option<String>, Vec<String>)
pub fn compute_transfer_context( root: &Arc<dyn Agent>, target_name: &str, ) -> (Option<String>, Vec<String>)
Compute the parent name and peer names for a given agent in the tree.
Returns (parent_name, peer_names).
Walks the agent tree to find the parent of target_name, then collects
the parent’s name and the sibling agent names (excluding the target itself).