AGENT_EVENT_CHANNEL_CAPACITY

Constant AGENT_EVENT_CHANNEL_CAPACITY 

Source
pub const AGENT_EVENT_CHANNEL_CAPACITY: usize = 4_096;
Expand description

[tokio::sync::mpsc] channel capacity for streaming AgentEvents produced by a single crate::ports::AgentLoopPort::run call.

Set to a generous static ceiling (4 096) rather than a formula tied to default config values. The formula-based value (~532 for default config) is too small for callers that use non-default settings such as max_iterations = 50 + max_parallel_tools = 20, which would produce up to ~2 061 structural events per run before any TextDelta headroom. Filling the channel causes tx.send().await to back-pressure on every token in the hot streaming path, with measurable latency impact.

4 096 fits comfortably in a few hundred kilobytes of memory per active agent session and is sufficient for any realistic configuration.

All callers (SSE handlers, CLI REPL) should use this constant instead of a magic literal.