Fix NameError in _handle_message_with_agent on already-sent media delivery - #72317
Closed
jorgeblanc9 wants to merge 1 commit into
Closed
jorgeblanc9 wants to merge 1 commit into
jorgeblanc9 wants to merge 1 commit into
Conversation
…already-sent responses
_history_media_paths was only defined inside the unrelated run_sync()
closure (line ~21981), not in _handle_message_with_agent, so any
already-streamed response that also needed to deliver media raised:
File "gateway/run.py", line 14561, in _handle_message_with_agent
history_media_paths=_history_media_paths,
NameError: name '_history_media_paths' is not defined
This surfaced on every message to users on the Telegram adapter as a
second "Sorry, I encountered an unexpected error." reply following the
normal streamed response.
Fix computes the same set from `history`, the pre-turn transcript
already loaded earlier in this function (used identically to
run_sync's `agent_history` for the same dedup purpose).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Contributor
Collaborator
|
Fixed on main via PR #72341 (salvaged from #72321 by @TheEpTic, merge commit c2ee503). Your fix was character-for-character identical — same |
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
_history_media_pathswas only defined inside the unrelatedrun_sync()closure (~line 21981), not in_handle_message_with_agent, so any already-streamed response that also needed to deliver media raised aNameErrorat the_deliver_media_from_response(...)call."Sorry, I encountered an unexpected error."reply following the normal streamed response.history, the pre-turn transcript already loaded earlier in_handle_message_with_agent, mirroring howrun_syncderivesagent_historyfor the same dedup purpose (so already-delivered media isn't double-counted, and media generated in the current turn is still delivered).Traceback fixed
Test plan
gateway.logon subsequent messages.history(vs. some other pre-turn history source) is the right dedup input in all call paths that reach this branch.🤖 Generated with Claude Code