From c30d58f7e30a0568c265814d70cea2301bea51a4 Mon Sep 17 00:00:00 2001 From: Aneesh-Fiddler Date: Tue, 28 Apr 2026 12:30:39 +0530 Subject: [PATCH] fix: resolve mypy indexed assignment error in function_call handling Build the tool_call part dict separately with an explicit type annotation so mypy can track the type, avoiding the 'Unsupported target for indexed assignment' error on tool_call["parts"][0]["id"]. --- litellm/integrations/opentelemetry.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/litellm/integrations/opentelemetry.py b/litellm/integrations/opentelemetry.py index 664aeadc7c2..8084a9d0f22 100644 --- a/litellm/integrations/opentelemetry.py +++ b/litellm/integrations/opentelemetry.py @@ -1914,19 +1914,14 @@ class OpenTelemetry(CustomLogger): transformed.append({"role": role, "parts": parts}) elif item.get("type") == "function_call": # Surface tool calls from Responses API output - tool_call = { - "role": "assistant", - "parts": [ - { - "type": "tool_call", - "name": item.get("name", ""), - "arguments": item.get("arguments", ""), - } - ], + part: dict = { + "type": "tool_call", + "name": item.get("name", ""), + "arguments": item.get("arguments", ""), } if item.get("call_id"): - tool_call["parts"][0]["id"] = item["call_id"] - transformed.append(tool_call) + part["id"] = item["call_id"] + transformed.append({"role": "assistant", "parts": [part]}) return transformed def set_raw_request_attributes(self, span: Span, kwargs, response_obj):