Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

refactor(tools): use abstract tool run contexts

Steven Enamakel1bbcef143749
diff --git a/src/openhuman/agent/orchestration/tools/agent_prepare_context.rs b/src/openhuman/agent/orchestration/tools/agent_prepare_context.rs
index 0c9832d65c..9899764304 100644
--- a/src/openhuman/agent/orchestration/tools/agent_prepare_context.rs
+++ b/src/openhuman/agent/orchestration/tools/agent_prepare_context.rs
@@ -724,7 +724,7 @@ impl Tool for AgentPrepareContextTool {
&self,
args: serde_json::Value,
_options: ToolCallOptions,
- tool_context: Option<&ToolExecutionContext>,
+ tool_context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
let prepared_sources = current_agent_context_prepared_sources();
if !prepared_sources.is_empty() {
@@ -745,7 +745,7 @@ impl Tool for AgentPrepareContextTool {
question,
focus,
&tool_catalog,
- tool_context.and_then(|ctx| ctx.workspace.clone()),
+ tool_context.and_then(|ctx| ctx.workspace().cloned()),
)
.await
}
diff --git a/src/openhuman/agent/orchestration/tools/archetype_delegation.rs b/src/openhuman/agent/orchestration/tools/archetype_delegation.rs
index ca88e03795..fff3e58fd7 100644
--- a/src/openhuman/agent/orchestration/tools/archetype_delegation.rs
+++ b/src/openhuman/agent/orchestration/tools/archetype_delegation.rs
@@ -121,7 +121,7 @@ impl Tool for ArchetypeDelegationTool {
&self,
args: serde_json::Value,
_options: ToolCallOptions,
- tool_context: Option<&ToolExecutionContext>,
+ tool_context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
let raw_prompt = args
.get("prompt")
diff --git a/src/openhuman/agent/orchestration/tools/continue_subagent.rs b/src/openhuman/agent/orchestration/tools/continue_subagent.rs
index 58036717dd..8d7da0227b 100644
--- a/src/openhuman/agent/orchestration/tools/continue_subagent.rs
+++ b/src/openhuman/agent/orchestration/tools/continue_subagent.rs
@@ -49,7 +49,7 @@ impl ContinueSubagentTool {
task_id: &str,
agent_id: &str,
message: &str,
- tool_context: Option<&ToolExecutionContext>,
+ tool_context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
use crate::openhuman::agent::orchestration::subagent_sessions::{
self, SubagentSessionStore,
@@ -167,7 +167,7 @@ impl Tool for ContinueSubagentTool {
&self,
args: serde_json::Value,
_options: ToolCallOptions,
- tool_context: Option<&ToolExecutionContext>,
+ tool_context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
let task_id = args
.get("task_id")
@@ -321,7 +321,7 @@ impl Tool for ContinueSubagentTool {
}
// Build options with initial_history for replay
- let workspace_descriptor = tool_context.and_then(|ctx| ctx.workspace.clone());
+ let workspace_descriptor = tool_context.and_then(|ctx| ctx.workspace().cloned());
let worktree_action_dir = workspace_descriptor
.as_ref()
.map(|descriptor| descriptor.root.clone());
diff --git a/src/openhuman/agent/orchestration/tools/delegate_graph.rs b/src/openhuman/agent/orchestration/tools/delegate_graph.rs
index 863296a9de..3fd13dd251 100644
--- a/src/openhuman/agent/orchestration/tools/delegate_graph.rs
+++ b/src/openhuman/agent/orchestration/tools/delegate_graph.rs
@@ -108,7 +108,7 @@ impl Tool for DelegateGraphTool {
&self,
args: serde_json::Value,
_options: ToolCallOptions,
- tool_context: Option<&ToolExecutionContext>,
+ tool_context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
let agent_id = match args.get("agent_id").and_then(|v| v.as_str()) {
Some(s) if !s.trim().is_empty() => s.trim().to_string(),
@@ -155,7 +155,7 @@ impl Tool for DelegateGraphTool {
definition,
task,
max_revisions,
- tool_context.and_then(|ctx| ctx.workspace.clone()),
+ tool_context.and_then(|ctx| ctx.workspace().cloned()),
)
.await
{
diff --git a/src/openhuman/agent/orchestration/tools/dispatch.rs b/src/openhuman/agent/orchestration/tools/dispatch.rs
index 2c047ef9a0..4f0d337786 100644
--- a/src/openhuman/agent/orchestration/tools/dispatch.rs
+++ b/src/openhuman/agent/orchestration/tools/dispatch.rs
@@ -32,10 +32,10 @@ pub(crate) async fn dispatch_subagent(
prompt: &str,
skill_filter: Option<&str>,
model_override: Option<&str>,
- tool_context: Option<&ToolExecutionContext>,
+ tool_context: Option<&dyn ToolRunContext>,
mode: DispatchMode,
) -> anyhow::Result<ToolResult> {
- let parent_workspace_descriptor = tool_context.and_then(|ctx| ctx.workspace.clone());
+ let parent_workspace_descriptor = tool_context.and_then(|ctx| ctx.workspace().cloned());
let registry = match AgentDefinitionRegistry::global() {
Some(reg) => reg,
None => {
diff --git a/src/openhuman/agent/orchestration/tools/skill_delegation.rs b/src/openhuman/agent/orchestration/tools/skill_delegation.rs
index 6c97f00100..089a2f801a 100644
--- a/src/openhuman/agent/orchestration/tools/skill_delegation.rs
+++ b/src/openhuman/agent/orchestration/tools/skill_delegation.rs
@@ -204,7 +204,7 @@ impl Tool for SkillDelegationTool {
&self,
args: serde_json::Value,
_options: ToolCallOptions,
- tool_context: Option<&ToolExecutionContext>,
+ tool_context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
let raw_toolkit = args
.get("toolkit")
diff --git a/src/openhuman/agent/orchestration/tools/spawn_async_subagent.rs b/src/openhuman/agent/orchestration/tools/spawn_async_subagent.rs
index 3ba14aab65..1acbdeb6c1 100644
--- a/src/openhuman/agent/orchestration/tools/spawn_async_subagent.rs
+++ b/src/openhuman/agent/orchestration/tools/spawn_async_subagent.rs
@@ -115,7 +115,7 @@ impl Tool for SpawnAsyncSubagentTool {
&self,
args: serde_json::Value,
_options: ToolCallOptions,
- tool_context: Option<&ToolExecutionContext>,
+ tool_context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
let agent_id = args
.get("agent_id")
@@ -250,7 +250,7 @@ impl Tool for SpawnAsyncSubagentTool {
));
}
let store = SubagentSessionStore::new(parent.workspace_dir.clone());
- let workspace_descriptor = tool_context.and_then(|ctx| ctx.workspace.clone());
+ let workspace_descriptor = tool_context.and_then(|ctx| ctx.workspace().cloned());
let effective_action_root = workspace_descriptor
.as_ref()
.map(|workspace| {
diff --git a/src/openhuman/agent/orchestration/tools/spawn_parallel_agents.rs b/src/openhuman/agent/orchestration/tools/spawn_parallel_agents.rs
index d0b2e2de27..c523ec740a 100644
--- a/src/openhuman/agent/orchestration/tools/spawn_parallel_agents.rs
+++ b/src/openhuman/agent/orchestration/tools/spawn_parallel_agents.rs
@@ -120,10 +120,10 @@ impl Tool for SpawnParallelAgentsTool {
&self,
args: serde_json::Value,
_options: ToolCallOptions,
- tool_context: Option<&ToolExecutionContext>,
+ tool_context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
tracing::debug!("[spawn_parallel_agents] execute entry");
- let workspace_descriptor = tool_context.and_then(|ctx| ctx.workspace.clone());
+ let workspace_descriptor = tool_context.and_then(|ctx| ctx.workspace().cloned());
let cancellation = current_run_cancellation().unwrap_or_else(|| {
tracing::debug!(
"[spawn_parallel_agents] no active tinyagents run cancellation token; using local token"
diff --git a/src/openhuman/agent/orchestration/tools/spawn_subagent.rs b/src/openhuman/agent/orchestration/tools/spawn_subagent.rs
index b03b86bf15..c6f2406a05 100644
--- a/src/openhuman/agent/orchestration/tools/spawn_subagent.rs
+++ b/src/openhuman/agent/orchestration/tools/spawn_subagent.rs
@@ -172,7 +172,7 @@ impl Tool for SpawnSubagentTool {
&self,
args: serde_json::Value,
_options: ToolCallOptions,
- tool_context: Option<&ToolExecutionContext>,
+ tool_context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
// ── Argument extraction with back-compat ───────────────────────
let agent_id = args
@@ -530,7 +530,7 @@ impl Tool for SpawnSubagentTool {
}
// ── Run the sub-agent ──────────────────────────────────────────
- let workspace_descriptor = tool_context.and_then(|ctx| ctx.workspace.clone());
+ let workspace_descriptor = tool_context.and_then(|ctx| ctx.workspace().cloned());
let worktree_action_dir = workspace_descriptor
.as_ref()
.map(|descriptor| descriptor.root.clone());
diff --git a/src/openhuman/agent/orchestration/tools/spawn_worker_thread.rs b/src/openhuman/agent/orchestration/tools/spawn_worker_thread.rs
index 572b921683..230767dd15 100644
--- a/src/openhuman/agent/orchestration/tools/spawn_worker_thread.rs
+++ b/src/openhuman/agent/orchestration/tools/spawn_worker_thread.rs
@@ -107,7 +107,7 @@ impl Tool for SpawnWorkerThreadTool {
&self,
args: serde_json::Value,
_options: ToolCallOptions,
- tool_context: Option<&ToolExecutionContext>,
+ tool_context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
let started = std::time::Instant::now();
@@ -229,7 +229,7 @@ impl Tool for SpawnWorkerThreadTool {
// sees. Instead, we return the info in the tool result.
// ── Run Subagent ──────────────────────────────────────────────
- let workspace_descriptor = tool_context.and_then(|ctx| ctx.workspace.clone());
+ let workspace_descriptor = tool_context.and_then(|ctx| ctx.workspace().cloned());
let worktree_action_dir = workspace_descriptor
.as_ref()
.map(|descriptor| descriptor.root.clone());
diff --git a/src/openhuman/agent/tinyagents/tools.rs b/src/openhuman/agent/tinyagents/tools.rs
index cb795d701f..e89a293590 100644
--- a/src/openhuman/agent/tinyagents/tools.rs
+++ b/src/openhuman/agent/tinyagents/tools.rs
@@ -191,10 +191,10 @@ const TINYAGENTS_TOOL_SESSION: &str = "tinyagents";
pub(crate) async fn execute_openhuman_tool(
tool: &dyn crate::openhuman::tools::Tool,
call: TaToolCall,
- context: Option<&ToolExecutionContext>,
+ context: Option<&dyn ToolRunContext>,
) -> TaToolResult {
let workspace_root = context
- .and_then(|ctx| ctx.workspace.as_ref())
+ .and_then(|ctx| ctx.workspace())
.map(|workspace| workspace.root.display().to_string());
tracing::debug!(
tool = %call.name,
@@ -393,7 +393,7 @@ impl SharedToolAdapter {
async fn call_openhuman_tool(
&self,
call: TaToolCall,
- context: Option<&ToolExecutionContext>,
+ context: Option<&dyn ToolRunContext>,
) -> tinyagents::Result<TaToolResult> {
let found = self
.sets
diff --git a/src/openhuman/agent/tools/delegate_to_personality.rs b/src/openhuman/agent/tools/delegate_to_personality.rs
index 5735a9230f..074e93a7b5 100644
--- a/src/openhuman/agent/tools/delegate_to_personality.rs
+++ b/src/openhuman/agent/tools/delegate_to_personality.rs
@@ -71,7 +71,7 @@ impl Tool for DelegateToPersonalityTool {
&self,
args: serde_json::Value,
_options: ToolCallOptions,
- tool_context: Option<&ToolExecutionContext>,
+ tool_context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
let personality_id = args
.get("personality_id")
@@ -219,7 +219,7 @@ impl Tool for DelegateToPersonalityTool {
}
};
- let workspace_descriptor = tool_context.and_then(|ctx| ctx.workspace.clone());
+ let workspace_descriptor = tool_context.and_then(|ctx| ctx.workspace().cloned());
let worktree_action_dir = workspace_descriptor
.as_ref()
.map(|descriptor| descriptor.root.clone());
diff --git a/src/openhuman/integrations/file_storage/tools.rs b/src/openhuman/integrations/file_storage/tools.rs
index dd5db49e9e..45af9edf3d 100644
--- a/src/openhuman/integrations/file_storage/tools.rs
+++ b/src/openhuman/integrations/file_storage/tools.rs
@@ -196,10 +196,10 @@ fn mime_for_path(path: &Path) -> &'static str {
/// workspace from the execution context (mirrors `media_generation`).
fn action_dir_for_context(
default_action_dir: &Path,
- context: Option<&ToolExecutionContext>,
+ context: Option<&dyn ToolRunContext>,
tool_name: &str,
) -> PathBuf {
- if let Some(workspace) = context.and_then(|ctx| ctx.workspace.as_ref()) {
+ if let Some(workspace) = context.and_then(|ctx| ctx.workspace()) {
tracing::debug!(
tool = tool_name,
workspace_root = %workspace.root.display(),
@@ -400,7 +400,7 @@ impl Tool for StorageUploadFileTool {
&self,
args: Value,
_options: ToolCallOptions,
- context: Option<&ToolExecutionContext>,
+ context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
let action_dir = action_dir_for_context(&self.action_dir, context, self.name());
self.run(args, &action_dir).await
@@ -548,7 +548,7 @@ impl Tool for StorageDownloadFileTool {
&self,
args: Value,
_options: ToolCallOptions,
- context: Option<&ToolExecutionContext>,
+ context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
let action_dir = action_dir_for_context(&self.action_dir, context, self.name());
self.run(args, &action_dir).await
diff --git a/src/openhuman/media/generation/tools.rs b/src/openhuman/media/generation/tools.rs
index a46b2986ba..f0dd5dcdc0 100644
--- a/src/openhuman/media/generation/tools.rs
+++ b/src/openhuman/media/generation/tools.rs
@@ -172,10 +172,10 @@ async fn generate_and_persist(
fn action_dir_for_context(
default_action_dir: &Path,
- context: Option<&ToolExecutionContext>,
+ context: Option<&dyn ToolRunContext>,
tool_name: &str,
) -> PathBuf {
- if let Some(workspace) = context.and_then(|ctx| ctx.workspace.as_ref()) {
+ if let Some(workspace) = context.and_then(|ctx| ctx.workspace()) {
tracing::debug!(
tool = tool_name,
workspace_root = %workspace.root.display(),
@@ -290,7 +290,7 @@ impl Tool for MediaGenerateImageTool {
&self,
args: Value,
_options: ToolCallOptions,
- context: Option<&ToolExecutionContext>,
+ context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
let action_dir = action_dir_for_context(&self.action_dir, context, self.name());
self.run(args, &action_dir).await
@@ -397,7 +397,7 @@ impl Tool for MediaGenerateVideoTool {
&self,
args: Value,
_options: ToolCallOptions,
- context: Option<&ToolExecutionContext>,
+ context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
let action_dir = action_dir_for_context(&self.action_dir, context, self.name());
self.run(args, &action_dir).await
diff --git a/src/openhuman/memory/agent/tools.rs b/src/openhuman/memory/agent/tools.rs
index 468ebf8b7d..c9040585c1 100644
--- a/src/openhuman/memory/agent/tools.rs
+++ b/src/openhuman/memory/agent/tools.rs
@@ -104,7 +104,7 @@ impl Tool for CallMemoryAgentTool {
&self,
args: serde_json::Value,
_options: ToolCallOptions,
- tool_context: Option<&ToolExecutionContext>,
+ tool_context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
let query = args
.get("query")
@@ -178,7 +178,7 @@ impl Tool for CallMemoryAgentTool {
task_id
);
- let workspace_descriptor = tool_context.and_then(|ctx| ctx.workspace.clone());
+ let workspace_descriptor = tool_context.and_then(|ctx| ctx.workspace().cloned());
let worktree_action_dir = workspace_descriptor
.as_ref()
.map(|descriptor| descriptor.root.clone());
diff --git a/src/openhuman/tools/impl/filesystem/apply_patch.rs b/src/openhuman/tools/impl/filesystem/apply_patch.rs
index c13127b13c..1fbfdc1d2b 100644
--- a/src/openhuman/tools/impl/filesystem/apply_patch.rs
+++ b/src/openhuman/tools/impl/filesystem/apply_patch.rs
@@ -83,7 +83,7 @@ impl Tool for ApplyPatchTool {
&self,
args: serde_json::Value,
_options: ToolCallOptions,
- context: Option<&ToolExecutionContext>,
+ context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
self.execute_in_context(args, context).await
}
@@ -93,7 +93,7 @@ impl ApplyPatchTool {
async fn execute_in_context(
&self,
args: serde_json::Value,
- context: Option<&ToolExecutionContext>,
+ context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
let edits = args
.get("edits")
diff --git a/src/openhuman/tools/impl/filesystem/csv_export.rs b/src/openhuman/tools/impl/filesystem/csv_export.rs
index 0b32c49d74..0deaa8cb71 100644
--- a/src/openhuman/tools/impl/filesystem/csv_export.rs
+++ b/src/openhuman/tools/impl/filesystem/csv_export.rs
@@ -132,7 +132,7 @@ impl Tool for CsvExportTool {
&self,
args: serde_json::Value,
_options: ToolCallOptions,
- context: Option<&ToolExecutionContext>,
+ context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
self.execute_in_context(args, context).await
}
@@ -142,7 +142,7 @@ impl CsvExportTool {
async fn execute_in_context(
&self,
args: serde_json::Value,
- context: Option<&ToolExecutionContext>,
+ context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
let data_str = args
.get("data")
diff --git a/src/openhuman/tools/impl/filesystem/edit_file.rs b/src/openhuman/tools/impl/filesystem/edit_file.rs
index 82c6253e04..7efd5e0eb1 100644
--- a/src/openhuman/tools/impl/filesystem/edit_file.rs
+++ b/src/openhuman/tools/impl/filesystem/edit_file.rs
@@ -73,7 +73,7 @@ impl Tool for EditFileTool {
&self,
args: serde_json::Value,
_options: ToolCallOptions,
- context: Option<&ToolExecutionContext>,
+ context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
self.execute_in_context(args, context).await
}
@@ -83,7 +83,7 @@ impl EditFileTool {
async fn execute_in_context(
&self,
args: serde_json::Value,
- context: Option<&ToolExecutionContext>,
+ context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
let path = args
.get("path")
diff --git a/src/openhuman/tools/impl/filesystem/file_read.rs b/src/openhuman/tools/impl/filesystem/file_read.rs
index 04e3bb7fd6..fe13a6e2c1 100644
--- a/src/openhuman/tools/impl/filesystem/file_read.rs
+++ b/src/openhuman/tools/impl/filesystem/file_read.rs
@@ -58,7 +58,7 @@ impl Tool for FileReadTool {
&self,
args: serde_json::Value,
_options: ToolCallOptions,
- context: Option<&ToolExecutionContext>,
+ context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
self.execute_in_context(args, context).await
}
@@ -68,7 +68,7 @@ impl FileReadTool {
async fn execute_in_context(
&self,
args: serde_json::Value,
- context: Option<&ToolExecutionContext>,
+ context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
let path = args
.get("path")
diff --git a/src/openhuman/tools/impl/filesystem/file_write.rs b/src/openhuman/tools/impl/filesystem/file_write.rs
index 893f463a6f..9cfc0bc385 100644
--- a/src/openhuman/tools/impl/filesystem/file_write.rs
+++ b/src/openhuman/tools/impl/filesystem/file_write.rs
@@ -108,7 +108,7 @@ impl Tool for FileWriteTool {
&self,
args: serde_json::Value,
_options: ToolCallOptions,
- context: Option<&ToolExecutionContext>,
+ context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
self.execute_in_context(args, context).await
}
@@ -118,7 +118,7 @@ impl FileWriteTool {
async fn execute_in_context(
&self,
args: serde_json::Value,
- context: Option<&ToolExecutionContext>,
+ context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
let path = args
.get("path")
diff --git a/src/openhuman/tools/impl/filesystem/git_operations.rs b/src/openhuman/tools/impl/filesystem/git_operations.rs
index e191a0201b..81fa178b74 100644
--- a/src/openhuman/tools/impl/filesystem/git_operations.rs
+++ b/src/openhuman/tools/impl/filesystem/git_operations.rs
@@ -31,8 +31,8 @@ impl GitOperationsTool {
/// `ToolExecutionContext::from_run_context`. Otherwise falls back to the
/// tool's configured `action_dir`, which preserves the non-isolated
/// behaviour exactly. See #3376, #4249 (08.5).
- fn effective_action_dir_for_context(&self, context: Option<&ToolExecutionContext>) -> PathBuf {
- if let Some(workspace) = context.and_then(|ctx| ctx.workspace.as_ref()) {
+ fn effective_action_dir_for_context(&self, context: Option<&dyn ToolRunContext>) -> PathBuf {
+ if let Some(workspace) = context.and_then(|ctx| ctx.workspace()) {
tracing::debug!(
workspace_root = %workspace.root.display(),
policy_id = %workspace.policy_id,
@@ -510,7 +510,7 @@ impl Tool for GitOperationsTool {
&self,
args: serde_json::Value,
_options: ToolCallOptions,
- context: Option<&ToolExecutionContext>,
+ context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
self.execute_in_context(args, context).await
}
@@ -524,7 +524,7 @@ impl GitOperationsTool {
async fn execute_in_context(
&self,
args: serde_json::Value,
- context: Option<&ToolExecutionContext>,
+ context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
let operation = match args.get("operation").and_then(|v| v.as_str()) {
Some(op) => op,
diff --git a/src/openhuman/tools/impl/filesystem/glob_search.rs b/src/openhuman/tools/impl/filesystem/glob_search.rs
index ae47563729..49aa5e95b5 100644
--- a/src/openhuman/tools/impl/filesystem/glob_search.rs
+++ b/src/openhuman/tools/impl/filesystem/glob_search.rs
@@ -94,7 +94,7 @@ impl Tool for GlobTool {
&self,
args: serde_json::Value,
_options: ToolCallOptions,
- context: Option<&ToolExecutionContext>,
+ context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
self.execute_in_context(args, context).await
}
@@ -104,7 +104,7 @@ impl GlobTool {
async fn execute_in_context(
&self,
args: serde_json::Value,
- context: Option<&ToolExecutionContext>,
+ context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
let pattern_str = args
.get("pattern")
diff --git a/src/openhuman/tools/impl/filesystem/grep.rs b/src/openhuman/tools/impl/filesystem/grep.rs
index 0a7c36ab0f..7da50add92 100644
--- a/src/openhuman/tools/impl/filesystem/grep.rs
+++ b/src/openhuman/tools/impl/filesystem/grep.rs
@@ -85,7 +85,7 @@ impl Tool for GrepTool {
&self,
args: serde_json::Value,
_options: ToolCallOptions,
- context: Option<&ToolExecutionContext>,
+ context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
self.execute_in_context(args, context).await
}
@@ -95,7 +95,7 @@ impl GrepTool {
async fn execute_in_context(
&self,
args: serde_json::Value,
- context: Option<&ToolExecutionContext>,
+ context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
let pattern = args
.get("pattern")
diff --git a/src/openhuman/tools/impl/filesystem/list_files.rs b/src/openhuman/tools/impl/filesystem/list_files.rs
index 7b21273828..9caf6eb837 100644
--- a/src/openhuman/tools/impl/filesystem/list_files.rs
+++ b/src/openhuman/tools/impl/filesystem/list_files.rs
@@ -59,7 +59,7 @@ impl Tool for ListFilesTool {
&self,
args: serde_json::Value,
_options: ToolCallOptions,
- context: Option<&ToolExecutionContext>,
+ context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
self.execute_in_context(args, context).await
}
@@ -69,7 +69,7 @@ impl ListFilesTool {
async fn execute_in_context(
&self,
args: serde_json::Value,
- context: Option<&ToolExecutionContext>,
+ context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
let path = args.get("path").and_then(|v| v.as_str()).unwrap_or(".");
diff --git a/src/openhuman/tools/impl/filesystem/mod.rs b/src/openhuman/tools/impl/filesystem/mod.rs
index 305d11f3fe..9c82b94d2f 100644
--- a/src/openhuman/tools/impl/filesystem/mod.rs
+++ b/src/openhuman/tools/impl/filesystem/mod.rs
@@ -56,11 +56,11 @@ pub use update_memory_md::UpdateMemoryMdTool;
/// model-supplied text.
pub(super) fn security_for_tool_context(
security: &SecurityPolicy,
- context: Option<&ToolExecutionContext>,
+ context: Option<&dyn ToolRunContext>,
tool: &str,
) -> SecurityPolicy {
let mut scoped = security.clone();
- if let Some(workspace) = context.and_then(|ctx| ctx.workspace.as_ref()) {
+ if let Some(workspace) = context.and_then(|ctx| ctx.workspace()) {
tracing::debug!(
tool,
workspace_root = %workspace.root.display(),
diff --git a/src/openhuman/tools/impl/filesystem/read_diff.rs b/src/openhuman/tools/impl/filesystem/read_diff.rs
index cd2f653fb7..8e84497e84 100644
--- a/src/openhuman/tools/impl/filesystem/read_diff.rs
+++ b/src/openhuman/tools/impl/filesystem/read_diff.rs
@@ -16,8 +16,8 @@ impl ReadDiffTool {
Self { workspace_dir }
}
- fn workspace_dir_for_context(&self, context: Option<&ToolExecutionContext>) -> PathBuf {
- if let Some(workspace) = context.and_then(|ctx| ctx.workspace.as_ref()) {
+ fn workspace_dir_for_context(&self, context: Option<&dyn ToolRunContext>) -> PathBuf {
+ if let Some(workspace) = context.and_then(|ctx| ctx.workspace()) {
tracing::debug!(
workspace_root = %workspace.root.display(),
policy_id = %workspace.policy_id,
@@ -73,7 +73,7 @@ impl Tool for ReadDiffTool {
&self,
args: serde_json::Value,
_options: ToolCallOptions,
- context: Option<&ToolExecutionContext>,
+ context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
let workspace_dir = self.workspace_dir_for_context(context);
let base = args.get("base").and_then(|v| v.as_str());
diff --git a/src/openhuman/tools/impl/filesystem/run_linter.rs b/src/openhuman/tools/impl/filesystem/run_linter.rs
index 335b0f2d4d..c7a8068bb4 100644
--- a/src/openhuman/tools/impl/filesystem/run_linter.rs
+++ b/src/openhuman/tools/impl/filesystem/run_linter.rs
@@ -16,8 +16,8 @@ impl RunLinterTool {
Self { workspace_dir }
}
- fn workspace_dir_for_context(&self, context: Option<&ToolExecutionContext>) -> PathBuf {
- if let Some(workspace) = context.and_then(|ctx| ctx.workspace.as_ref()) {
+ fn workspace_dir_for_context(&self, context: Option<&dyn ToolRunContext>) -> PathBuf {
+ if let Some(workspace) = context.and_then(|ctx| ctx.workspace()) {
tracing::debug!(
workspace_root = %workspace.root.display(),
policy_id = %workspace.policy_id,
@@ -71,7 +71,7 @@ impl Tool for RunLinterTool {
&self,
args: serde_json::Value,
_options: ToolCallOptions,
- context: Option<&ToolExecutionContext>,
+ context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
let workspace_dir = self.workspace_dir_for_context(context);
let linter = args
diff --git a/src/openhuman/tools/impl/filesystem/run_tests.rs b/src/openhuman/tools/impl/filesystem/run_tests.rs
index 8dea8c2f20..43111971a3 100644
--- a/src/openhuman/tools/impl/filesystem/run_tests.rs
+++ b/src/openhuman/tools/impl/filesystem/run_tests.rs
@@ -16,8 +16,8 @@ impl RunTestsTool {
Self { workspace_dir }
}
- fn workspace_dir_for_context(&self, context: Option<&ToolExecutionContext>) -> PathBuf {
- if let Some(workspace) = context.and_then(|ctx| ctx.workspace.as_ref()) {
+ fn workspace_dir_for_context(&self, context: Option<&dyn ToolRunContext>) -> PathBuf {
+ if let Some(workspace) = context.and_then(|ctx| ctx.workspace()) {
tracing::debug!(
workspace_root = %workspace.root.display(),
policy_id = %workspace.policy_id,
@@ -76,7 +76,7 @@ impl Tool for RunTestsTool {
&self,
args: serde_json::Value,
_options: ToolCallOptions,
- context: Option<&ToolExecutionContext>,
+ context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
let workspace_dir = self.workspace_dir_for_context(context);
let runner = args
diff --git a/src/openhuman/tools/impl/filesystem/update_memory_md.rs b/src/openhuman/tools/impl/filesystem/update_memory_md.rs
index c26685342c..3716bf2f2d 100644
--- a/src/openhuman/tools/impl/filesystem/update_memory_md.rs
+++ b/src/openhuman/tools/impl/filesystem/update_memory_md.rs
@@ -150,8 +150,8 @@ impl UpdateMemoryMdTool {
Self { workspace_dir }
}
- fn workspace_dir_for_context(&self, context: Option<&ToolExecutionContext>) -> PathBuf {
- if let Some(workspace) = context.and_then(|ctx| ctx.workspace.as_ref()) {
+ fn workspace_dir_for_context(&self, context: Option<&dyn ToolRunContext>) -> PathBuf {
+ if let Some(workspace) = context.and_then(|ctx| ctx.workspace()) {
tracing::debug!(
workspace_root = %workspace.root.display(),
policy_id = %workspace.policy_id,
@@ -216,7 +216,7 @@ impl Tool for UpdateMemoryMdTool {
&self,
args: serde_json::Value,
_options: ToolCallOptions,
- context: Option<&ToolExecutionContext>,
+ context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
let workspace_dir = self.workspace_dir_for_context(context);
let file = args
diff --git a/src/openhuman/tools/impl/system/mod.rs b/src/openhuman/tools/impl/system/mod.rs
index 898846a541..f4198ec9d5 100644
--- a/src/openhuman/tools/impl/system/mod.rs
+++ b/src/openhuman/tools/impl/system/mod.rs
@@ -67,11 +67,11 @@ pub use workspace_state::WorkspaceStateTool;
/// model-supplied text.
pub(super) fn security_for_tool_context(
security: &SecurityPolicy,
- context: Option<&ToolExecutionContext>,
+ context: Option<&dyn ToolRunContext>,
tool: &str,
) -> SecurityPolicy {
let mut scoped = security.clone();
- if let Some(workspace) = context.and_then(|ctx| ctx.workspace.as_ref()) {
+ if let Some(workspace) = context.and_then(|ctx| ctx.workspace()) {
tracing::debug!(
tool,
workspace_root = %workspace.root.display(),
diff --git a/src/openhuman/tools/impl/system/node_exec.rs b/src/openhuman/tools/impl/system/node_exec.rs
index d4d85a3136..ae379e8eca 100644
--- a/src/openhuman/tools/impl/system/node_exec.rs
+++ b/src/openhuman/tools/impl/system/node_exec.rs
@@ -159,7 +159,7 @@ impl Tool for NodeExecTool {
&self,
args: serde_json::Value,
_options: ToolCallOptions,
- context: Option<&ToolExecutionContext>,
+ context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
self.execute_in_context(args, context).await
}
@@ -169,7 +169,7 @@ impl NodeExecTool {
async fn execute_in_context(
&self,
args: serde_json::Value,
- context: Option<&ToolExecutionContext>,
+ context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
let inline_code = args
.get("inline_code")
diff --git a/src/openhuman/tools/impl/system/npm_exec.rs b/src/openhuman/tools/impl/system/npm_exec.rs
index 2445a43fc8..486dcc030a 100644
--- a/src/openhuman/tools/impl/system/npm_exec.rs
+++ b/src/openhuman/tools/impl/system/npm_exec.rs
@@ -166,7 +166,7 @@ impl Tool for NpmExecTool {
&self,
args: serde_json::Value,
_options: ToolCallOptions,
- context: Option<&ToolExecutionContext>,
+ context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
self.execute_in_context(args, context).await
}
@@ -176,7 +176,7 @@ impl NpmExecTool {
async fn execute_in_context(
&self,
args: serde_json::Value,
- context: Option<&ToolExecutionContext>,
+ context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
let subcommand = match args.get("subcommand").and_then(|v| v.as_str()) {
Some(s) => s.trim().to_string(),
diff --git a/src/openhuman/tools/impl/system/python_exec.rs b/src/openhuman/tools/impl/system/python_exec.rs
index f5203548a6..f5f9e4f3c7 100644
--- a/src/openhuman/tools/impl/system/python_exec.rs
+++ b/src/openhuman/tools/impl/system/python_exec.rs
@@ -147,7 +147,7 @@ impl Tool for PythonExecTool {
&self,
args: serde_json::Value,
_options: ToolCallOptions,
- context: Option<&ToolExecutionContext>,
+ context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
self.execute_in_context(args, context).await
}
@@ -157,7 +157,7 @@ impl PythonExecTool {
async fn execute_in_context(
&self,
args: serde_json::Value,
- context: Option<&ToolExecutionContext>,
+ context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
let inline_code = args
.get("inline_code")
diff --git a/src/openhuman/tools/impl/system/shell.rs b/src/openhuman/tools/impl/system/shell.rs
index 92eef0fddd..de66307476 100644
--- a/src/openhuman/tools/impl/system/shell.rs
+++ b/src/openhuman/tools/impl/system/shell.rs
@@ -153,8 +153,8 @@ impl ShellTool {
/// `ToolExecutionContext::from_run_context`. Otherwise falls back to the
/// shared `self.security.action_dir`, which preserves the non-isolated
/// behaviour exactly. See #3376, #4249 (08.5).
- fn effective_action_dir_for_context(&self, context: Option<&ToolExecutionContext>) -> PathBuf {
- if let Some(workspace) = context.and_then(|ctx| ctx.workspace.as_ref()) {
+ fn effective_action_dir_for_context(&self, context: Option<&dyn ToolRunContext>) -> PathBuf {
+ if let Some(workspace) = context.and_then(|ctx| ctx.workspace()) {
tracing::debug!(
workspace_root = %workspace.root.display(),
policy_id = %workspace.policy_id,
@@ -269,7 +269,7 @@ impl Tool for ShellTool {
&self,
args: serde_json::Value,
_options: ToolCallOptions,
- context: Option<&ToolExecutionContext>,
+ context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
self.execute_in_context(args, context).await
}
@@ -279,7 +279,7 @@ impl ShellTool {
async fn execute_in_context(
&self,
args: serde_json::Value,
- context: Option<&ToolExecutionContext>,
+ context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
let command = args
.get("command")
@@ -333,7 +333,7 @@ impl ShellTool {
&self,
command: &str,
requested_timeout: Option<u64>,
- context: Option<&ToolExecutionContext>,
+ context: Option<&dyn ToolRunContext>,
) -> (bool, ToolResult) {
// Read-only `Block` + the Option-2 structural guard. Approval for
// Write / Network / Destructive already happened at the harness
diff --git a/src/openhuman/tools/toolpacks/tools.rs b/src/openhuman/tools/toolpacks/tools.rs
index 028c217ee4..6e9757f0d4 100644
--- a/src/openhuman/tools/toolpacks/tools.rs
+++ b/src/openhuman/tools/toolpacks/tools.rs
@@ -252,7 +252,7 @@ impl Tool for UseSkillTool {
&self,
args: Value,
options: ToolCallOptions,
- context: Option<&tinyagents::harness::tool::ToolExecutionContext>,
+ context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
let Some((tools, idx)) = self.resolve(&args) else {
let skill = args.get("skill").and_then(Value::as_str).unwrap_or("");
diff --git a/vendor/tinyagents b/vendor/tinyagents
index 744020a636..aa4678b83f 160000
--- a/vendor/tinyagents
+++ b/vendor/tinyagents
@@ -1 +1 @@
-Subproject commit 744020a6366a70db50b2a240d12f7abb80004c2e
+Subproject commit aa4678b83f5ca00f4621a5abb772e4facc3ffb59