fix(gateway): preserve media attachments in /steer and /goal kickoff events - #57946
Open
Ahmett101 wants to merge 2 commits into
Open
fix(gateway): preserve media attachments in /steer and /goal kickoff events#57946Ahmett101 wants to merge 2 commits into
Ahmett101 wants to merge 2 commits into
Conversation
…cal and remote mode (NousResearch#57911) A bare-new-session (Cmd+N without a project scope) in remote mode used to inherit the remembered cwd under workspaceCwdKey()'s remote variant — i.e. the last project the user attached to on that backend. Symptom: Cmd+N landed on the wrong project's workspace (e.g. a configuration discussion thread opened in the tradingview directory). The remote branch in workspaceCwdForNewSession is the entire bug class: - It overrides the configured-default-pre-attaches rule, so users who configured an explicit default didn't get it under remote mode either. - The bare-new-session path has no notion of "remember where I was" — that's startSessionInWorktree's job. The remembered cwd is only meant to assist resume/restore (ensureDefaultWorkspaceCwd, which keeps its remote-keyed sticky seed and is unaffected by this change). Drop the mode === 'remote' early return and route both modes through getConfiguredDefaultProjectDir(), matching the proposed fix in the issue. Test: the existing 'keeps remote workspace memory separate from local and other remotes' case set the local key then switched connection to remote, so under the buggy code it returned '' regardless — it never gated the regression. Add a remote-key repro and a symmetric explicit-default test so the fix is observable from the suite.
…events (NousResearch#57928) When a Telegram user invoked /steer, /goal, /subgoal with an attached file (photo, document, audio), the attachment was silently dropped because only the slash-command args string was extracted from the MessageEvent and forwarded. /queue already carries media_urls / media_types / reply_to_* through the synthesized MessageEvent (NousResearch#20906); /steer and /goal used the same MessageEvent(...) construction but lost every non-text field. /subgoal doesn't synthesize events so it was a false positive in the report — skipped. Two layered fixes: 1. gateway/run.py (L9010-9050, /steer): before extracting steer_text, snapshot media_urls / media_types from the original event. For the fallback 'no agent / pending sentinel' MessageEvent, copy them through alongside reply_to_*. For the 'running agent' path the AIAgent.steer() API is text-only by contract — append an '[Attached files: ...]' hint to the steered text so the model knows which paths to read_file(). The hint mirrors the shape the normal message pipeline uses to surface attachment paths. 2. gateway/slash_commands.py (L2271-2287, /goal kickoff MessageEvent): mirror the same passthrough shape as /queue, and only switch message_type away from MessageType.TEXT when there is actually a media attachment (no fake attachment metadata on text-only /goal). Tests: tests/gateway/test_steer_command.py gains three — the 'running-agent steers with [Attached files:] hint', the 'pending sentinel fallback preserves all media fields', and a regression guard that without media the steer text is just the command args. New tests/gateway/test_goal_command_media_passthrough_57928.py covers the /goal kickoff: with-attachment preserves media; without-attachment stays MessageType.TEXT. 53/53 in the slash-command family pass.
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
When a Telegram user invokes
/steeror/goalwith an attached file (document, photo, audio) captioned with the slash command, the file is silently dropped because onlyevent.get_command_args()is forwarded./queuealready preservesmedia_urls/media_types/reply_to_*in its synthesizedMessageEvent(#20906);/steerand/goalbuilt the sameMessageEvent(...)pattern but discarded every non-text field./subgoalwas reported as affected, but its handler does not enqueue a syntheticMessageEvent— it only mutates the goal manager. No fix seam, out of scope.Changes
gateway/run.py(/steer, ~L9010-9050): snapshotmedia_urls/media_typesonce at the top of the/steerbranch, copy them through both fallbackMessageEventconstructions (pending sentinel + no-agent), and append an[Attached files: <p1>, <p2>]hint tosteer_texton the running-agent path so the model canread_file()the listed paths.AIAgent.steer()is text-only by contract (see run_agent.py:2719), so the API is unchanged.gateway/slash_commands.py(/goalkickoff, ~L2269-2287): mirror the passthrough shape/queueuses, copy the same field set, and only flipmessage_typeaway fromMessageType.TEXTwhen there is real media.tests/gateway/test_steer_command.py: 3 new tests — running-agent carries[Attached files: …]hint; pending-sentinel fallback preserves media+reply fields; no-media regression guard so a plain/steer hellostill steers with just"hello".tests/gateway/test_goal_command_media_passthrough_57928.py(new): 2 tests —/goal <text>with attachment preserves media on kickoff;/goal <text>without attachment staysMessageType.TEXT.How to Test
pytest tests/gateway/test_steer_command.py \ tests/gateway/test_goal_command_media_passthrough_57928.py -qAll 10 tests in those two files pass (5 pre-existing + 5 new). The full slash-command family (10 files, 104 tests) stays green.
Risk & Impact
Low. Pure passthrough: the same field set
/queuealready trusts since #20906. No public API change (AIAgent.steer()signature unchanged). Worst-case regression: a user who attached a file to/steerand expected a path-free prompt body will now see[Attached files: …]in the steer text — but that case is the bug itself.Closes #57928