Skip to content

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

refactor(agent): thread dispatch context into journal trace reads

Steven Enamakel4c8080e2333a
diff --git a/crates/openhuman-core/src/agent/progress_tracing/export.rs b/crates/openhuman-core/src/agent/progress_tracing/export.rs
index afa79bc38c..f1818ea6af 100644
--- a/crates/openhuman-core/src/agent/progress_tracing/export.rs
+++ b/crates/openhuman-core/src/agent/progress_tracing/export.rs
@@ -133,6 +133,7 @@ pub(crate) async fn export_run_trace_from_journal(
/// The backend stamps the authenticated user onto the trace, while the child
/// run's original parent/root ids remain in trace metadata for navigation.
pub(crate) async fn export_subagent_journal_trace(
+ ctx: &crate::core::runtime::DispatchCtx,
config: &Config,
journal_run_id: &str,
thread_id: Option<&str>,
@@ -151,7 +152,7 @@ pub(crate) async fn export_subagent_journal_trace(
);
return;
}
- let observations = match crate::agent::tinyagents::journal::read_run_events(journal_run_id, 0)
+ let observations = match crate::agent::tinyagents::journal::read_run_events(ctx, journal_run_id, 0)
.await
{
Ok(observations) if !observations.is_empty() => observations,
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/graph/dispatch.rs b/crates/openhuman-core/src/agent/subagent_host/ops/graph/dispatch.rs
index 12403fe010..35c242157e 100644
--- a/crates/openhuman-core/src/agent/subagent_host/ops/graph/dispatch.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/ops/graph/dispatch.rs
@@ -190,6 +190,7 @@ pub(in super::super) async fn run_subagent_via_graph(
// dispatch boundary. Reusing that owned value preserves its immediate
// parent-ledger link; forking again here would hide nested child usage in a
// second, unreachable ledger.
+ let dispatch = run_context.dispatch_ctx();
let mut child_context = run_context;
// A parallel task may omit `thread_id`; that means inherit the parent
// conversation, not erase it. Only an explicit task thread may replace
@@ -262,8 +263,10 @@ pub(in super::super) async fn run_subagent_via_graph(
let thread_id = trace_session_group.clone();
let agent_id = agent_id.to_string();
let task_id = task_id.to_string();
+ let dispatch = dispatch.clone();
tokio::spawn(async move {
crate::agent::progress_tracing::export_subagent_journal_trace(
+ &dispatch,
&config,
&journal_run_id,
thread_id.as_deref(),
diff --git a/crates/openhuman-core/src/web_chat/journal_shadow.rs b/crates/openhuman-core/src/web_chat/journal_shadow.rs
index 3844b2d780..1cf02938f5 100644
--- a/crates/openhuman-core/src/web_chat/journal_shadow.rs
+++ b/crates/openhuman-core/src/web_chat/journal_shadow.rs
@@ -100,6 +100,7 @@ fn describe_signature_divergence(live: &[String], projected: &[String]) -> Strin
}
pub(super) async fn shadow_compare_journal_projection(
+ ctx: &crate::core::runtime::DispatchCtx,
request_id: &str,
trace_ctx: tinyagents_harness::observability::trace_export::TraceContext,
max_iterations: u32,
@@ -115,7 +116,7 @@ pub(super) async fn shadow_compare_journal_projection(
return None;
};
- let observations = match crate::agent::tinyagents::journal::read_run_events(&journal_run_id, 0)
+ let observations = match crate::agent::tinyagents::journal::read_run_events(ctx, &journal_run_id, 0)
.await
{
Ok(observations) => observations,
diff --git a/crates/openhuman-core/src/web_chat/progress_bridge.rs b/crates/openhuman-core/src/web_chat/progress_bridge.rs
index 878271256f..df91541a8f 100644
--- a/crates/openhuman-core/src/web_chat/progress_bridge.rs
+++ b/crates/openhuman-core/src/web_chat/progress_bridge.rs
@@ -1164,6 +1164,7 @@ pub(crate) fn spawn_progress_bridge(
let live_spans = collector.spans().to_vec();
let journal_export = if let Some(trace_ctx) = journal_trace_ctx.take() {
super::journal_shadow::shadow_compare_journal_projection(
+ &crate::core::runtime::DispatchCtx::ambient(),
&request_id,
trace_ctx.clone(),
parent_max_iterations,