fix: prefer execution-local message routing metadata#1449
fix: prefer execution-local message routing metadata#1449ilblackdragon merged 4 commits intostagingfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical bug where autonomous message deliveries could incorrectly reuse outdated routing information, leading to messages being dropped or misdirected. The changes ensure that message routing consistently uses the most relevant, execution-local metadata, improving the reliability of notifications across different channels and scenarios. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request correctly addresses a message routing bug by prioritizing execution-local metadata over shared conversation defaults. The changes are well-structured, centralizing metadata creation and applying the fix to both normal chat turns and approval-resumed operations. The new tests are comprehensive and validate the fix effectively. However, I've identified a critical logic bug in the new routing implementation within the message tool that could prevent fallback targets from being used correctly. My review includes a suggested fix for this issue.
There was a problem hiding this comment.
Pull request overview
This PR fixes a routing bug in the message built-in tool by making it prefer execution-local routing metadata (notify_channel / notify_user / notify_thread_id) over shared per-conversation defaults, preventing stale context (e.g., “gateway”) from hijacking autonomous Telegram deliveries.
Changes:
- Update
messagetool routing resolution to prioritize execution-local metadata and only fall back to shared defaults when no routing metadata exists. - Add a shared helper to build consistent chat execution metadata for both normal turns and approval resumes.
- Propagate
notify_thread_idinto gatewayOutgoingResponsethread routing so gateway broadcasts aren’t silently dropped.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/tools/builtin/message.rs |
Adjusts channel/target resolution precedence and injects notify_thread_id into gateway responses; adds focused regression tests using recording channels. |
src/agent/dispatcher.rs |
Switches chat JobContext.metadata construction to a shared helper for consistent routing. |
src/agent/thread_ops.rs |
Ensures approval-resume tool executions also get correct routing metadata via the shared helper. |
src/agent/agent_loop.rs |
Introduces chat_tool_execution_metadata() and adds unit tests for its routing-target selection behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
* fix: prefer execution-local message routing metadata * test: cover message routing fallback metadata * refactor: simplify message target resolution * fix: ignore stale channel defaults for notify user metadata
* fix: prefer execution-local message routing metadata * test: cover message routing fallback metadata * refactor: simplify message target resolution * fix: ignore stale channel defaults for notify user metadata
* fix: prefer execution-local message routing metadata * test: cover message routing fallback metadata * refactor: simplify message target resolution * fix: ignore stale channel defaults for notify user metadata
* fix: prefer execution-local message routing metadata * test: cover message routing fallback metadata * refactor: simplify message target resolution * fix: ignore stale channel defaults for notify user metadata
Summary
This fixes a Telegram delivery bug where autonomous routine or resume-driven
messagecalls could reuse stale shared chat routing context instead of the execution-localnotify_*metadata.Problem
When the last interactive turn came from the web gateway, the shared
messagetool context could stay pinned togateway. A later autonomous send withnotify_channel=telegramcould then route togatewayinstead of Telegram, and the message would be dropped because there was no gateway thread id.Fix
messageprefer execution-localnotify_channelandnotify_usermetadata over shared defaultsnotify_thread_idinto gateway deliveries so intentional gateway sends stay visible in the originating threadValidation