Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions backend/app/services/llm/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ def convert_chat_messages_to_llm_format(messages) -> list[dict]:
continue # Skip malformed tool_call records
else:
entry: dict = {"role": msg.role, "content": msg.content}
if hasattr(msg, "thinking") and msg.thinking:
entry["thinking"] = msg.thinking
if msg.role == "assistant" and hasattr(msg, "thinking") and msg.thinking:
entry["reasoning_content"] = msg.thinking
result.append(entry)

return result
Expand Down
20 changes: 20 additions & 0 deletions backend/tests/test_llm_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from types import SimpleNamespace
from app.services.llm.utils import convert_chat_messages_to_llm_format

def test_convert_chat_messages_preserves_reasoning_content():
message = SimpleNamespace(
id="message-1",
role="assistant",
content="I found the answer.",
thinking="I should inspect the evidence first.",
)

result = convert_chat_messages_to_llm_format([message])

assert result == [
{
"role": "assistant",
"content": "I found the answer.",
"reasoning_content": "I should inspect the evidence first.",
}
]