From 31ae4db4dff5a66066013f0d816dd45930199036 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Wed, 17 Jun 2026 10:33:25 +0200 Subject: [PATCH] refac --- cptr/utils/ai.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cptr/utils/ai.py b/cptr/utils/ai.py index 166fbf6..c858624 100644 --- a/cptr/utils/ai.py +++ b/cptr/utils/ai.py @@ -448,7 +448,7 @@ def _to_openai_messages(messages: list[dict], instructions: str) -> list[dict]: if rc: out["reasoning_content"] = rc # Clean tool_calls: remove fc_id which is Responses-API-only - if "tool_calls" in out: + if out.get("tool_calls"): out["tool_calls"] = [ {k: v for k, v in tc.items() if k != "fc_id"} for tc in out["tool_calls"] ] @@ -554,7 +554,7 @@ async def stream_openai_completions( emitted = True yield {"type": "output", "item": item} - for tc in delta.get("tool_calls", []): + for tc in delta.get("tool_calls") or []: idx = tc["index"] if idx not in tool_calls: tool_calls[idx] = {