Channels are the arteries of the Agent Air system. Configuring their capacity correctly is crucial for backpressure handling.
Default Capacities
By default, Agent Air uses conservative buffer sizes to prevent memory ballooning if a consumer falls behind.
- Event Channel (Controller -> UI): 32 messages.
- Action Channel (UI -> Controller): 32 messages.
- Stream Channel (Provider -> Controller): 100 chunks.
Tuning for High Load
If you are building an agent that processes massive amounts of text or runs many tools in parallel, you might see ChannelClosed or lag.
You can override these defaults in AgentConfig:
let config = AgentConfig {
channel_capacity: 1024,
..Default::default()
};
Backpressure
We use mpsc (bounded) channels intentionally. If a channel fills up, the sender (e.g., the LLM stream parser) will await until space is available. This naturally slows down the producer to match the consumer’s speed, preventing Out-Of-Memory (OOM) crashes.
