四处复现过的毛病:上下文尺子漏了 tool_calls 参数、500 不重试、/resume 不认原话、检索建图两两比较 - #1
Merged
Merged
Conversation
一次全仓复核里挑出来的四条,每条都先写判据、看它红,再改。
一、上下文预算只量了一半
_ctx_chars 只数 content,而 write_file 写的整份文件躺在 tool_calls[].arguments 里。
实测 6 次 write_file、每次 1.8 万字符:真实历史 123,922 字符,它报 73。
压缩永远不触发,_prune_old_tool_results 也只剪 role=tool —— 写得越多的任务
越是每一步把所有写过的文件原样重发,直到 400 超长。
· _msg_chars:正文 + 参数,_ctx_chars 和 _tail_start 都走它
· 窗口外的大块参数跟旧工具输出同一条规则剪掉;剪完仍是合法 JSON、path 留着,
spawn_subagent 不剪(理由同它的返回不剪)
· 连写 12 个 6000 字符文件的一轮:最大一次请求 84,602 → 压在 COMPACT_AT 以下
· SECURITY.md 那条「会话文件不保证是原始内容」补上参数这一半
二、500 一次就放弃
重试判据是在报错文本里找关键词,表里有 502/503 没有 500。用真 openai 异常对象核对:
500 试 1 次;504 的 "Gateway Timeout" 被记成读超时、只多给一次;
429「余额不足」反而重试满三趟。FINDINGS 七十八节那个任务三趟死法正是 500、500、429。
· 按 status_code 认 408/429/5xx,文本表留着给没有状态码的异常
· 有状态码就不算读超时
· 余额/额度耗尽直接报(只认明确写法 —— Gemini 每分钟限流的文本也是
"exceeded your current quota",那是真限流,照样重试)
· 认 Retry-After / retry-after-ms,封顶 60s;没有就 2/4/8s(原来 1/2s)
· 四条走真退避的旧判据补上 sleep 桩,全套从 12s 回到 9s
三、REPL 里 /resume 不认人的原话
启动时 --resume 会 _human_asks 重建 state["asks"],REPL 里 /resume 和
/delete 掉当前会话这两条路没有:切过去之后 asks 还是上一个会话的对象,
续上的会话一压缩人的原话就被转述掉,「点名要过」也拿上一个会话的话去比。
抽成 _adopt_history,三条路都走它。旧判据只查「repl 里调过 _human_asks」,
启动那一处就满足了;新判据真把 REPL 跑一遍。
四、检索建图两两比较
_edges 对全部节点两两求交,每轮顶层、复盘、子 agent 各建一遍,节点数随会话数涨。
实测每次 recall():500 个会话 0.23s,1500 个 1.3s,3000 个 4.6s。
改成关键词倒排,只数真共享关键词的那几对;每行邻居按下标升序,跟原来逐项相同
(_activate 按这个顺序累加浮点,顺序一变同分的可能换位)。
FINDINGS 句子做语料:3000 个会话 recall() 1540ms → 319ms,输出逐字相同。
336 判据:334 过、5 skip、1 xfail(原有);py3.10 / 3.11 / 3.13 都跑过。
三个 selfcheck 绿。
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014gdkHx6rLSMVsUmQiErVSn
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.
一次全仓复核里挑出来的四条。每条都先写判据、确认它在旧代码上红,再改。
一、上下文预算漏了工具调用参数
_ctx_chars只数content,而write_file写的整份文件放在tool_calls[].arguments里。6 次 write_file、每次 1.8 万字符:真实历史 123,922 字符,_ctx_chars报 73。压缩永远不触发,_prune_old_tool_results也只剪role=tool。_msg_chars(正文 + 参数),_ctx_chars和_tail_start都走它path保留,spawn_subagent不剪COMPACT_AT以下SECURITY.md:会话文件里的旧write_file内容现在也是打桩后的版本二、500 不重试
重试判据是在报错文本里找关键词,表里有 502/503,没有 500。用真 openai 异常对象核对过:500 试 1 次;504 的 "Gateway Timeout" 被记成读超时,只多给一次;429「余额不足」反而重试满三趟。
status_code认 408/429/5xx;没有状态码的异常照旧靠文本表Retry-After/retry-after-ms,封顶 60s;没有就 2/4/8s(原来 1/2s)sleep桩,全套约 12s → 9s三、REPL 里
/resume不认用户原话启动时
--resume会用_human_asks重建state["asks"];REPL 里的/resume、/delete掉当前会话这两条路没有。抽成_adopt_history,三条路都走它。旧判据只查「repl 里调过_human_asks」(启动那一处就满足了),新判据真把 REPL 跑一遍。四、检索建图两两比较
recall._edges对全部节点两两求交。实测每次recall():500 个会话 0.23s,1500 个 1.3s,3000 个 4.6s。改成关键词倒排,每行邻居按下标升序,跟原来逐项相同(_activate按这个顺序累加浮点)。FINDINGS 句子做语料:3000 个会话 1540ms → 319ms,输出逐字相同。验证
agent.py/drawiocheck.py/drawio_layout.py三个 selfcheck 绿TALOS_SWEEP=1守卫变异全扫通过(没有摘掉之后全套照绿的守卫)🤖 Generated with Claude Code
https://claude.ai/code/session_014gdkHx6rLSMVsUmQiErVSn
Generated by Claude Code