Skip to content

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

feat(agent): attach thread files to agent turns

Steven Enamakel2d653c824e0c
diff --git a/crates/openhuman-core/src/agent/attachments/mod.rs b/crates/openhuman-core/src/agent/attachments/mod.rs
index 0124414adb..c2683bfb3f 100644
--- a/crates/openhuman-core/src/agent/attachments/mod.rs
+++ b/crates/openhuman-core/src/agent/attachments/mod.rs
@@ -161,6 +161,7 @@ pub(crate) fn action_root(config: &Config, scope: &AttachmentAccessScope) -> Pat
/// Uploads must be written, validated and read under this one root; the turn
/// runs with `action_dir` replaced by the thread's folder (#7714).
pub(crate) async fn thread_action_dir(
+ ctx: &DispatchCtx,
config: &Config,
threads_dir: &Path,
thread_id: Option<&str>,
@@ -169,7 +170,7 @@ pub(crate) async fn thread_action_dir(
return Ok(config.action_dir.clone());
};
let bound = crate::threads::ops::thread_working_dir(
- &DispatchCtx::ambient(),
+ ctx,
threads_dir.to_path_buf(),
thread_id,
)
diff --git a/crates/openhuman-core/src/agent/harness/graph.rs b/crates/openhuman-core/src/agent/harness/graph.rs
index 976464c6be..b2ed10ef19 100644
--- a/crates/openhuman-core/src/agent/harness/graph.rs
+++ b/crates/openhuman-core/src/agent/harness/graph.rs
@@ -62,9 +62,10 @@ pub(crate) async fn run_channel_turn_via_graph(
memory_identity: crate::memory::scope::MemoryIdentity,
) -> Result<crate::agent::tinyagents::TinyagentsTurnOutcome> {
let extra_arc = Arc::new(extra_tools);
- // A channel/CLI turn is entered without a run context: bind the calling
- // task's context here, once, and carry it on the turn's run context.
- let dispatch = crate::core::runtime::DispatchCtx::ambient();
+ // A channel/CLI turn is entered without a run context: the model source
+ // was built under the turn's context, so bind that one here, once, and
+ // carry it on the turn's run context.
+ let dispatch = source.dispatch_ctx();
// The callable set is the visibility whitelist. The runner advertises each via
// its own `spec()`, deduped by name (extras shadow the registry).
diff --git a/crates/openhuman-core/src/threads/ops/crud.rs b/crates/openhuman-core/src/threads/ops/crud.rs
index 3827edba7a..55e613dbc7 100644
--- a/crates/openhuman-core/src/threads/ops/crud.rs
+++ b/crates/openhuman-core/src/threads/ops/crud.rs
@@ -190,6 +190,7 @@ async fn message_append_with_config(
// where the turn reads them (#7714).
let workspace = if raw_upload || durable_upload {
crate::agent::attachments::thread_action_dir(
+ ctx,
config,
persistence_dir,
Some(&request.thread_id),
diff --git a/crates/openhuman-core/src/web_chat/ops/start_chat.rs b/crates/openhuman-core/src/web_chat/ops/start_chat.rs
index 836800f269..cb2531c0b4 100644
--- a/crates/openhuman-core/src/web_chat/ops/start_chat.rs
+++ b/crates/openhuman-core/src/web_chat/ops/start_chat.rs
@@ -200,6 +200,7 @@ async fn start_chat_inner(
// Stage where the turn will read: the thread's working folder when
// one is bound (`run_task` applies the same folder), else action_dir.
let workspace = crate::agent::attachments::thread_action_dir(
+ ctx,
&config,
&config.workspace_dir,
Some(&thread_id),