Skip to content

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

fix(tinyagents): flush child events after terminal status write

Steven Enamakel0c3d078f3167
diff --git a/crates/openhuman-core/src/agent/subagent_host/lifecycle/driver_adapter.rs b/crates/openhuman-core/src/agent/subagent_host/lifecycle/driver_adapter.rs
index e315001d2b..0b5b7eedd5 100644
--- a/crates/openhuman-core/src/agent/subagent_host/lifecycle/driver_adapter.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/lifecycle/driver_adapter.rs
@@ -191,6 +191,8 @@ impl SubagentExecutor<crate::agent::tinyagents::host::OpenHumanRunContext> for O
depth: native_run_config.lineage.depth,
config: native_run_config,
parent_events,
+ child_events: std::sync::Arc::default(),
+ child_journal: std::sync::Arc::default(),
name: definition.id.clone(),
};
let run = Box::pin(
diff --git a/crates/openhuman-core/src/agent/tinyagents/journal.rs b/crates/openhuman-core/src/agent/tinyagents/journal.rs
index a0b7616b50..ebe41b2214 100644
--- a/crates/openhuman-core/src/agent/tinyagents/journal.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/journal.rs
@@ -130,6 +130,12 @@ pub(crate) struct TurnJournal {
}
impl TurnJournal {
+ /// Flush events appended after the terminal status write without changing
+ /// that status. Child host persistence may finish after a typed RunFailed.
+ pub(crate) fn flush_events(&self) {
+ self.event_sink.flush();
+ }
+
/// Best-effort terminal write: mark the run completed and persist. Non-fatal.
pub(crate) async fn finish_completed(&self) {
self.event_sink.flush();
diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_exec.rs b/crates/openhuman-core/src/agent/tinyagents/turn_exec.rs
index 21be64d12b..c2a6b11b74 100644
--- a/crates/openhuman-core/src/agent/tinyagents/turn_exec.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/turn_exec.rs
@@ -113,6 +113,7 @@ pub(crate) struct TurnSpec<'a> {
/// Native execution identity retained by OpenHuman's neutral sub-agent
/// adapter. Child model/tool events use their own run-local sink; the parent
/// sink carries only the typed child lifecycle link.
+#[derive(Clone)]
pub(crate) struct NativeSubagentRunContext {
pub config: tinyagents_harness::context::RunConfig,
pub parent_events: EventSink,
@@ -762,12 +763,5 @@ async fn drive_turn(
journal_run_id,
)
.await;
- if let Some(native) = native_subagent {
- native.parent_events.emit(
- tinyagents_harness::events::AgentEvent::SubAgentRunCompleted {
- run_id: journal_run_id,
- },
- );
- }
Ok(outcome)
}