mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-16 09:31:37 +00:00
refactor(cli): normalize note and avoid blank lines in prepend helper
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.
This commit is contained in:
parent
a26a12ad07
commit
c35ede789f
2 changed files with 25 additions and 3 deletions
|
|
@ -14,10 +14,30 @@ def test_string_message_gets_note_prepended():
|
|||
|
||||
def test_empty_note_returns_message_unchanged():
|
||||
assert _prepend_note_to_message("hello", "") == "hello"
|
||||
assert _prepend_note_to_message("hello", " ") == "hello"
|
||||
parts = [{"type": "text", "text": "hi"}]
|
||||
assert _prepend_note_to_message(parts, "") == parts
|
||||
|
||||
|
||||
def test_note_is_stripped():
|
||||
assert _prepend_note_to_message("hello", " NOTE ") == "NOTE\n\nhello"
|
||||
|
||||
|
||||
def test_empty_string_message_yields_just_note():
|
||||
# No trailing blank lines when the user message is empty.
|
||||
assert _prepend_note_to_message("", "NOTE") == "NOTE"
|
||||
|
||||
|
||||
def test_empty_text_part_yields_just_note():
|
||||
message = [
|
||||
{"type": "text", "text": ""},
|
||||
{"type": "image_url", "image_url": {"url": "x"}},
|
||||
]
|
||||
result = _prepend_note_to_message(message, "NOTE")
|
||||
assert result[0]["text"] == "NOTE"
|
||||
assert result[1]["type"] == "image_url"
|
||||
|
||||
|
||||
def test_list_message_folds_note_into_first_text_part():
|
||||
message = [
|
||||
{"type": "text", "text": "describe this"},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue