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// Re-export HITL types
31pub use middleware::HitlPolicy;
32
33/// Default runtime wrapper that delegates to an inner agent implementation.
34pub struct RuntimeAgent<T>
35where
36    T: AgentHandle,
37{
38    inner: Arc<T>,
39}
40
41impl<T> RuntimeAgent<T>
42where
43    T: AgentHandle,
44{
45    pub fn new(inner: Arc<T>) -> Self {
46        Self { inner }
47    }
48}
49
50#[async_trait]
51impl<T> AgentHandle for RuntimeAgent<T>
52where
53    T: AgentHandle + Sync + Send,
54{
55    async fn describe(&self) -> AgentDescriptor {
56        self.inner.describe().await
57    }
58
59    async fn handle_message(
60        &self,
61        input: AgentMessage,
62        state: Arc<AgentStateSnapshot>,
63    ) -> anyhow::Result<AgentMessage> {
64        tracing::debug!(role = ?input.role, "handling message");
65        self.inner.handle_message(input, state).await
66    }
67}