The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
feat(agent): add attachment support to embedded sessions
Steven Enamakel5f9507359b0d
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session.rs b/crates/openhuman-core/src/agent/session_host/runtime_session.rsindex 18ebbb72b9..5262b09f48 100644--- a/crates/openhuman-core/src/agent/session_host/runtime_session.rs+++ b/crates/openhuman-core/src/agent/session_host/runtime_session.rs@@ -190,7 +190,6 @@ impl OpenHumanTurnPrelude {Arc<Vec<Box<dyn tinytools::Tool>>>,tinytools::ToolPolicySession,String,- String,) {let surface = self.tool_surface@@ -200,7 +199,6 @@ impl OpenHumanTurnPrelude {surface.tools.clone(),surface.synthesized_tools.clone(),surface.tool_policy_session.clone(),- surface.event_session_id.clone(),surface.event_channel.clone(),)}@@ -938,7 +936,6 @@ impl OpenHumanSessionHost {mut current_tools,mut current_synthesized_tools,policy_session,- policy_session_id,policy_channel,) = prelude.current_tool_source();if turn.overrides.suppress_tools {diff --git a/crates/openhuman-embed/src/agent/attachments.rs b/crates/openhuman-embed/src/agent/attachments.rsindex 0d38798250..f06ac80567 100644--- a/crates/openhuman-embed/src/agent/attachments.rs+++ b/crates/openhuman-embed/src/agent/attachments.rs@@ -1,6 +1,9 @@//! Permanent tool sources attached to an already configured agent.use super::Agent;-use openhuman_core::agent::tool_policy::{ToolPolicy, ToolPolicyDecision, ToolPolicyRequest};+use openhuman_core::agent::tinyagents::host::OpenHumanRunContext;+use tinyagents_harness::context::RunContext;+use tinyagents_harness::middleware::{PolicyDecision, ToolCallPolicy};+use tinyinference_llm::tool::ToolCall;use openhuman_core::agent::{HostTools, TurnContext};use std::collections::{BTreeMap, HashSet};use std::sync::{Arc, Mutex};@@ -150,28 +153,28 @@ impl super::AgentInner {}))}}-type SourcePolicy = (HashSet<String>, Option<Arc<dyn ToolPolicy>>);+type SourcePolicy = (HashSet<String>, Option<Arc<dyn ToolCallPolicy<OpenHumanRunContext>>>);struct AttachmentPolicy {- original: Option<Arc<dyn ToolPolicy>>,+ original: Option<Arc<dyn ToolCallPolicy<OpenHumanRunContext>>>,policies: Vec<SourcePolicy>,}#[async_trait::async_trait]-impl ToolPolicy for AttachmentPolicy {+impl ToolCallPolicy<OpenHumanRunContext> for AttachmentPolicy {fn name(&self) -> &str {"permanent_attachments"}- async fn check(&self, request: &ToolPolicyRequest) -> ToolPolicyDecision {+ async fn check(&self, ctx: &RunContext<OpenHumanRunContext>, call: &ToolCall) -> PolicyDecision {for (names, policy) in &self.policies {- if names.contains(&request.tool_name) {+ if names.contains(&call.name) {return match policy {- Some(policy) => policy.check(request).await,- None => ToolPolicyDecision::Allow,+ Some(policy) => policy.check(ctx, call).await,+ None => PolicyDecision::Allow,};}}match &self.original {- Some(policy) => policy.check(request).await,- None => ToolPolicyDecision::Allow,+ Some(policy) => policy.check(ctx, call).await,+ None => PolicyDecision::Allow,}}}diff --git a/crates/openhuman-embed/src/agent/attachments_tests.rs b/crates/openhuman-embed/src/agent/attachments_tests.rsindex d66b8639d7..8623a37e19 100644--- a/crates/openhuman-embed/src/agent/attachments_tests.rs+++ b/crates/openhuman-embed/src/agent/attachments_tests.rs@@ -1,22 +1,23 @@use super::*;-use openhuman_core::agent::tool_policy::{ToolCallContext, ToolPolicyDecision};struct Deny;#[async_trait::async_trait]-impl ToolPolicy for Deny {+impl ToolCallPolicy<OpenHumanRunContext> for Deny {fn name(&self) -> &str {"deny"}- async fn check(&self, _: &ToolPolicyRequest) -> ToolPolicyDecision {- ToolPolicyDecision::Deny {+ async fn check(&self, _: &RunContext<OpenHumanRunContext>, _: &ToolCall) -> PolicyDecision {+ PolicyDecision::Deny {reason: "host denied".into(),}}}-fn request(name: &str) -> ToolPolicyRequest {- ToolPolicyRequest::new(- name,- serde_json::json!({}),- ToolCallContext::session("s", "c", "a", "call", 0),+fn request(name: &str) -> (RunContext<OpenHumanRunContext>, ToolCall) {+ (+ RunContext::new(+ tinyagents_harness::context::RunConfig::new("attachments-test"),+ OpenHumanRunContext::new(),+ ),+ ToolCall::new("call", name, serde_json::json!({})),)}#[tokio::test]@@ -32,15 +33,15 @@ async fn attachment_policy_does_not_replace_original_host_authority() {],};assert!(matches!(- policy.check(&request("hivemind_message")).await,- ToolPolicyDecision::Allow+ { let (ctx, call) = request("hivemind_message"); policy.check(&ctx, &call).await },+ PolicyDecision::Allow));assert!(matches!(- policy.check(&request("host_original")).await,- ToolPolicyDecision::Deny { .. }+ { let (ctx, call) = request("host_original"); policy.check(&ctx, &call).await },+ PolicyDecision::Deny { .. }));assert!(matches!(- policy.check(&request("hivemind_create")).await,- ToolPolicyDecision::Deny { .. }+ { let (ctx, call) = request("hivemind_create"); policy.check(&ctx, &call).await },+ PolicyDecision::Deny { .. }));}