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
chore: files changed crates/openhuman-core/src/channels/runtime/dispatch/host_agent/mod.rs,crates/op
Steven Enamakelec8829a6e970
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/mod.rs b/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/mod.rsindex 2c856dd9de..edbb521e34 100644--- a/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/mod.rs+++ b/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/mod.rs@@ -29,7 +29,7 @@ use crate::core::events::DomainEvent;pub(crate) mod posture;mod turn;-pub(crate) use turn::{run_host_agent_turn, HostChannelTurn};+pub(crate) use turn::{run_host_agent_turn, seed_rows, HostChannelTurn};/// What a channel's binding resolves to for one message.pub(crate) enum HostRoute {diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/mod_tests.rs b/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/mod_tests.rsindex a3b835d8ee..4faefd9bc0 100644--- a/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/mod_tests.rs+++ b/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/mod_tests.rs@@ -35,3 +35,23 @@ fn the_binding_is_read_from_toml() {Some("teeny-chat"));}++#[test]+fn seed_rows_keep_only_the_prior_turns() {+ use tinyagents_session::transcript::TranscriptMessage;+ let history = vec![+ TranscriptMessage::system("CHANNEL_PROMPT"),+ TranscriptMessage::user("earlier"),+ TranscriptMessage::assistant("reply"),+ TranscriptMessage::user("now"),+ ];+ assert_eq!(+ seed_rows(&history),+ vec![+ ("user".to_string(), "earlier".to_string()),+ ("assistant".to_string(), "reply".to_string()),+ ]+ );+ assert!(seed_rows(&history[..2]).is_empty());+ assert!(seed_rows(&[]).is_empty());+}diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/turn.rs b/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/turn.rsindex 55338b6b60..adcbde1835 100644--- a/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/turn.rs+++ b/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/turn.rs@@ -7,6 +7,7 @@ use crate::agent::bus::AgentTurnResponse;use crate::agent::host_agents::HostAgent;use crate::agent::progress::AgentProgress;use crate::agent::turn_origin::AgentTurnOrigin;+use tinyagents_session::transcript::TranscriptMessage;/// One channel message, as a host agent's turn needs it.pub(crate) struct HostChannelTurn {@@ -81,3 +82,16 @@ pub(crate) async fn run_host_agent_turn(model,))}++/// The prior turns of a channel `history` (`[system, ..prior, user]`) as seed+/// rows: the channel's own system prompt and the new message are dropped, the+/// agent brings its own prompt and the message is the turn.+pub(crate) fn seed_rows(history: &[TranscriptMessage]) -> Vec<(String, String)> {+ let end = history.len().saturating_sub(1);+ history+ .get(1..end)+ .unwrap_or_default()+ .iter()+ .map(|row| (row.role.clone(), row.content.clone()))+ .collect()+}diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/processor.rs b/crates/openhuman-core/src/channels/runtime/dispatch/processor.rsindex 6d8decab14..0650f71111 100644--- a/crates/openhuman-core/src/channels/runtime/dispatch/processor.rs+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor.rs@@ -12,6 +12,7 @@//! `tinychannels::runtime::run_dispatch_loop`.mod approval;+mod bus_turn;mod turn;use crate::channels::context::ChannelRuntimeContext;diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs b/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rsindex b6fa886365..398b3ad452 100644--- a/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs@@ -2,7 +2,7 @@//! assembly, dispatching the agentic turn over the native bus, and//! delivering the draft/final reply.-use crate::agent::bus::{AgentTurnRequest, AgentTurnResponse, AGENT_RUN_TURN_METHOD};+use crate::agent::bus::AgentTurnResponse;use crate::agent::progress::AgentProgress;use crate::channels::context::{compact_sender_history, conversation_history_key, is_context_window_overflow_error,@@ -19,7 +19,6 @@ use crate::util::truncate_with_ellipsis;use std::sync::Arc;use std::time::{Duration, Instant};use tinyagents_session::transcript::TranscriptMessage;-use tinybus::NativeRequestError;use tokio_util::sync::CancellationToken;use tokio_util::task::AbortOnDropHandle;@@ -27,8 +26,11 @@ use super::super::helpers::{build_channel_context_block, log_worker_join_result, select_acknowledgment_reaction,spawn_scoped_typing_task, REPLY_LOG_TRUNCATE_CHARS,};-use super::super::routing::resolve_target_agent;+use super::super::host_agent::{+ self, run_host_agent_turn, seed_rows, HostChannelTurn, HostRoute,+};use super::approval::{channel_has_approval_surface, try_route_approval_reply};+use super::bus_turn::dispatch_bus_turn;use super::RuntimeChannelMessage;pub(crate) async fn process_channel_message(@@ -83,6 +85,23 @@ pub(crate) async fn process_channel_runtime_message(return;}+ // A channel bound to a host agent nobody answers for is refused before+ // any typing or provider work; see `host_agent`.+ let bound_agent = match host_agent::route(ctx.as_ref(), &msg.channel) {+ HostRoute::Unbound => None,+ HostRoute::Agent(host) => Some(host),+ HostRoute::Missing(agent_id) => {+ host_agent::refuse_missing_agent(+ ctx.as_ref(),+ &msg,+ target_channel.as_ref(),+ &agent_id,+ )+ .await;+ return;+ }+ };+// Fire typing indicator as early as possible — before any async I/O — so the// user sees feedback immediately regardless of how fast the LLM responds.if let Some(channel) = target_channel.as_ref() {