diff --git a/llmcore.py b/llmcore.py index f92932a..decc28e 100644 --- a/llmcore.py +++ b/llmcore.py @@ -510,7 +510,7 @@ class NativeOAISession: while True: yield next(gen) except StopIteration as e: content_blocks = e.value or [] if content_blocks and not (len(content_blocks) == 1 and content_blocks[0].get("text", "").startswith("Error:")): - self.history.append({"role": "assistant", "content": content_blocks}) + self.history.append({"role": "assistant", "content": [b if b.get("type") != "tool_use" else {"type": "text", "text": json.dumps(b, ensure_ascii=False)} for b in content_blocks]}) text_parts = [b["text"] for b in content_blocks if b.get("type") == "text"] content = "\n".join(text_parts).strip() tool_calls = [MockToolCall(b["name"], b.get("input", {}), id=b.get("id", "")) for b in content_blocks if b.get("type") == "tool_use"]