Skip to content

Commit fc484a7

Browse files
committed
fix(models): preserve LiteLLM reasoning fragments
1 parent fd8b492 commit fc484a7

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

src/google/adk/models/lite_llm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,7 @@ async def _content_to_message_param(
925925
):
926926
reasoning_texts.append(_decode_inline_text_data(part.inline_data.data))
927927

928-
reasoning_content = _NEW_LINE.join(text for text in reasoning_texts if text)
928+
reasoning_content = "".join(text for text in reasoning_texts if text)
929929
return ChatCompletionAssistantMessage(
930930
role=role,
931931
content=final_content,

tests/unittests/models/test_litellm.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4898,6 +4898,23 @@ async def test_content_to_message_param_non_anthropic_uses_reasoning_content():
48984898
assert "thinking_blocks" not in result
48994899

49004900

4901+
@pytest.mark.asyncio
4902+
async def test_content_to_message_param_preserves_reasoning_fragments():
4903+
content = types.Content(
4904+
role="model",
4905+
parts=[
4906+
types.Part(text="Step 1: ", thought=True),
4907+
types.Part(text="inspect", thought=True),
4908+
types.Part(text=".", thought=True),
4909+
types.Part(text="Done"),
4910+
],
4911+
)
4912+
4913+
result = await _content_to_message_param(content, model="openai/gpt-4o")
4914+
4915+
assert result.get("reasoning_content") == "Step 1: inspect."
4916+
4917+
49014918
@pytest.mark.asyncio
49024919
async def test_anthropic_thinking_blocks_round_trip():
49034920
"""End-to-end: thinking_blocks in response → Part → thinking_blocks out."""

0 commit comments

Comments
 (0)