1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//! Agent kernel crate — minimal orchestration primitives for multi-agent discussion.
//!
//! # Design Principles (pi-mono)
//! - Extreme minimalism: `discuss()` is the ONLY orchestration primitive
//! - Full trust: caller controls `rounds`, no internal policy
//! - Observability first: `AgentEvent` is a first-class output via `mpsc::Sender`
//! - Late binding: `Message` stays internal until provider converts at the boundary
//!
//! # Phase 2 additions (independent repo)
//! - `evolution` module: `EvolutionContext` + `EvolutionRuntime` trait
//! - `AgentEvent::Evolved` variant in `event` module
//!
//! # Quick Start
//!
//! ```rust,no_run
//! use agent_kernel::{Agent, AgentRuntime, BoxFuture, discuss};
//! use tokio::sync::mpsc;
//! use tokio_util::sync::CancellationToken;
//!
//! struct MyRuntime;
//!
//! impl AgentRuntime for MyRuntime {
//! fn respond<'a>(
//! &'a self,
//! agent: &'a Agent,
//! _history: &'a [agent_kernel::Message],
//! ) -> BoxFuture<'a, anyhow::Result<String>> {
//! Box::pin(async move {
//! Ok(format!("[{}] My response", agent.name))
//! })
//! }
//! }
//!
//! #[tokio::main]
//! async fn main() -> anyhow::Result<()> {
//! let runtime = MyRuntime;
//! let agents = vec![
//! Agent { name: "alice".into(), soul_md: "You are Alice.".into(), model: "gpt-4o".into() },
//! Agent { name: "bob".into(), soul_md: "You are Bob.".into(), model: "gpt-4o".into() },
//! ];
//! let (tx, mut rx) = mpsc::channel(64);
//! let cancel = CancellationToken::new();
//! let summary = discuss(&runtime, &agents, "What is Rust?", 2, cancel, tx).await?;
//! while let Ok(event) = rx.try_recv() {
//! println!("{event:?}");
//! }
//! println!("Summary: {summary}");
//! Ok(())
//! }
//! ```
/// Boxed future used as [`AgentRuntime::respond`] return type.
///
/// Using an explicit `BoxFuture` instead of `async_trait` keeps the kernel
/// dependency-free (no `async_trait` macro crate required).
pub type BoxFuture<'a, T> = Pin;
// ── Re-exports ────────────────────────────────────────────────────────────────
pub use Agent;
pub use AgentEvent;
pub use ;
pub use ;
pub use AgentRuntime;
pub use discuss;