agents_runtime/
lib.rs

1//! Tokio-powered runtime that glues together planners, tools, and prompt packs.
2//! The initial implementation focuses on synchronous message handling with
3//! pluggable state stores and tracing hooks.
4
5use std::sync::Arc;
6
7use agents_core::agent::{AgentDescriptor, AgentHandle};
8use agents_core::messaging::AgentMessage;
9use agents_core::state::AgentStateSnapshot;
10use async_trait::async_trait;
11
12pub mod agent;
13pub mod middleware;
14pub mod planner;
15pub mod providers;
16
17// Re-export key functions for convenience - now from the agent module
18pub use agent::{
19    create_async_deep_agent, create_deep_agent, get_default_model, ConfigurableAgentBuilder,
20    DeepAgent,
21};
22
23/// Default runtime wrapper that delegates to an inner agent implementation.
24pub struct RuntimeAgent<T>
25where
26    T: AgentHandle,
27{
28    inner: Arc<T>,
29}
30
31impl<T> RuntimeAgent<T>
32where
33    T: AgentHandle,
34{
35    pub fn new(inner: Arc<T>) -> Self {
36        Self { inner }
37    }
38}
39
40#[async_trait]
41impl<T> AgentHandle for RuntimeAgent<T>
42where
43    T: AgentHandle + Sync + Send,
44{
45    async fn describe(&self) -> AgentDescriptor {
46        self.inner.describe().await
47    }
48
49    async fn handle_message(
50        &self,
51        input: AgentMessage,
52        state: Arc<AgentStateSnapshot>,
53    ) -> anyhow::Result<AgentMessage> {
54        tracing::debug!(role = ?input.role, "handling message");
55        self.inner.handle_message(input, state).await
56    }
57}