fix: sanitize backticks in code_run output & simplify subagent turn header
This commit is contained in:
1 parent
d626c9f02c
commit
6a3eecc07e
2 files changed
+5
-2
No files matched your search
+4
-2
@@ -46,8 +46,10 @@ def agent_runner_loop(client, system_prompt, user_input, handler, tools_schema,
|
||||
]
|
||||
turn = 0; handler.max_turns = max_turns
|
||||
while turn < handler.max_turns:
|
||||
turn += 1; md = '**' if verbose else ''
|
||||
yield f"{md}LLM Running (Turn {turn}) ...{md}\n\n"
|
||||
turn += 1; turnstr = f'LLM Running (Turn {turn}) ...'
|
||||
if handler.parent.task_dir: turnstr = f'Turn {turn} ...'
|
||||
if verbose: turnstr = f'**{turnstr}**'
|
||||
yield f"\n\n{turnstr}\n\n"
|
||||
if turn%10 == 0: client.last_tools = '' # 每10轮重置一次工具描述,避免上下文过大导致的模型性能下降
|
||||
response_gen = client.chat(messages=messages, tools=tools_schema)
|
||||
if verbose:
|
||||
|
||||
@@ -75,6 +75,7 @@ def code_run(code, code_type="python", timeout=60, cwd=None, code_cwd=None, stop
|
||||
status_icon = "✅" if exit_code == 0 else "❌"
|
||||
if exit_code is None: status_icon = "⏳"
|
||||
output_snippet = smart_format(stdout_str, max_str_len=600, omit_str='\n\n[omitted long output]\n\n')
|
||||
output_snippet = re.sub(r'`{4,}', lambda m: m.group(0)[:3] + '\u200b' + m.group(0)[3:], output_snippet)
|
||||
yield f"[Status] {status_icon} Exit Code: {exit_code}\n[Stdout]\n{output_snippet}\n"
|
||||
if process.stdout: threading.Thread(target=process.stdout.close, daemon=True).start()
|
||||
return {
|
||||
|
||||
Reference in new issue
Block a user