Repository navigation
Description
Parent: #8147
Summary
Route hosted channel messages (Telegram/Discord/Slack over the backend socket) through the tinyeventqueues pipeline instead of the event bus, so none are lost and each one is gated, coalesced and triaged before it costs an agent turn.
Problem
platform/socket/event_handlers.rs (the *:message arm, ~L263) publishes ChannelInboundMessage on the event bus. The bus buffers 256 signals and a lagging subscriber silently skips. ChannelInboundSubscriber (channels/bus/subscriber.rs, ~L142) then blocks up to 180 s per message, so hosted messages are serialized behind each other and can be dropped under load. Every message also costs a full agent turn — channel traffic is never triaged.
Solution
- In the socket handler, hand the message to
inbound::route(as Composio triggers and webhooks do since feat(inbound): queue Composio triggers and agent webhooks through tinyeventqueues #8136); keep the bus publish only as the direct path when the queues do not take the event. - Envelope:
source = channel:<platform>,conversation_key/thread_keyfrom channel + thread_ts,addressed_to_agentfrom mention/DM/reply-to-agent,dedupe_keyfrom the platform message id. Deliverstarts or steers the turn the subscriber runs today; retire the 180 s blocking wait.- Unaddressed group chatter lands as context (ambient buffer for the next real turn), not as a turn of its own.
Acceptance criteria
- No loss under burst — regression test: 300 hosted messages published faster than turns complete are all delivered (or recorded as context/dropped-with-reason); the bus path loses some.
- No 180 s serialization — the blocking subscriber is gone; conversations proceed independently, one turn in flight per conversation.
- Redelivery deduped — the same platform message id twice produces one turn.
- Fallback intact — with
[components] eventqueues = falsethe current bus path still works. - Diff coverage ≥ 80% — the implementing PR meets the changed-lines coverage gate (Vitest + cargo-llvm-cov, enforced by
.github/workflows/ci-fast.yml).
Related
Part of #8147. Builds on #8136 (inbound domain, tinyeventqueues v0.1.2) and tinyhumansai/tinyeventqueues#6.
Audit findings (2026-10-20)
platform/socket/event_handlers.rs:263-318is the only publisher ofChannelInboundMessage(L310). It drops messages whosechannelormessageis empty, and ignoresraw_data, so no platform message id reaches the core and nothing can dedupe today.channels/bus/subscriber.rs(283 LOC, registered atcore/runtime/subscribers.rs:307-313) runs a fullweb_chat::start_chatturn per message with a 180 s pump (L107-162).- The tinybus subscriber loop awaits
handle()inline (vendor/tinybuscrates/tinybus/src/events/subscriber.rs:149-185), so every hosted message waits behind the previous turn. SIGNAL_BUFFER = 256(tinybus/src/connection.rs:133); on lag the loop logs "subscriber lagged, skipped events" and carries on (subscriber.rs:153-159). That is silent loss.- The relay path (
channel_relay_inbound,channels/providers/relay/store.rs:29,90) already dedupes onmessage_iddurably; reuse that id convention.
Agent brief
Depends on: senamakel#514 · Blocks: #8152, senamakel#515 · Parallel with: #8149, #8150, #8151
Research first
- Which field of the socket payload (
raw_data) carries the platform message id for each hosted provider; ask the backend (backend/channel socket emitters) if it is missing. The id is theevent_id. - Whether the backend needs to send a message id at all. If so, file it in tinyhumansai/backend first.
Files to consider
- Read:
crates/openhuman-core/src/platform/socket/event_handlers.rs:263-318,channels/bus/subscriber.rs:40-283,inbound/events.rs(envelope pattern),integrations/composio/bus/trigger_subscriber.rs:223-324(routing pattern to copy) - Change:
platform/socket/event_handlers.rs,inbound/events.rs(achannelenvelope),channels/bus/subscriber.rs(kept as the direct path only), thechannel:handler ininbound/deliver/ - Tests:
platform/socket/event_handlers_tests.rs,channels/bus/subscriber_tests.rs,inbound/*_tests.rs
Workflow: implementing-an-epic step.
Subagents: tdd-implementer (Sonnet), then code-reviewer.
Gates: cargo check --manifest-path Cargo.toml · pnpm rust:clippy · cargo test -p openhuman channels::bus inbound platform::socket · pnpm rust:layout
Activity
M3gA-Mind commentedon Nov 16, 2026
Re-checked on current main: not done yet. Hosted
*:messageevents still publishChannelInboundMessageon the bus, and the subscriber still runs one turn per message. Only Composio triggers and webhooks useinbound::route.One update for whoever picks this up: the socket handling moved (#8487). The entry is now
openhuman-tinyhumans/src/socket/port.rs:330→platform/socket/event_sink.rs, notplatform/socket/event_handlers.rs.