The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
refactor(core): centralize turn event mapping
Steven Enamakelc51edc02ad0c
diff --git a/crates/openhuman-core/src/agent/turn_progress.rs b/crates/openhuman-core/src/agent/turn_progress.rsindex 100461b7dd..2fa5af09ac 100644--- a/crates/openhuman-core/src/agent/turn_progress.rs+++ b/crates/openhuman-core/src/agent/turn_progress.rs@@ -16,6 +16,67 @@ use tinyagents_harness::progress::AgentProgress;type Failure = tinytools::status::ClassifiedFailure;+/// The shared per-turn progress events understood by both web and native+/// channel projections. Surface-specific lifecycle and sub-agent orchestration+/// remains in each adapter, while tool result handling stays canonical here.+pub(crate) fn turn_event(event: AgentProgress) -> Option<ChannelOutputEvent> {+ match event {+ AgentProgress::TextDelta { delta, iteration } => Some(text_delta(delta, iteration)),+ AgentProgress::ThinkingDelta { delta, iteration } => {+ Some(thinking_delta(delta, iteration))+ }+ AgentProgress::ToolCallStarted {+ call_id,+ tool_name,+ arguments,+ iteration,+ display_label,+ display_detail,+ } => Some(tool_started(+ call_id,+ tool_name,+ arguments,+ iteration,+ display_label,+ display_detail,+ )),+ AgentProgress::ToolCallArgsDelta {+ call_id,+ tool_name,+ delta,+ iteration,+ } => Some(ChannelOutputEvent::ToolCallArgsDelta {+ call_id,+ tool_name,+ delta,+ iteration,+ }),+ AgentProgress::ToolCallProgress { call_id, message } => {+ Some(tool_progress(call_id, message))+ }+ completed @ AgentProgress::ToolCallCompleted { .. } => tool_completed(completed),+ _ => None,+ }+}++pub(crate) fn text_delta(text: String, iteration: u32) -> ChannelOutputEvent {+ ChannelOutputEvent::TextDelta {+ text,+ iteration: Some(iteration),+ }+}++pub(crate) fn thinking_delta(text: String, iteration: u32) -> ChannelOutputEvent {+ ChannelOutputEvent::ThinkingDelta {+ text,+ iteration: Some(iteration),+ }+}++pub(crate) fn tool_progress(call_id: String, message: String) -> ChannelOutputEvent {+ ChannelOutputEvent::ToolCallProgress { call_id, message }+}+/// Wire spelling of a unit-variant enum (`ClassifiedFailure` serializes its/// class and category as the bare variant name).fn variant_name<T: Serialize>(value: &T) -> String {diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/processor/progressive.rs b/crates/openhuman-core/src/channels/runtime/dispatch/processor/progressive.rsindex 7fc741fffc..a3da48882e 100644--- a/crates/openhuman-core/src/channels/runtime/dispatch/processor/progressive.rs+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor/progressive.rs@@ -183,64 +183,7 @@ fn delivery_unsupported_count(}pub(crate) fn output_event(progress: AgentProgress) -> Option<ChannelOutputEvent> {- match progress {- AgentProgress::TextDelta { delta, iteration } => Some(ChannelOutputEvent::TextDelta {- text: delta,- iteration: Some(iteration),- }),- AgentProgress::ThinkingDelta { delta, iteration } => {- Some(ChannelOutputEvent::ThinkingDelta {- text: delta,- iteration: Some(iteration),- })- }- AgentProgress::ToolCallStarted {- call_id,- tool_name,- arguments,- iteration,- display_label,- display_detail,- } => Some(ChannelOutputEvent::ToolCallStarted {- call_id,- tool_name,- arguments,- iteration,- display_label,- display_detail,- }),- AgentProgress::ToolCallProgress { call_id, message } => {- Some(ChannelOutputEvent::ToolCallProgress { call_id, message })- }- AgentProgress::ToolCallCompleted {- call_id,- tool_name,- success,- output_chars,- output,- arguments,- elapsed_ms,- iteration,- display_label,- display_detail,- structured,- ..- } => Some(ChannelOutputEvent::ToolCallCompleted {- call_id,- tool_name,- success,- output_chars,- output,- arguments,- elapsed_ms,- iteration,- failure: None,- display_label,- display_detail,- structured,- }),- _ => None,- }+ crate::agent::turn_progress::turn_event(progress)}#[cfg(test)]diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/processor/progressive_tests.rs b/crates/openhuman-core/src/channels/runtime/dispatch/processor/progressive_tests.rsindex 37405d422e..032d89ae24 100644--- a/crates/openhuman-core/src/channels/runtime/dispatch/processor/progressive_tests.rs+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor/progressive_tests.rs@@ -42,6 +42,50 @@ fn native_tool_progress_keeps_correlation_and_display_metadata() {));}+#[test]+fn native_tool_completion_preserves_failure_and_shared_payload_caps() {+ let failure = tinytools::status::classify("[not-found] missing file", false);+ let event = output_event(AgentProgress::ToolCallCompleted {+ call_id: "call-failed".into(),+ tool_name: "file_read".into(),+ success: false,+ output_chars: 4,+ output: "x".repeat(tinychannels_bus::web::MAX_WEB_TOOL_PAYLOAD_BYTES + 32),+ arguments: Some(serde_json::json!({+ "path": "y".repeat(tinychannels_bus::web::MAX_WEB_TOOL_PAYLOAD_BYTES)+ })),+ elapsed_ms: 12,+ iteration: 4,+ failure: Some(failure.clone()),+ display_label: None,+ display_detail: None,+ structured: Some(serde_json::json!({"kind": "read"})),+ })+ .expect("tool completion is projected");+ let ChannelOutputEvent::ToolCallCompleted {+ output,+ arguments,+ failure: summary,+ success,+ structured,+ ..+ } = event+ else {+ panic!("tool completion")+ };+ assert!(output.len() <= tinychannels_bus::web::MAX_WEB_TOOL_PAYLOAD_BYTES);+ assert!(output.contains("truncated"));+ let arguments = arguments.expect("arguments");+ assert!(arguments.to_string().contains("truncated"));+ let summary = summary.expect("classified failure");+ assert_eq!(summary.cause_plain, failure.cause_plain);+ assert_eq!(summary.recoverable, failure.recoverable);+ assert!(!summary.class.is_empty());+ assert!(!summary.category.is_empty());+ assert!(!success);+ assert_eq!(structured, Some(serde_json::json!({"kind": "read"})));+}+#[test]fn progressive_delivery_status_rejects_partial_or_unsupported_terminal_results() {use tinychannels_bus::module_progressive::{ProgressiveOutputFailure, ProgressiveResult};diff --git a/crates/openhuman-core/src/web_chat/progress.rs b/crates/openhuman-core/src/web_chat/progress.rsindex 9ea53313e8..40c103fc02 100644--- a/crates/openhuman-core/src/web_chat/progress.rs+++ b/crates/openhuman-core/src/web_chat/progress.rs@@ -276,19 +276,13 @@ impl ProgressProjection {self.pending_narration.push_str(&delta);if !self.metadata.hold_text_stream {self.surface- .output(ChannelOutputEvent::TextDelta {- text: delta,- iteration: Some(iteration),- })+ .output(map::text_delta(delta, iteration)).await;}}AgentProgress::ThinkingDelta { delta, iteration } => {self.surface- .output(ChannelOutputEvent::ThinkingDelta {- text: delta,- iteration: Some(iteration),- })+ .output(map::thinking_delta(delta, iteration)).await;}AgentProgress::ToolCallArgsDelta {@@ -312,7 +306,7 @@ impl ProgressProjection {self.ids.request_id);self.surface- .output(ChannelOutputEvent::ToolCallProgress { call_id, message })+ .output(map::tool_progress(call_id, message)).await;}AgentProgress::TurnCompleted { iterations, .. } => {