pub type AgentSpawner = Arc<dyn Fn(LoopbackChannel, Option<AcpContext>, SessionContext) -> Pin<Box<dyn Future<Output = ()> + 'static>> + Send + Sync + 'static>;Expand description
Factory that receives a LoopbackChannel, optional AcpContext, and SessionContext,
then drives the agent loop to completion.
Each invocation creates an independent agent with its own conversation history,
enabling true multi-session isolation. The future is 'static but not Send
(Agent<LoopbackChannel> holds non-Send references across .await); scheduled
via tokio::task::spawn_local inside a LocalSet. The ACP transport runtime
(serve_stdio/serve_connection) already wraps the dispatcher in a LocalSet,
so handler code may call spawn_local directly without additional setup.
§Examples
use std::sync::Arc;
use zeph_acp::{AgentSpawner, AcpContext, SessionContext};
use zeph_core::channel::LoopbackChannel;
let spawner: AgentSpawner = Arc::new(|channel, ctx, session| {
Box::pin(async move {
// drive your agent loop here
drop((channel, ctx, session));
})
});Aliased Type§
pub struct AgentSpawner { /* private fields */ }