Skip to main content

agent_sdk/agent/
context.rs

1use std::path::PathBuf;
2use std::sync::Arc;
3
4use tokio::sync::mpsc::UnboundedSender;
5
6use crate::error::AgentId;
7use crate::traits::llm_client::LlmClient;
8use crate::traits::prompt_builder::PromptBuilder;
9use crate::mailbox::broker::MessageBroker;
10use crate::task::store::TaskStore;
11
12use super::events::AgentEvent;
13use super::hooks::HookRegistry;
14use super::memory::MemoryStore;
15
16/// Per-agent working state. Each teammate gets its own context.
17#[derive(Clone)]
18pub struct AgentContext {
19    pub agent_id: AgentId,
20    /// Human-readable name for this teammate (e.g. "security-reviewer").
21    pub name: String,
22    /// Optional role instructions for this teammate.
23    pub role_prompt: String,
24    pub task_store: Arc<TaskStore>,
25    pub broker: Arc<MessageBroker>,
26    pub llm_client: Arc<dyn LlmClient>,
27    pub prompt_builder: Arc<dyn PromptBuilder>,
28    pub work_dir: PathBuf,
29    pub source_root: PathBuf,
30    pub poll_interval_ms: u64,
31    pub memory_store: Arc<MemoryStore>,
32    pub max_loop_iterations: usize,
33    pub max_context_tokens: usize,
34    pub max_idle_cycles: u32,
35    pub plan_approval_timeout_secs: u64,
36    pub event_tx: Option<UnboundedSender<AgentEvent>>,
37    /// If true, the teammate must submit a plan and get approval before implementing.
38    pub require_plan_approval: bool,
39    /// Hook registry (shared across the team).
40    pub hooks: Arc<HookRegistry>,
41}