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(caps_host): add run-scoped agent event stream
Steven Enamakel5550dd33ead5
diff --git a/crates/openhuman-core/src/flows/caps_host/agent.rs b/crates/openhuman-core/src/flows/caps_host/agent.rsindex fa24445cd6..30f4da85f2 100644--- a/crates/openhuman-core/src/flows/caps_host/agent.rs+++ b/crates/openhuman-core/src/flows/caps_host/agent.rs@@ -73,6 +73,17 @@ pub struct OpenHumanAgentRunner {/// The run's approval context (flow run correlation), handed to the gate/// with every acting dispatch.pub approval: crate::security::approval::ApprovalTurnContext,+ /// Run-scoped event stream consumed by `CapsHost.AgentEvents`.+ pub progress: Option<tokio::sync::mpsc::Sender<crate::agent::progress::AgentProgress>>,+}++/// Bounded callback state for one in-flight host agent turn.+#[derive(Default)]+pub(crate) struct AgentRunState {+ pub(crate) events: Vec<tinyflows_bus::runs::AgentProgressEvent>,+ pub(crate) outcome: Option<tinyflows_bus::runs::AgentRunOutcome>,+ pub(crate) error: Option<String>,+ pub(crate) done: bool,}/// Process-wide ceiling on **simultaneous harness agent turns started by flow@@ -375,6 +386,7 @@ impl OpenHumanAgentRunner {))})?;agent.set_agent_definition_name(agent_ref.to_string());+ agent.set_on_progress(self.progress.clone());// Issue #4868 — the session builder now stamps `agent_ref`'s own// `effective_max_iterations()` onto the agent (instead of the globaldiff --git a/crates/openhuman-core/src/flows/caps_host/binding.rs b/crates/openhuman-core/src/flows/caps_host/binding.rsindex addbc9256d..a84c1c3ac6 100644--- a/crates/openhuman-core/src/flows/caps_host/binding.rs+++ b/crates/openhuman-core/src/flows/caps_host/binding.rs@@ -1,6 +1,6 @@//! One trusted `CapsHost` callback object for a single TinyFlows run.-use std::sync::Arc;+use std::{collections::HashMap, sync::Arc};use crate::config::Config;use crate::core::runtime::DispatchCtx;@@ -8,16 +8,29 @@ use crate::flows::catalog_storage::CatalogStorageRegistration;use crate::modules::tinyflows as module;use tinyflows_bus::runs::{CallbackAddress, CapsHost};-use super::service::CapsHostService;+use super::{agent::AgentRunState, service::CapsHostService};/// Owns the host callback and its dependent owner-scoped catalog callback./// Keep this handle alive until the module has settled or parked the run.pub(crate) struct CapsHostRegistration {_registration: module::ServedObjectRegistration,_catalog: Arc<CatalogStorageRegistration>,+ _binding: Arc<CapsHostBinding>,address: CapsHost,}+/// Request-scoped values shared by all capability callbacks for one run.+pub(crate) struct CapsHostBinding {+ pub(crate) ctx: DispatchCtx,+ pub(crate) config: Arc<Config>,+ pub(crate) flow_id: String,+ pub(crate) run_id: String,+ pub(crate) security: Arc<crate::security::SecurityPolicy>,+ pub(crate) approval: crate::security::approval::ApprovalTurnContext,+ pub(crate) agent_runs:+ tokio::sync::Mutex<HashMap<String, Arc<tokio::sync::Mutex<AgentRunState>>>>,+}+impl CapsHostRegistration {/// Address to pass unchanged to `Runs.StartRun` or `Runs.ResumeRun`.pub(crate) fn address(&self) -> CapsHost {@@ -41,6 +54,27 @@ pub(crate) async fn serve(},};let ctx = ctx.with_turn_origin(origin);+ let security = Arc::new(crate::security::SecurityPolicy::from_config(+ &config.autonomy,+ &config.workspace_dir,+ &config.action_dir,+ ));+ let approval = crate::security::approval::ApprovalTurnContext {+ flow_run: Some(crate::security::approval::FlowRunContext {+ flow_id: flow_id.clone(),+ run_id: run_id.clone(),+ }),+ ..Default::default()+ };+ let binding = Arc::new(CapsHostBinding {+ ctx,+ config,+ flow_id,+ run_id,+ security,+ approval,+ agent_runs: tokio::sync::Mutex::new(HashMap::new()),+ });let path = format!("/ai/tinyhumans/openhuman/CapsHost/{}",uuid::Uuid::new_v4().simple()@@ -51,11 +85,12 @@ pub(crate) async fn serve(object_path: path.clone(),},};- let service = CapsHostService::new(ctx, config, flow_id, run_id);+ let service = CapsHostService::new(Arc::clone(&binding));let registration = module::serve_registered(path, service).await?;Ok(CapsHostRegistration {_registration: registration,_catalog: catalog,+ _binding: binding,address,})}