From 274d47f35ffbdef21b96a4981be4ec1f70920cf3 Mon Sep 17 00:00:00 2001 From: Liang Jiaqing Date: Wed, 22 Apr 2026 17:15:12 +0800 Subject: [PATCH] Normalize OAI messages before conversion and update tool-call prompt --- llmcore.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/llmcore.py b/llmcore.py index 604f97c..7f64f82 100644 --- a/llmcore.py +++ b/llmcore.py @@ -623,10 +623,9 @@ class NativeClaudeSession(BaseSession): return MockResponse(thinking, content, tool_calls, str(content_blocks)) class NativeOAISession(NativeClaudeSession): - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) def raw_ask(self, messages): """OpenAI streaming. yields text chunks, generator return = list[content_block]""" + messages = _fix_messages(messages) msgs = ([{"role": "system", "content": self.system}] if self.system else []) + _msgs_claude2oai(messages) return (yield from _openai_stream(self.api_base, self.api_key, msgs, self.model, self.api_mode, temperature=self.temperature, max_tokens=self.max_tokens, @@ -893,17 +892,17 @@ class MixinSession: THINKING_PROMPT_ZH = """ ### 行动规范(持续有效) -每次回复请遵循: +每次回复请先在回复文字中包含: 1. 在 标签中先分析现状和策略 2. 在 中输出极简单行(<30字)物理快照:上次结果新信息+本次意图。此内容进入长期工作记忆。 -3. 然后才能输出工具调用 +\n**除了最后回答,必须进行工具调用!** """.strip() THINKING_PROMPT_EN = """ ### Action Protocol (always in effect) -For every reply, follow these steps: +The reply body should first include: 1. Analyze the current situation and strategy inside 2. Output a minimal one-line (<30 words) physical snapshot in : new info from last result + current intent. This goes into long-term working memory. -3. Then output tool calls +\n**Tool calls are required for every turn except the final answer!** """.strip() class NativeToolClient: