Skip to content

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

feat(web_chat): wrap media tools in artifact tool and add timing to chat done

Steven Enamakelffc9c4e3a9a5
diff --git a/crates/openhuman-core/src/media/generation/tools.rs b/crates/openhuman-core/src/media/generation/tools.rs
index f4f6908166..022cf3a5d7 100644
--- a/crates/openhuman-core/src/media/generation/tools.rs
+++ b/crates/openhuman-core/src/media/generation/tools.rs
@@ -71,21 +71,25 @@ pub fn media_tools_from(
let output = MediaOutput::new(action_dir)
.with_reference_policy(reference_policy(action_dir, workspace_dir));
let tools: Vec<Box<dyn Tool>> = vec![
- Box::new(
+ Box::new(MediaArtifactTool::new(
GenerateImageTool::new(Arc::clone(&image), output.clone())
.with_name(IMAGE_TOOL_NAME)
.with_description(IMAGE_DESCRIPTION)
.with_permission_level(PermissionLevel::Execute)
.with_category(ToolCategory::Workflow),
- ),
- Box::new(
+ ArtifactKind::Image,
+ workspace_dir.to_path_buf(),
+ )),
+ Box::new(MediaArtifactTool::new(
GenerateVideoTool::new(Arc::clone(&video), output)
.with_name(VIDEO_TOOL_NAME)
.with_description(VIDEO_DESCRIPTION)
.with_permission_level(PermissionLevel::Execute)
.with_category(ToolCategory::Workflow)
.with_wait_policy(video_wait),
- ),
+ ArtifactKind::Video,
+ workspace_dir.to_path_buf(),
+ )),
Box::new(MediaListModelsTool { image, video }),
];
tracing::debug!("[media_generation] registered {} media tools", tools.len());
diff --git a/crates/openhuman-core/src/web_chat/presentation.rs b/crates/openhuman-core/src/web_chat/presentation.rs
index bf4e422331..fd58ad073c 100644
--- a/crates/openhuman-core/src/web_chat/presentation.rs
+++ b/crates/openhuman-core/src/web_chat/presentation.rs
@@ -270,6 +270,9 @@ pub(crate) fn deliver_response_single_bubble(
None,
&[],
usage_payload(usage),
+ // Background/core-initiated turns don't run through the web-channel
+ // progress bridge, so there is no `TurnTiming` to report here.
+ None,
);
}
@@ -282,6 +285,7 @@ fn publish_chat_done(
reaction_emoji: Option<String>,
citations: &[crate::memory::agent::memory_loader::MemoryCitation],
usage_payload: Option<TurnUsagePayload>,
+ timing_payload: Option<crate::core::socketio::TurnTimingPayload>,
) {
publish_web_channel_event(WebChannelEvent {
event: "chat_done".to_string(),
diff --git a/crates/openhuman-core/src/web_chat/progress_bridge.rs b/crates/openhuman-core/src/web_chat/progress_bridge.rs
index 3ce526650e..4df11faf8e 100644
--- a/crates/openhuman-core/src/web_chat/progress_bridge.rs
+++ b/crates/openhuman-core/src/web_chat/progress_bridge.rs
@@ -949,6 +949,7 @@ pub(crate) fn spawn_progress_bridge(
task_id,
error,
} => {
+ let parent_call_id = subagent_parent_call_ids.remove(&task_id).flatten();
let completed_at = chrono::Utc::now();
ledger_upsert_agent_run(
&config,
@@ -984,7 +985,11 @@ pub(crate) fn spawn_progress_bridge(
RunEventAppend {
run_id: task_id.clone(),
event_type: "subagent_failed".to_string(),
- payload: json!({ "agentId": agent_id, "error": error }),
+ payload: json!({
+ "agentId": agent_id,
+ "error": error,
+ "parentCallId": parent_call_id
+ }),
},
);
publish_seq_stamped(
@@ -998,6 +1003,10 @@ pub(crate) fn spawn_progress_bridge(
tool_name: Some(agent_id),
skill_id: Some(task_id),
success: Some(false),
+ subagent: Some(SubagentProgressDetail {
+ parent_call_id,
+ ..Default::default()
+ }),
round: Some(round),
..Default::default()
},