fix(cli): TypeError concatenating queued note onto image (multimodal) message#37081
Closed
xxxigm wants to merge 3 commits into
Closed
fix(cli): TypeError concatenating queued note onto image (multimodal) message#37081xxxigm wants to merge 3 commits into
xxxigm wants to merge 3 commits into
Conversation
Sending an image to a vision model turns the user message into a list of
OpenAI-style content parts. When a /model or /reload-skills note was queued
for the same turn, the CLI did `note + "\n\n" + agent_message`, crashing the
agent thread with:
TypeError: can only concatenate str (not "list") to str
Repro: `/model gpt-5.5 --provider openai-codex`, then paste+send an image.
Add _prepend_note_to_message(), which folds the note into the first text
part of a content-parts list (or inserts a leading text part for image-only
messages) and keeps the plain-string path unchanged. Used for both the
model-switch and skills-reload notes.
Regression coverage for the multimodal-message TypeError: note folding into text parts, image-only insertion, empty-note passthrough, and unknown-shape fail-open.
Adopt the cleaner handling from PR NousResearch#37080: coerce/strip the note and skip the extra newlines when the underlying message (or text part) is empty, while keeping the safer fail-open behavior for unknown shapes.
tonydwb
approved these changes
Jun 2, 2026
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Approved ✅
Review Notes
- PR #37081 —
fix(cli): TypeError concatenating queued note onto image (multimodal) messageby @xxxigm
✅ Looks Good
- Correct fix: The root cause is clearly identified —
str + listTypeError when a queued note (/model or /reload-skills) is concatenated with a multimodal content-parts list. - Clean helper function:
_prepend_note_to_message()handles str, list (with/without text part), and unknown shapes via fail-open. Well-documented. - No mutation of original: Immutability is preserved throughout.
- Good test coverage: 6 tests covering all branches — str, empty note, list-with-text, image-only, exact repro shape, unknown shape.
- Well-scoped fix: Only 2 source files touched (cli.py + new test file), 100 additions total.
💡 Suggestions (Non-Blocking)
- Consider extracting this to a shared utility if other parts of the codebase ever need similar note-prepend behavior.
Reviewed by Hermes Agent
19 tasks
Contributor
|
Merged via #37173 (#37173). Your three commits were rebased onto current main with your authorship preserved in git log (043350d, a26a12a, c35ede7). Thanks for the clean fix and the thorough edge-case tests. cc @helix4u who hit the same root cause in #37080 and closed his own in favor of this one's coverage — both credited. |
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
Fixes a crash in the interactive CLI agent thread:
Related Issue:
No issue filed. Reported on Discord by privacydied ( https://discord.com/channels/1053877538025386074/1511137568224444426/1511137568224444426 ).
Repro:
hermes/model gpt-5.5 --provider openai-codex(queues a pending model-switch note)Root cause: attaching an image to a vision-capable model turns the user message into a list of OpenAI-style content parts (
text+image_url). The queued/model(and/reload-skills) note was prepended withnote + "\n\n" + agent_message, which isstr + list→TypeError. The adjacent_voice_prefixblock already guarded withisinstance(message, str), but these two note-prepend blocks did not.Fix: add
_prepend_note_to_message()that:str→f"{note}\n\n{message}"(unchanged behavior)list→ folds the note into the first{"type": "text"}part, or inserts a leading text part for image-only messagesUsed for both the model-switch and skills-reload notes. Original message is not mutated.
Test plan
scripts/run_tests.sh tests/cli/test_prepend_note_to_message.py— covers str/list folding, image-only insertion, empty-note passthrough, unknown-shape fail-open, and the exact multimodal repro shape.