Skip to content

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

docs(relay): describe thread id derivation via PrepareChannelIdentity

Steven Enamakel4aa6cfe9edb3
diff --git a/crates/openhuman-core/src/channels/providers/relay/README.md b/crates/openhuman-core/src/channels/providers/relay/README.md
index bcb98ebdf3..ac9cbfe9e3 100644
--- a/crates/openhuman-core/src/channels/providers/relay/README.md
+++ b/crates/openhuman-core/src/channels/providers/relay/README.md
@@ -43,7 +43,7 @@ Replies are final messages only: the relay sink takes no streaming drafts or rea
## How a message runs
-1. `params.rs` validates the message and derives its thread with `tinychannels::channel::derive_inbound_thread_id`: `channel:<channel>/<sender>/<chat>`, the same id as the backend-relayed inbound path. A user cannot create such a thread through `threads_upsert`, which reserves `channel:`.
+1. `params.rs` validates the message. The confidential `PrepareChannelIdentity` operation returns the canonical thread id, `channel:<channel>/<sender>/<chat>`, shared with the backend-relayed inbound path. A user cannot create such a thread through `threads_upsert`, which reserves `channel:`.
2. `store.rs` creates the thread in the workspace of the caller's config and appends the message (`user:<message_id>`). In a single-user core the process-wide channel persistence subscriber is told to skip this turn (`threads::store::claim_channel_turn`), so it is not mirrored under a second id; in SaaS that subscriber is not registered and the claim is a no-op.
3. `ops.rs` builds a one-message `ChannelRuntimeContext` from the caller's config and policy (`channels::runtime::build_channel_turn_parts` with `PromptToolDescs::Registered`, then `runtime_context`): the caller's tools, model and workspace, never the process's channel runtime. The pipeline's per-chat history is seeded from the thread's earlier rows. The turn runs in the background under the caller's scope (`spawn_scoped`).
4. `process_channel_message` runs it like any channel message: slash commands, approval replies, then the orchestrator over `agent.run_turn` under the `ExternalChannel` origin.
diff --git a/crates/openhuman-core/src/channels/providers/relay/mod.rs b/crates/openhuman-core/src/channels/providers/relay/mod.rs
index 4d0aab55a9..2444809965 100644
--- a/crates/openhuman-core/src/channels/providers/relay/mod.rs
+++ b/crates/openhuman-core/src/channels/providers/relay/mod.rs
@@ -6,8 +6,9 @@
//! For each message it calls `channel_relay_inbound` under that user's scope.
//! The core:
//!
-//! 1. validates the message ([`params`]) and derives its thread,
-//! `channel:<channel>/<sender>/<chat>` (`tinychannels::channel::derive_inbound_thread_id`);
+//! 1. validates the message ([`params`]) and asks TinyChannels' confidential
+//! `PrepareChannelIdentity` operation for its canonical thread id,
+//! `channel:<channel>/<sender>/<chat>`;
//! 2. records the message on that thread in the caller's workspace
//! ([`store`]), refusing a duplicate `message_id`;
//! 3. runs the turn through the channel dispatch pipeline
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/processor.rs b/crates/openhuman-core/src/channels/runtime/dispatch/processor.rs
index f56107ac09..2f285869af 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/processor.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor.rs
@@ -11,8 +11,8 @@
//! the native bus. A channel bound to a host agent runs through
//! [`super::host_agent`] instead.
//! * [`run_message_dispatch_loop`] — feeds messages into
-//! [`process_channel_runtime_message`] through the bounded-concurrency
-//! `tinychannels::runtime::run_dispatch_loop`.
+//! [`process_channel_runtime_message`] with a bounded set of host workers
+//! and joins them when the inbound queue closes.
mod approval;
mod bus_turn;