Skip to content

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

fix(tinyagents): deliver TurnCompleted instead of dropping it on a full channel\n\n`AgentProgress` rides a bounded 256-slot mpsc whose producer is `try_send`, so\nevents are dropped when the consumer is behind. The terminal `TurnCompleted` was\nemitted through that same lossy path as `let _ = sink.try_send(...)`.\n\nThe web-chat progress bridge sets `parent_completed` on `TurnCompleted` and on\nnothing else. When the event is dropped the bridge falls out of its loop on\nsender-drop with `parent_completed == false`, records the run as `interrupted`\n("progress bridge exited before turn completion") and never emits `chat_done`.\n\nThe turn itself has already succeeded at that point: the journal records\n`run_completed`, and the reply is persisted to the journal, the session\ntranscript and the memory tree. Only the user-visible thread misses it, so the\nUI shows a tool running and then silence forever, while the agent reads its own\nreply back as context on the next turn and behaves as though it had answered.\n\nOnly tool-heavy turns are affected, because only they generate enough events to\nfill the buffer. Observed: turns with 5 tool calls were reliably lost while\n0-tool turns always completed.\n\nBlocking is safe at this call site specifically. It is guarded by\n`subagent_scope.is_none()`, so it runs only on a parent turn that nothing is\nawaiting. The sub-agent stall documented on `harness::session::tool_progress::emit`\nrequires parking a *sub-agent's* loop while the orchestrator awaits its tool\ncall, which is unreachable here. Deltas and sub-agent lifecycle events keep the\nlossy `emit` path deliberately.\n\nVerified against a self-hosted core: a 16-tool turn now completes and emits\n`chat_done`, where 5 tools previously produced `interrupted`.\n

MuscleGear5d43b0f29cf5e
diff --git a/src/openhuman/agent/tinyagents/mod_part_02.rs b/src/openhuman/agent/tinyagents/mod_part_02.rs
index 2c2a7ca005..c97ea995cc 100644
--- a/src/openhuman/agent/tinyagents/mod_part_02.rs
+++ b/src/openhuman/agent/tinyagents/mod_part_02.rs
@@ -547,9 +547,32 @@ pub(crate) async fn run_turn_via_tinyagents_shared(
// (`defer_turn_completed_to_caller`, #4457 defect C) — so this is the single
// emission point for callers with no post-run streaming (channel/CLI).
if let Some(sink) = &turn_completed_sink {
- let _ = sink.try_send(AgentProgress::TurnCompleted {
- iterations: run.model_calls as u32,
- });
+ // NOT best-effort. `TurnCompleted` is the web bridge's sole completion
+ // signal: drop it and `parent_completed` stays false, so the bridge
+ // marks a turn that actually finished as `interrupted` and never emits
+ // `chat_done`. The turn's output still reaches the journal, session
+ // transcript and memory tree, so the agent "remembers" replying while
+ // the user's thread shows silence. A heavy turn (many tools + long
+ // streaming) reliably fills the 256-slot channel, which is why only
+ // tool-heavy turns were affected.
+ //
+ // Blocking is safe *here specifically*: this site is guarded by
+ // `subagent_scope.is_none()`, so it only ever runs on a parent turn
+ // with nothing awaiting it. The sub-agent stall documented on
+ // `tool_progress::emit` comes from parking a *sub-agent's* loop while
+ // the orchestrator awaits its tool call — unreachable from this path.
+ // Deltas and sub-agent lifecycle events stay lossy via `emit`.
+ if let Err(err) = sink
+ .send(AgentProgress::TurnCompleted {
+ iterations: run.model_calls as u32,
+ })
+ .await
+ {
+ tracing::warn!(
+ error = %err,
+ "[tinyagents] TurnCompleted not delivered — progress receiver gone"
+ );
+ }
}
// Response-cache effectiveness for this turn (issue #4249, 03.2). Additive —