fix(v1): preserve truncated tool result bodies - #13
Merged
ranxianglei merged 2 commits intoAug 13, 2026
Conversation
Contributor
Author
Dual-agent review按
验证: 非阻断剩余风险:尚未运行真实 OpenCode V1 端到端;空字符串 result core 按无改写处理(当前 kernel 截断结果始终非空)。V2 明确不在本 PR 范围内。 |
# Conflicts: # packages/billion-context-opencode/src/messages-v1.ts # packages/billion-context-opencode/tests/messages.test.ts
Merged
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.
范围
这是原 PR #3 在当前 monorepo 上的替代版本,仅修复 OpenCode V1 适配器:
packages/billion-context-opencode/src/messages-v1.tsmessages-v2.ts,也不对尚未验证的 OpenCode V2 结果结构作结论现象
acp-kernel的 emergency truncate 会改写tool-resultcore 的正文,但 V1 的reassemble在确认 tool-call 与 tool-result 都存活后,直接把原始 tool part 放回消息。结果是 kernel 已生成的截断正文被丢弃,完整工具输出仍会发送给模型。修复
新增统一的 V1 工具结果正文投影,并在重组时按原状态回填:
state.outputError: ${state.error};回填state.error时只移除适配层添加的一个Error:前缀metadata.interrupted === true且存在字符串输出时,读取并写回state.metadata.outputapplyToolBody仅在 kernel 正文发生实质变化时创建新 part;尾部空白差异保持原对象不变。回填通过对象展开保留原来的status、input、error、metadata、time及其他宿主字段,不会把失败状态改成成功。原有 tool call/result 配对规则保持不变;dual-shape export、持久化状态、kernel 配置和 V2 适配器均不受影响。
验证
metadata.output投影并回填npm run typecheck:通过npm run test:30/30 通过npm run build:通过acp-kernelemergency truncate 的 V1 round trip:通过(12,010 字符原结果回填为 4,064 字符的带截断标记结果)仓库现有根目录
smoke.mjs仍引用重构前的dist/index.js,而当前构建输出位于packages/billion-context-opencode/dist/index.js;这是当前master的既有路径问题,本 PR 未扩大范围修改。开发记录与审查
devlog/2026-08-13_v1-tool-result-truncation/包含REQ.md、WORKLOG.md、DESIGN.mdAGENTS.md要求交由两名独立 Agent 审查;审查结论记录在 PR 评论中