fix(cli): prepend turn notes to multimodal messages#37080
Closed
helix4u wants to merge 1 commit into
Closed
Conversation
xxxigm
added a commit
to xxxigm/hermes-agent
that referenced
this pull request
Jun 2, 2026
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
✅ Looks Good
- Same root cause as #37081 (sibling fix) — both independently address the same
str + listTypeError. This PR's_prepend_turn_note_to_message()handles the same cases correctly. - Good test coverage: 3 test cases in existing test file, covering str, multimodal with text part, and image-only lists.
- Non-mutating: Original message preserved.
- Clean scope: Only 2 files changed (cli.py + test file), 67 additions.
⚠️ Note on Duplication
- This PR and #37081 fix the same bug independently. Both solutions are correct. The team should pick one or merge the approaches. This PR uses a simpler helper name (
_prepend_turn_note_to_messagewith args(note, message)) while #37081 uses_prepend_note_to_messagewith args(message, note).
Reviewed by Hermes Agent
Contributor
Author
|
Looks like #37081 landed on the same root cause after this one. It has the same fix shape plus a few extra edge-case tests, so I’m fine with using that one instead if maintainers prefer the more complete test coverage. |
teknium1
pushed a commit
that referenced
this pull request
Jun 2, 2026
Adopt the cleaner handling from PR #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.
1 task
changman
pushed a commit
to changman/hermes-agent
that referenced
this pull request
Jun 10, 2026
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.
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.
What does this PR do?
Fixes a CLI crash when a user switches model mid-session and then sends an image attachment as the next turn.
The CLI queues one-shot notes after commands such as
/modeland/reload-skillsso the model sees the updated session state on the next user turn. That path assumed the next message was always a string. Native image attachment routing can instead turn the next message into an OpenAI-style content-parts list, so the CLI crashed while trying to concatenate the note with a list.This adds a small helper that prepends queued CLI notes to either plain text messages or native multimodal content lists. For content lists, it prefixes the first text part, or inserts a text part before image parts when no text part exists.
Related Issue
No issue filed. Reported on Discord by privacydied.
Type of Change
Changes Made
cli.py: add_prepend_turn_note_to_message()for one-shot CLI notes on string and native multimodal messages.cli.py: use the helper for pending model-switch notes and pending skills-reload notes.tests/cli/test_cli_image_command.py: add regression coverage for text messages, native image messages with a text part, and image-only content-part lists.How to Test
/model gpt-5.5 --provider openai-codex.TypeError: can only concatenate str (not "list") to strand the image turn reaches the model.Focused local validation:
scripts/run_tests.sh -j 4 tests/cli/test_cli_image_command.py— 12 passedscripts/run_tests.sh -j 4 tests/cli/test_cli_reload_skills.py— 3 passedgit diff --check -- cli.py tests/cli/test_cli_image_command.py— cleanChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AFor New Skills
N/A
Screenshots / Logs
Original crash:
TypeError: can only concatenate str (not "list") to strCrash site was the pending model-switch note prepend path when the next message was a native multimodal content-parts list.