Skip to content

fix: preserve empty string message content in chat requests - #714

Open
r7mekmy4g67w6l wants to merge 6 commits into
ollama:mainfrom
r7mekmy4g67w6l:fix/preserve-empty-message-content
Open

fix: preserve empty string message content in chat requests#714
r7mekmy4g67w6l wants to merge 6 commits into
ollama:mainfrom
r7mekmy4g67w6l:fix/preserve-empty-message-content

Conversation

@r7mekmy4g67w6l

Copy link
Copy Markdown

Summary

  • _copy_messages previously filtered with truthiness (if v), so empty-string content was dropped.
  • Tool / assistant messages with content="" lost their content field before the request was sent.
  • Keep all non-None fields; add a regression test.

Why

Tool-calling loops often append tool results that can be an empty string. Dropping content changes the payload sent to /api/chat and can confuse models that expect a tool message to always include content.

Test plan

  • Manual assertion that empty content survives _copy_messages and ChatRequest.model_dump(exclude_none=True)
  • Added est_copy_messages_preserves_empty_string_content

Signed-off-by: r7mekmy4g67w6l <r7mekmy4g67w6l@users.noreply.github.com>
Signed-off-by: r7mekmy4g67w6l <r7mekmy4g67w6l@users.noreply.github.com>
Signed-off-by: r7mekmy4g67w6l <r7mekmy4g67w6l@users.noreply.github.com>

Normalize to LF so the PR shows the real 1-line change.
Signed-off-by: r7mekmy4g67w6l <r7mekmy4g67w6l@users.noreply.github.com>

Normalize to LF so the PR shows the real 1-line change.
Signed-off-by: r7mekmy4g67w6l <r7mekmy4g67w6l@users.noreply.github.com>

Normalize to LF so the PR shows the real 1-line change.
Signed-off-by: r7mekmy4g67w6l <r7mekmy4g67w6l@users.noreply.github.com>

Normalize to LF so the PR shows the real 1-line change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant