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