Skip to content

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

refactor(core): update turn origin documentation and context handling

Steven Enamakel894fe405646a
diff --git a/crates/openhuman-core/src/agent/turn_origin.rs b/crates/openhuman-core/src/agent/turn_origin.rs
index de956dddb6..0fff646124 100644
--- a/crates/openhuman-core/src/agent/turn_origin.rs
+++ b/crates/openhuman-core/src/agent/turn_origin.rs
@@ -56,8 +56,8 @@ pub enum AgentTurnOrigin {
sender_name: Option<String>,
reply_target: String,
message_id: String,
- /// The channel runtime's conversation-history key for this chat, set only by
- /// the channel processor (the one place that owns `conversation_histories`).
+ /// The channel runtime's legacy conversation key for this chat, set only by
+ /// the channel processor. It is attribution data, not durable session authority.
/// `None` for ExternalChannel-labelled turns that are not a channel
/// conversation (MCP server callers, triage, voice), so scheduling can tell a
/// real chat from those.
diff --git a/crates/openhuman-core/src/channels/context.rs b/crates/openhuman-core/src/channels/context.rs
index f1aaa2599a..3c4273889f 100644
--- a/crates/openhuman-core/src/channels/context.rs
+++ b/crates/openhuman-core/src/channels/context.rs
@@ -11,11 +11,13 @@ use std::sync::{Arc, Mutex};
use tinytools::Tool;
pub(crate) use tinychannels_runtime::context::{
- clear_sender_history, ChannelRouteSelection, ConversationHistoryMap,
- CHANNEL_MESSAGE_TIMEOUT_SECS, CHANNEL_TYPING_REFRESH_INTERVAL_SECS,
+ ChannelRouteSelection, CHANNEL_MESSAGE_TIMEOUT_SECS, CHANNEL_TYPING_REFRESH_INTERVAL_SECS,
DEFAULT_CHANNEL_INITIAL_BACKOFF_SECS, DEFAULT_CHANNEL_MAX_BACKOFF_SECS, MAX_CHANNEL_HISTORY,
};
+#[cfg(test)]
+pub(crate) use tinychannels_runtime::context::{clear_sender_history, ConversationHistoryMap};
+
#[cfg(test)]
pub(crate) use tinychannels_runtime::context::compact_sender_history;
@@ -53,6 +55,7 @@ pub(crate) struct ChannelRuntimeContext {
pub(crate) model: Arc<String>,
pub(crate) temperature: f64,
pub(crate) max_tool_iterations: usize,
+ #[cfg(test)]
pub(crate) conversation_histories: ConversationHistoryMap,
pub(crate) turn_model_source_cache: TurnModelSourceCacheMap,
pub(crate) route_overrides: RouteSelectionMap,
diff --git a/crates/openhuman-core/src/channels/routes.rs b/crates/openhuman-core/src/channels/routes.rs
index 8f4242f9c5..b65cb2a574 100644
--- a/crates/openhuman-core/src/channels/routes.rs
+++ b/crates/openhuman-core/src/channels/routes.rs
@@ -1,5 +1,6 @@
//! Per-sender routing and runtime command handling.
+#[cfg(test)]
#[cfg(test)]
use super::context::clear_sender_history;
use super::context::{ChannelRouteSelection, ChannelRuntimeContext};
diff --git a/crates/openhuman-core/src/channels/runtime/startup/turn_parts.rs b/crates/openhuman-core/src/channels/runtime/startup/turn_parts.rs
index 0254bb4192..84b67eaa54 100644
--- a/crates/openhuman-core/src/channels/runtime/startup/turn_parts.rs
+++ b/crates/openhuman-core/src/channels/runtime/startup/turn_parts.rs
@@ -251,6 +251,7 @@ pub(crate) fn runtime_context(
model: Arc::new(parts.model),
temperature: config.default_temperature,
max_tool_iterations: config.agent.max_tool_iterations,
+ #[cfg(test)]
conversation_histories: Arc::new(Mutex::new(HashMap::new())),
turn_model_source_cache: Arc::new(Mutex::new(HashMap::new())),
route_overrides: Arc::new(Mutex::new(HashMap::new())),