chore: simplify summary, english turn hints, reasoning field compat
This commit is contained in:
1 parent
2057d86ac4
commit
3dcca65348
2 files changed
+8
-6
No files matched your search
@@ -553,7 +553,7 @@ class GenericAgentHandler(BaseHandler):
|
||||
else:
|
||||
tc = tool_calls[0]; tool_name, args = tc['tool_name'], tc['args'] # at least one because no_tool
|
||||
clean_args = {k: v for k, v in args.items() if not k.startswith('_')}
|
||||
summary = f"调用工具{tool_name}, args: {clean_args}"
|
||||
summary = f"{tool_name}, args: {clean_args}"
|
||||
if tool_name == 'no_tool': summary = "直接回答了用户问题"
|
||||
next_prompt += "\n\n\n[SYSTEM] 必须在回复文本中包含<summary>!\n\n"
|
||||
summary = smart_format(summary.replace('\n', ''), max_str_len=40)
|
||||
@@ -562,9 +562,11 @@ class GenericAgentHandler(BaseHandler):
|
||||
_plan = self._in_plan_mode()
|
||||
|
||||
if turn % 175 == 0 and (not _plan):
|
||||
next_prompt += f"\n\n[DANGER] 已连续执行第 {turn} 轮。必须总结情况进行ask_user,不允许继续重试。"
|
||||
next_prompt += f"\n\n[DANGER] Turn {turn}. Must call ask_user to summarize progress and get direction. No more blind retries."
|
||||
elif turn % 7 == 0:
|
||||
next_prompt += f"\n\n[SYSTEM] 已连续执行第 {turn} 轮。建议调用update_working_checkpoint保存关键上下文。禁止无效重试;若无有效进展,必须切换策略:1. 探测物理边界 2. **重读相关SOP**"
|
||||
next_prompt += f"\n\n[SYSTEM] Turn {turn}. Call update_working_checkpoint to save key context. Stop ineffective retries; if no progress, switch strategy: 1) Probe physical boundaries 2) **Re-read relevant SOPs**"
|
||||
elif turn % 25 == 0:
|
||||
next_prompt += f"\n\n[SYSTEM] Turn {turn}. Write checkpoints/key findings/tried approaches to a file for future reference. Avoid losing critical info."
|
||||
elif turn % 10 == 0: next_prompt += get_global_memory()
|
||||
|
||||
if _plan and turn >= 10 and turn % 5 == 0:
|
||||
|
||||
+3
-3
@@ -274,8 +274,8 @@ def _parse_openai_sse(resp_lines, api_mode="chat_completions"):
|
||||
except: continue
|
||||
ch = (evt.get("choices") or [{}])[0]
|
||||
delta = ch.get("delta") or {}
|
||||
if delta.get("reasoning_content"):
|
||||
reasoning_text += delta["reasoning_content"]
|
||||
if rc := delta.get("reasoning_content") or delta.get("reasoning", ""):
|
||||
reasoning_text += rc; yield rc
|
||||
if delta.get("content"):
|
||||
text = delta["content"]; content_text += text; yield text
|
||||
for tc in (delta.get("tool_calls") or []):
|
||||
@@ -334,7 +334,7 @@ def _parse_openai_json(data, api_mode="chat_completions"):
|
||||
else:
|
||||
_record_usage(data.get("usage") or {}, api_mode)
|
||||
msg = (data.get("choices") or [{}])[0].get("message", {})
|
||||
reasoning = msg.get("reasoning_content", "")
|
||||
reasoning = msg.get("reasoning_content") or msg.get("reasoning", "")
|
||||
if reasoning:
|
||||
blocks.append({"type": "thinking", "thinking": reasoning})
|
||||
content = msg.get("content", "")
|
||||
|
||||
Reference in new issue
Block a user