From 018750e0cdce1af28e3113ef78a5984d6c33a961 Mon Sep 17 00:00:00 2001 From: Cesar Garcia <128240629+Chesars@users.noreply.github.com> Date: Wed, 4 Mar 2026 18:50:50 -0300 Subject: [PATCH] Update litellm/llms/openai/responses/count_tokens/transformation.py Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --- litellm/llms/openai/responses/count_tokens/transformation.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/litellm/llms/openai/responses/count_tokens/transformation.py b/litellm/llms/openai/responses/count_tokens/transformation.py index a89e8dd7438..3ee0f7eaa61 100644 --- a/litellm/llms/openai/responses/count_tokens/transformation.py +++ b/litellm/llms/openai/responses/count_tokens/transformation.py @@ -122,6 +122,8 @@ class OpenAICountTokensConfig: elif role == "assistant": # Map tool_calls to Responses API function_call items tool_calls = msg.get("tool_calls") + if content: + input_items.append({"role": "assistant", "content": content}) if tool_calls: for tc in tool_calls: func = tc.get("function", {}) @@ -131,7 +133,7 @@ class OpenAICountTokensConfig: "name": func.get("name", ""), "arguments": func.get("arguments", ""), }) - else: + elif not content: input_items.append({"role": "assistant", "content": content}) elif role == "tool": input_items.append({