Skip to content
Open
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
20 changes: 10 additions & 10 deletions helpers/litellm_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,14 +517,13 @@ def parse(chunk: Any) -> ChatChunk:
message, "reasoning_content"
) or ""
parsed = {"reasoning_delta": reasoning_delta, "response_delta": response_delta}
if not response_delta:
tool_calls = _as_list(_get_value(message, "tool_calls"))
response_delta = ChatCompletionsTransport.tool_calls_text(tool_calls)
if response_delta:
parsed["response_delta"] = response_delta
parsed["_output_items"] = ChatCompletionsTransport.output_items(
tool_calls
)
tool_calls = _as_list(_get_value(message, "tool_calls"))
tool_calls_text = ChatCompletionsTransport.tool_calls_text(tool_calls) if tool_calls else ""
if tool_calls_text:
parsed["response_delta"] = tool_calls_text
Comment on lines +522 to +523

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Update the helper DOX contract

This parser precedence change is a behavioral change to helpers/litellm_transport.py, but the matching helpers/litellm_transport.py.dox.md was not updated. helpers/AGENTS.md explicitly requires, "When a helper module is added, removed, renamed, or behaviorally changed, update its matching *.py.dox.md in the same change." Please update the DOX contract to capture that tool/function calls now take precedence even when text content is present.

Useful? React with 👍 / 👎.

parsed["_output_items"] = ChatCompletionsTransport.output_items(
tool_calls
)
return parsed

@classmethod
Expand Down Expand Up @@ -1046,8 +1045,9 @@ def normalize_reasoning(reasoning: Any) -> Any:
def parse_response(cls, response: Any) -> ChatChunk:
response_delta = cls.output_text(response)
reasoning_delta = cls.reasoning_text(response)
if not response_delta:
response_delta = cls.function_calls_text(response)
function_calls_text = cls.function_calls_text(response)
if function_calls_text:
response_delta = function_calls_text
return {"reasoning_delta": reasoning_delta, "response_delta": response_delta}

@classmethod
Expand Down