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"].
This commit is contained in:
Aneesh-Fiddler 2026-04-28 12:30:39 +05:30
parent e70b0c97a4
commit c30d58f7e3

View file

@ -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):