pub struct AppState {
pub tools: Vec<ToolInfo>,
pub tool_registry: ToolRegistry,
pub config: Config,
pub provider: Arc<dyn ChatProvider>,
pub sessions: Arc<RwLock<HashMap<String, SessionState>>>,
pub event_channels: Arc<RwLock<HashMap<String, Sender<SseEvent>>>>,
pub metrics: Arc<Metrics>,
pub slash_commands: Arc<Vec<SlashCommandInfo>>,
pub session_ttl_secs: u64,
pub run_semaphore: Arc<Semaphore>,
pub rate_limiter: RateLimiter,
pub skills: Vec<Skill>,
}Expand description
Shared application state for the HTTP server.
Fields§
§tools: Vec<ToolInfo>§tool_registry: ToolRegistryLive tool registry used to construct per-request and per-session AgentRuntimes. Without this, runtimes get an empty registry and every tool_call from the LLM resolves to “tool not found”.
config: Config§provider: Arc<dyn ChatProvider>§sessions: Arc<RwLock<HashMap<String, SessionState>>>Session state keyed by session ID.
event_channels: Arc<RwLock<HashMap<String, Sender<SseEvent>>>>Per-session SSE broadcast channels.
metrics: Arc<Metrics>§slash_commands: Arc<Vec<SlashCommandInfo>>Goal-169: registered slash commands (built-in + skill-backed).
Pre-built at startup for cheap GET /slash-commands responses.
session_ttl_secs: u64§run_semaphore: Arc<Semaphore>Semaphore limiting concurrent agent runs. Acquired in run_agent and
send_session_message before creating an AgentRuntime. When the
configured max_concurrent_runs is 0 (unlimited), this is initialised
with Semaphore::MAX_PERMITS.
rate_limiter: RateLimiterShared rate limiter for all API requests. Stored on AppState so the
session reaper can prune idle token buckets.
skills: Vec<Skill>Discovered skills for skill_index injection into the system prompt. Empty if no skills found. Goal-312.