feat(ambient): observe threads under configured channels (default-on)#1220
Merged
Conversation
This comment has been minimized.
This comment has been minimized.
Ambient v1 only buffered top-level messages in a configured channel (gated on !in_thread). But most OpenAB conversation happens in auto-created threads, so ambient saw almost nothing. Now, when ambient is enabled, messages in a thread whose parent is an ambient channel are observed by default — keyed by the thread id so each thread batches independently. Only threads the bot does NOT own are observed passively; threads the bot owns keep using normal (immediate) dispatch, so there's no double-handling. @mention still discards the buffer and takes priority. No new config knob — ambient's existing 'enabled' flag is the opt-in; once on, it covers the channel and its threads. Routing is encapsulated in AmbientDispatcher::should_buffer(channel_id, in_thread, bot_owns_thread, parent_id) with unit tests.
803d307 to
5986130
Compare
This comment has been minimized.
This comment has been minimized.
Remove the !bot_owns_thread gate from should_buffer(). Bot-owned threads are now also passively observed via ambient — the bot can follow thread conversation it started without requiring @mention. An @mention still discards the buffer and triggers immediate dispatch.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
added 2 commits
June 27, 2026 13:19
Z渡 correctly identified that ambient thread observation was unreachable when the channel was only in [ambient.discord].channels but not in [discord].allowed_channels. The early return gate and detect_thread() both depended on the normal allowlist. Fix: - Always preserve thread_parent_id (not gated on detect_thread result) - Add is_structural_thread from thread_metadata for ambient routing - Compute in_ambient_context before the early return gate - Let ambient-eligible messages bypass the normal allowlist gate Also addresses reviewer suggestions: - Add startup info! log when ambient+threads is active - Add tracing::debug! on thread_parent_id parse failure
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Unconditionally setting thread_parent_id to gc.parent_id caused non-thread channels (under categories) to incorrectly populate SenderContext with the category ID as parent. Fix: split into two fields: - thread_parent_id (String): gated on has_thread_metadata, used for SenderContext and downstream - structural_parent_id (u64): gated on has_thread_metadata, used for ambient routing (avoids string parsing entirely)
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Collaborator
Author
|
LGTM ✅ — All findings from previous review rounds addressed; thread observation under ambient channels is clean and ready to merge. What This PR DoesAmbient mode v1 only buffered top-level channel messages ( How It Works
Findings
Addressing Previous Review Findings🔴 (Round 1) —
|
thepagent
approved these changes
Jun 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem does this solve?
Ambient v1 only buffered top-level messages in a configured channel — routing in
discord.rswas gated on!in_thread. But OpenAB auto-creates a thread per conversation, so ~99% of activity is in threads and ambient observed almost nothing (verified live on chaodu).Change
When ambient is enabled, messages in a thread whose parent is a configured channel are observed by default — no extra config knob (ambient's existing
enabledflag is the opt-in; once on, it covers the channel and its threads).channel_id; replies post back into that thread.Routing is encapsulated in a pure, unit-tested method:
Compatibility
No new config field. Behavior only changes for deployments that already have ambient enabled — those now also observe threads under their configured channels (the intended behavior, since channel-only observation was nearly useless given OpenAB's thread-centric UX).
Tests
should_bufferunit tests: top-level match, thread-under-ambient-channel (both owned and non-owned → buffered), parent-not-ambient negative, no-parent negative, and disabled-when-ambient-off.Docs
docs/ambient.mdupdated: threads-observed-by-default note + both owned/non-owned threads observed + per-thread-batching semantics.