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, SubAgentConfig, SummarizationConfig,
21};
22
23// Re-export provider configurations and models
24pub use providers::{
25    AnthropicConfig, AnthropicMessagesModel, GeminiChatModel, GeminiConfig, OpenAiChatModel,
26    OpenAiConfig,
27};
28
29/// Default runtime wrapper that delegates to an inner agent implementation.
30pub struct RuntimeAgent<T>
31where
32    T: AgentHandle,
33{
34    inner: Arc<T>,
35}
36
37impl<T> RuntimeAgent<T>
38where
39    T: AgentHandle,
40{
41    pub fn new(inner: Arc<T>) -> Self {
42        Self { inner }
43    }
44}
45
46#[async_trait]
47impl<T> AgentHandle for RuntimeAgent<T>
48where
49    T: AgentHandle + Sync + Send,
50{
51    async fn describe(&self) -> AgentDescriptor {
52        self.inner.describe().await
53    }
54
55    async fn handle_message(
56        &self,
57        input: AgentMessage,
58        state: Arc<AgentStateSnapshot>,
59    ) -> anyhow::Result<AgentMessage> {
60        tracing::debug!(role = ?input.role, "handling message");
61        self.inner.handle_message(input, state).await
62    }
63}