Skip to content

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

fix(web_chat): publish late subagent failures directly

Steven Enamakel06a6d38be127
diff --git a/crates/openhuman-core/src/web_chat/turn_host.rs b/crates/openhuman-core/src/web_chat/turn_host.rs
index 0ff2498f16..3848cc2126 100644
--- a/crates/openhuman-core/src/web_chat/turn_host.rs
+++ b/crates/openhuman-core/src/web_chat/turn_host.rs
@@ -45,7 +45,9 @@ use tinyagents_harness::progress::AgentProgress;
mod progress_helpers;
#[cfg(test)]
use progress_helpers::spawn_heartbeat_with_interval;
-use progress_helpers::{settle_turn_snapshot, spawn_heartbeat, tap_progress, AbortOnDrop};
+use progress_helpers::{
+ settle_turn_snapshot, spawn_heartbeat, tap_progress, AbortOnDrop, LateSubagentSink,
+};
/// How long a finished turn waits for its progress tap to forward every event
/// the turn queued before the terminal `chat_done`/`chat_error` is published.
diff --git a/crates/openhuman-core/src/web_chat/turn_host_progress.rs b/crates/openhuman-core/src/web_chat/turn_host_progress.rs
index bdbed297e1..e902e7294e 100644
--- a/crates/openhuman-core/src/web_chat/turn_host_progress.rs
+++ b/crates/openhuman-core/src/web_chat/turn_host_progress.rs
@@ -127,38 +127,40 @@ pub(super) struct LateSubagentSink {
impl LateSubagentSink {
fn publish(&self, ctx: &DispatchCtx, event: AgentProgress) {
- let is_subagent = matches!(
- event,
- AgentProgress::SubagentSpawned { .. }
- | AgentProgress::SubagentCompleted { .. }
- | AgentProgress::SubagentFailed { .. }
- | AgentProgress::SubagentAwaitingUser { .. }
- | AgentProgress::SubagentIterationStarted { .. }
- | AgentProgress::SubagentToolCallStarted { .. }
- | AgentProgress::SubagentToolCallCompleted { .. }
- );
- if !is_subagent {
- return;
- }
- let Some(output) = super::super::progress_map::subagent_event(event, 0, None) else {
+ // Only the event that settles a sub-agent card can matter after the
+ // turn: a child aborted by `subagent_cancel` (or one that failed late)
+ // still reports its failure. Everything else is turn-scoped output
+ // the finished turn no longer renders.
+ let AgentProgress::SubagentFailed {
+ agent_id,
+ task_id,
+ error,
+ ..
+ } = event
+ else {
return;
};
- let mut projector = tinychannels_runtime::adapters::web::WebTurnProjector::new(
- &self.client_id,
- &self.thread_id,
- &self.request_id,
+ log::debug!(
+ "[web-channel] late subagent_failed task_id={task_id} request_id={}",
+ self.request_id
+ );
+ let context = super::super::event_context(
+ self.client_id.clone(),
+ self.thread_id.clone(),
+ self.request_id.clone(),
+ );
+ super::super::event_bus_channel::publish_web_channel_event_in(
+ ctx,
+ tinychannels_bus::web::WebChannelEvent::SubagentFailed {
+ context,
+ message: Some(error),
+ tool_name: Some(agent_id),
+ skill_id: Some(task_id),
+ success: Some(false),
+ subagent: None,
+ round: None,
+ },
);
- for mut projected in projector.project(output, super::super::progress::unix_epoch_ms()) {
- // A late event follows the turn's own sequence, which this
- // projector does not know; leave it unstamped.
- tinychannels_runtime::adapters::web::context_mut(&mut projected).seq = None;
- log::debug!(
- "[web-channel] late sub-agent event event={} request_id={}",
- projected.event_name(),
- self.request_id
- );
- super::super::event_bus_channel::publish_web_channel_event_in(ctx, projected);
- }
}
}