fix(prompt_builder): tool-role history loss + typo breaking tool_calls#27
Open
youyou752 wants to merge 11 commits into
Open
fix(prompt_builder): tool-role history loss + typo breaking tool_calls#27youyou752 wants to merge 11 commits into
youyou752 wants to merge 11 commits into
Conversation
修改docker和添加图片生成功能
修改了claude code 中长任务工具调用
…es-qwen-code Add Responses API compatibility and improve Qwen Code tool-call handling
Two fixes: 1. line 419: typo _looks_like_opencode_system_prompt -> looks_like_opencode_system_prompt (NameError crashed every tools request with HTTP 500) 2. default client_profile (non qwen-code / non claude-code) with tools: max_history_msgs 8->32; tool-role messages no longer count against msg_count; tool_result_limit 300->3000 chars. Fixes agent loops losing tool history after ~5 turns.
Owner
|
有冲突我就先不拉, 你们说的我都有改,而且我加了很多新的功能,感谢佬 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
在 v0.5.0+ 用 OpenAI 兼容 tools 接口跑 agent loop 时发现两个 bug。
Bug 1:
prompt_builder.py:419typo → NameError → HTTP 500每一个带
tools=[]的/v1/chat/completions请求都会 NameError 崩,回 500。Bug 2:默认 profile tool-loop 死在第 5 轮
非 qwen-code / claude-code 的通用客户端(Cline、Continue、自写 agent等)命中 default profile:
max_history_msgs = 8:5 轮 tool call 以后早期上下文全部被截tool_result_limit = 300 chars:几行 JSON 就被截断,模型看不到完整 tool outputrole=="tool"的消息跟 assistant/user 一起计入msg_count,虽然 tool-role msg 它们是上一步 assistant tool_call 的回收数据,本不应几乎平级被简他结果模型在第 6-7 轮就看不到自己前几轮调用的 tool 返回值,开始幻觉/重复调用/提前 finish。
修复
line 419:_looks_like_opencode_system_prompt → looks_like_opencode_system_promptline 442-443:default profile 开 tools 时max_history_msgs 8 → 32,tool_result_limit 300 → 3000line 476:role=="tool"的消息不再计入msg_count(仍受字符 budget 约束)测试
用 天气 + compare_numbers 两个工具搭 7 步任务回放:
另用真实 sandbox shell agent (shell/write_file/read_file/finish 4 工具)跑了个分析 docker log 写报告的任务,7 轮 25s 0 错误完成。
影响面
QWEN_CODE_OPENAI_PROFILE/CLAUDE_CODE_OPENAI_PROFILE不受影响)