fix(gateway): route watch-pattern notifications to originating session#10446
Closed
kshitijk4poor wants to merge 2 commits into
Closed
fix(gateway): route watch-pattern notifications to originating session#10446kshitijk4poor wants to merge 2 commits into
kshitijk4poor wants to merge 2 commits into
Conversation
- Populate watcher_* routing fields for watch-only processes (not just notify_on_complete), so watch-pattern events carry direct metadata instead of relying solely on session_key parsing fallback - Extract _parse_session_key() helper to dedupe session key parsing at two call sites in gateway/run.py - Add negative test proving cross-thread leakage doesn't happen - Add edge-case tests for _build_process_event_source returning None (empty evt, invalid platform, short session_key) - Add unit tests for _parse_session_key helper
Contributor
|
Merged via PR #10460. Your salvage of #9537 was cherry-picked onto current main with both contributors' authorship preserved in git log. We added a small follow-up fix for a stale |
5 tasks
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.
Summary
Salvage of #9537 by @etcircle — fixes watch-pattern notifications being delivered to whichever Discord/Telegram thread happens to be active when the queue is drained, instead of routing back to the thread that started the background process.
Root cause
_inject_watch_notification(synth_text, event)in gateway/run.py passed the current foreground event (whatever thread the user just messaged from) instead of the process's own routing metadata. So if thread A started a background process and thread B later triggered the agent, thread A's watch notification appeared in thread B.What the original PR (#9537) fixes
session_key+ routing fields (platform,chat_id,thread_id, etc.)_build_process_event_source(evt)resolves the correctSessionSourcevia 3-tier fallback: session store → session_key parse → event dict fields_inject_watch_notification()takes the queue event dict instead of the foreground event_run_process_watchercompletion path also uses_build_process_event_sourceFollow-up fixes (our commit)
watcher_platform/chat_id/thread_idare now populated for watch-pattern-only processes (previously only set whennotify_on_completewas also enabled). Without this, watch events had empty routing fields and relied solely on session_key parsing fallback._parse_session_key()helperagent:main:{platform}:{chat_type}:{chat_id}) into a shared helper used by both_notify_active_sessions_shutdownand_build_process_event_source._build_process_event_sourcereturningNoneon: empty event, invalid platform, short session key._parse_session_keytestsTest results
test_run_progress_topics.py(4 failures, noted by contributor as baseline-drifty)Based on #9537 by @etcircle. Closes #9532.