From afa4586e3de08d219cb3f5a15416e5db39fa157f Mon Sep 17 00:00:00 2001 From: Jiaqing Liang Date: Sat, 25 Apr 2026 13:53:08 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=5Fdrop=5Funsigned=5Fthinking=E5=AF=B9st?= =?UTF-8?q?r=20content=E5=B4=A9=E6=BA=83=20+=20=5Fto=5Fresponses=5Finput?= =?UTF-8?q?=E4=B8=A2=E5=BC=83thinking-only=20assistant=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E5=AF=BC=E8=87=B4tool=5Fcall=E8=A2=AB=E5=90=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- llmcore.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/llmcore.py b/llmcore.py index 37a3bd1..9aa440e 100644 --- a/llmcore.py +++ b/llmcore.py @@ -420,8 +420,8 @@ def _to_responses_input(messages): elif ptype == "image_url": url = (part.get("image_url") or {}).get("url", "") if url and role != "assistant": parts.append({"type": "input_image", "image_url": url}) - if len(parts) == 0 and not isinstance(content, list): parts = [{"type": text_type, "text": str(content) or '[empty]'}] - if parts: result.append({"role": role, "content": parts}) + if len(parts) == 0: parts = [{"type": text_type, "text": str(content) if not isinstance(content, list) else '[empty]'}] + result.append({"role": role, "content": parts}) pending = [] for tc in (msg.get("tool_calls") or []): f = tc.get("function", {}) @@ -537,7 +537,9 @@ class BaseSession: def _keep_claude_block(b): return not isinstance(b, dict) or b.get("type") != "thinking" or b.get("signature") def _drop_unsigned_thinking(messages): - for m in messages: m["content"] = [b for b in m["content"] if _keep_claude_block(b)] + for m in messages: + c = m.get("content") + if isinstance(c, list): m["content"] = [b for b in c if _keep_claude_block(b)] return messages class ClaudeSession(BaseSession):