tune prompt tags, raise context_win defaults, simplify code_run schema desc
- ga: blank/incomplete/max_tokens retries use [ERROR]; summary tip [TIPS]; turn checkpoints [DANGER] - llmcore: default context_win 30k->35k, deepseek 70k->80k - tools_schema: shorten code_run.script description
This commit is contained in:
1 parent
d946498bcf
commit
0c2b3e0d51
3 files changed
+9
-9
No files matched your search
@@ -3,7 +3,7 @@
|
||||
"name": "code_run",
|
||||
"description": "Code executor. Prefer python. Multi-call OK, use script param. Reply code block is executed if no script arg; prefer for single call to avoid escaping. No hardcoding bulk data",
|
||||
"parameters": {"type": "object", "properties": {
|
||||
"script": {"type": "string", "description": "[Mutually exclusive] NEVER use this param when use reply code block."},
|
||||
"script": {"type": "string", "description": "script"},
|
||||
"type": {"type": "string", "enum": ["python", "powershell"], "description": "Code type", "default": "python"},
|
||||
"timeout": {"type": "integer", "description": "in seconds", "default": 60},
|
||||
"cwd": {"type": "string", "description": "Working directory, defaults to cwd"},
|
||||
|
||||
@@ -482,11 +482,11 @@ class GenericAgentHandler(BaseHandler):
|
||||
thinking = getattr(response, 'thinking', '') or ""
|
||||
if not response or (not content.strip() and not thinking.strip()):
|
||||
yield "[Warn] LLM returned an empty response. Retrying...\n"
|
||||
return self._retry_or_exit("[System] Blank response, regenerate and tooluse")
|
||||
return self._retry_or_exit("[ERROR] Blank response, regenerate and tooluse")
|
||||
if '[!!! 流异常中断' in content[-100:] or '!!!Error:' in content[-100:] or content.endswith('</summary>'):
|
||||
return self._retry_or_exit("[System] Incomplete response. Regenerate and tooluse.")
|
||||
return self._retry_or_exit("[ERROR] Incomplete response. Regenerate and tooluse.")
|
||||
if 'max_tokens !!!]' in content[-100:]:
|
||||
return self._retry_or_exit("[System] max_tokens limit reached. Use multi small steps to do it.")
|
||||
return self._retry_or_exit("[ERROR] max_tokens limit reached. Use multi small steps to do it.")
|
||||
|
||||
if self._in_plan_mode() and any(kw in content for kw in ['任务完成', '全部完成', '已完成所有', '🏁']):
|
||||
if 'VERDICT' not in content and '[VERIFY]' not in content and '验证subagent' not in content:
|
||||
@@ -575,7 +575,7 @@ class GenericAgentHandler(BaseHandler):
|
||||
else:
|
||||
tc = tool_calls[0]; clean_args = {k: v for k, v in tc['args'].items() if not k.startswith('_')} # at least one because no_tool
|
||||
summary = _c.strip() or smart_format("直接回答了用户问题" if tc['tool_name'] == 'no_tool' else f"{tc['tool_name']}, args: {clean_args}", max_str_len=40)
|
||||
next_prompt += "\n\n\n[SYSTEM] 必须在回复文本中包含<summary>!\n\n"
|
||||
next_prompt += "\n\n\n[TIPS] 必须在回复文本中包含<summary>!\n\n"
|
||||
summary = smart_format(summary.replace('\n', ''), max_str_len=80)
|
||||
self.history_info.append(f'[Agent] {summary}')
|
||||
_plan = self._in_plan_mode()
|
||||
@@ -583,9 +583,9 @@ class GenericAgentHandler(BaseHandler):
|
||||
if turn % 175 == 0 and (not _plan):
|
||||
next_prompt += f"\n\n[DANGER] Turn {turn}. Must call ask_user to summarize progress and get direction. No more blind retries."
|
||||
elif turn % 13 == 0:
|
||||
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**"
|
||||
next_prompt += f"\n\n[DANGER] 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 % 31 == 0:
|
||||
next_prompt += f"\n\n[SYSTEM] Turn {turn}. Write checkpoints/key findings/tried approaches to a **file** for future reference (not only working_checkpoint!). Avoid losing critical info."
|
||||
next_prompt += f"\n\n[DANGER] Turn {turn}. Write checkpoints/key findings/tried approaches to a **file** for future reference (not only working_checkpoint!). Avoid losing critical info."
|
||||
elif turn % 10 == 0: next_prompt += get_global_memory()
|
||||
|
||||
if _plan and turn >= 10 and turn % 5 == 0:
|
||||
|
||||
+2
-2
@@ -599,9 +599,9 @@ class BaseSession:
|
||||
self.api_key = cfg['apikey']
|
||||
self.api_base = cfg['apibase'].rstrip('/')
|
||||
self.model = cfg.get('model', '')
|
||||
default_context_win = 30000; default_cut_msg_interval = 5
|
||||
default_context_win = 35000; default_cut_msg_interval = 5
|
||||
if 'deepseek' in self.model.lower():
|
||||
default_context_win = 70000; default_cut_msg_interval = 25; self.trim_keep_rate = 0.3
|
||||
default_context_win = 80000; default_cut_msg_interval = 25; self.trim_keep_rate = 0.3
|
||||
self.context_win = cfg.get('context_win', default_context_win)
|
||||
self.maxlen_multiplier = min(max(self.context_win / default_context_win * 0.75, 1.0), 3.0)
|
||||
self.cut_msg_interval = int(default_cut_msg_interval * self.maxlen_multiplier)
|
||||
|
||||
Reference in new issue
Block a user