pub struct AgentContext {
pub iteration: usize,
pub state: AgentState,
pub cwd: PathBuf,
pub custom: HashMap<String, Value>,
pub tool_configs: HashMap<String, Value>,
pub writable_roots: Vec<PathBuf>,
}Expand description
Shared context passed to tools during execution.
Fields§
§iteration: usizeCurrent iteration (step number).
state: AgentStateAgent state.
cwd: PathBufWorking directory.
custom: HashMap<String, Value>Domain-specific data (extensible).
tool_configs: HashMap<String, Value>Per-tool configuration overrides. Key: tool name, Value: tool-specific config merged at execution time.
writable_roots: Vec<PathBuf>Directories the agent is allowed to write to (sandbox). Empty = no restriction.
Implementations§
Source§impl AgentContext
impl AgentContext
pub fn new() -> Self
pub fn with_cwd(self, cwd: impl Into<PathBuf>) -> Self
pub fn with_writable_roots(self, roots: Vec<PathBuf>) -> Self
Sourcepub fn is_writable(&self, path: &Path) -> bool
pub fn is_writable(&self, path: &Path) -> bool
Check if a path is writable under sandbox rules. Returns true if writable_roots is empty (no sandbox) or path is under any root. Canonicalizes paths to prevent traversal attacks (../ and symlinks).
Sourcepub fn set_tool_config(&mut self, tool_name: impl Into<String>, config: Value)
pub fn set_tool_config(&mut self, tool_name: impl Into<String>, config: Value)
Set per-tool config.
Sourcepub fn tool_config(&self, tool_name: &str) -> Option<&Value>
pub fn tool_config(&self, tool_name: &str) -> Option<&Value>
Get per-tool config.
Sourcepub fn merged_tool_config(&self, tool_name: &str, base: &Value) -> Value
pub fn merged_tool_config(&self, tool_name: &str, base: &Value) -> Value
Get tool config merged with a base config. Per-tool values override base values (shallow merge).
Trait Implementations§
Source§impl Clone for AgentContext
impl Clone for AgentContext
Source§fn clone(&self) -> AgentContext
fn clone(&self) -> AgentContext
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for AgentContext
impl Debug for AgentContext
Auto Trait Implementations§
impl Freeze for AgentContext
impl RefUnwindSafe for AgentContext
impl Send for AgentContext
impl Sync for AgentContext
impl Unpin for AgentContext
impl UnsafeUnpin for AgentContext
impl UnwindSafe for AgentContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more