Skip to content

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

feat(tinyflows): add agent, code, http, and ops capability modules

Steven Enamakeldc326b4fe1c7
diff --git a/crates/openhuman-core/src/flows/tinyflows/caps/agent.rs b/crates/openhuman-core/src/flows/tinyflows/caps/agent.rs
index b38ca55cec..327725609c 100644
--- a/crates/openhuman-core/src/flows/tinyflows/caps/agent.rs
+++ b/crates/openhuman-core/src/flows/tinyflows/caps/agent.rs
@@ -68,6 +68,8 @@ use crate::inference::provider::{is_raw_passthrough_model, role_for_model_tier};
/// caller's task), so HITL gating still applies to every fanned-out turn.
pub struct OpenHumanAgentRunner {
pub config: Arc<Config>,
+ /// The context the run acts under, handed over by whoever started it.
+ pub ctx: crate::core::runtime::DispatchCtx,
/// The run's approval context (flow run correlation), handed to the gate
/// with every acting dispatch.
pub approval: crate::security::approval::ApprovalTurnContext,
@@ -175,8 +177,8 @@ impl AgentRunner for OpenHumanAgentRunner {
request: Value,
conn: Option<&str>,
) -> Result<Value> {
- // Entry point of a flow agent node: bind the calling task's context once.
- let dispatch = crate::core::runtime::DispatchCtx::ambient();
+ // Entry point of a flow agent node: the run's own context.
+ let dispatch = self.ctx.clone();
// The harness definition registry must be initialised before we can
// build a named agent. Idempotent: a booted core already did this at
// startup; a bare flow run (tests, standalone) has not. A failure here
diff --git a/crates/openhuman-core/src/flows/tinyflows/caps/code.rs b/crates/openhuman-core/src/flows/tinyflows/caps/code.rs
index 62e69bfee6..95a4999847 100644
--- a/crates/openhuman-core/src/flows/tinyflows/caps/code.rs
+++ b/crates/openhuman-core/src/flows/tinyflows/caps/code.rs
@@ -45,6 +45,8 @@ use tinybox_bus::CommandClass;
/// no policy check and no approval gate at all.
pub struct OpenHumanCode {
pub config: Arc<Config>,
+ /// The context the run acts under, handed over by whoever started it.
+ pub ctx: DispatchCtx,
pub security: Arc<SecurityPolicy>,
/// The run's approval context (flow run correlation), handed to the gate
/// with every acting dispatch.
@@ -83,8 +85,7 @@ impl CodeRunner for OpenHumanCode {
return Err(EngineError::Capability(reason));
}
- // Transitional (#7801): the flow caps carry no context yet.
- let dispatch = DispatchCtx::ambient();
+ let dispatch = self.ctx.clone();
let outcome: Result<Value> = async {
let policy = resolve_sandbox_policy(
&dispatch,
diff --git a/crates/openhuman-core/src/flows/tinyflows/caps/http.rs b/crates/openhuman-core/src/flows/tinyflows/caps/http.rs
index 61be564050..f132457efb 100644
--- a/crates/openhuman-core/src/flows/tinyflows/caps/http.rs
+++ b/crates/openhuman-core/src/flows/tinyflows/caps/http.rs
@@ -43,6 +43,8 @@ use tinytools::Tool as _;
/// **unknown** credential fails the request closed (`EngineError::Capability`)
/// rather than silently sending it unauthenticated.
pub struct OpenHumanHttp {
+ /// The context the run acts under, handed over by whoever started it.
+ pub ctx: crate::core::runtime::DispatchCtx,
pub security: Arc<SecurityPolicy>,
pub http_config: HttpRequestConfig,
pub http_creds: Arc<HttpCredentialsStore>,
@@ -197,7 +199,7 @@ impl HttpClient for OpenHumanHttp {
}
let tool = http_request_tool(
- &crate::core::runtime::DispatchCtx::ambient(),
+ &self.ctx,
self.security.clone(),
self.http_config.allowed_domains.clone(),
self.http_config.max_response_size,
diff --git a/crates/openhuman-core/src/flows/tinyflows/caps/ops.rs b/crates/openhuman-core/src/flows/tinyflows/caps/ops.rs
index c76514098c..160256ce4a 100644
--- a/crates/openhuman-core/src/flows/tinyflows/caps/ops.rs
+++ b/crates/openhuman-core/src/flows/tinyflows/caps/ops.rs
@@ -605,11 +605,15 @@ impl ToolInvoker for OpenHumanTools {
/// flow-scoped memory: `OpenHumanMemory` tags memory items with
/// `flows::flow_tag`, derived independently from the run's trusted origin.
///
+/// `ctx` is the context the run acts under: the agent, code and HTTP adapters
+/// act for it instead of reading the calling task's own scope.
+///
/// `flow_run` is the run the capabilities serve: every acting dispatch hands it
/// to the approval gate (with the tool call), so a parked approval is stamped
/// with the exact flow and run. `None` for a run with no flow identity (a dry
/// run, a preview).
pub fn build_capabilities(
+ ctx: &crate::core::runtime::DispatchCtx,
config: Arc<Config>,
state_namespace: impl Into<String>,
flow_run: Option<crate::security::approval::FlowRunContext>,
@@ -636,12 +640,14 @@ pub fn build_capabilities(
approval: approval.clone(),
}),
http: Arc::new(OpenHumanHttp {
+ ctx: ctx.clone(),
security: security.clone(),
http_config,
http_creds,
approval: approval.clone(),
}),
code: Arc::new(OpenHumanCode {
+ ctx: ctx.clone(),
config: config.clone(),
security: security.clone(),
approval: approval.clone(),
@@ -649,6 +655,7 @@ pub fn build_capabilities(
state: crate::flows::tinyflows::state::FlowState::open(&config, state_namespace)
.into_state_store(),
agent: Some(Arc::new(OpenHumanAgentRunner {
+ ctx: ctx.clone(),
config: config.clone(),
approval: approval.clone(),
})),