Repository navigation
fix(core): recover compaction from empty text history - #5214
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: bd078f0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
commit: |
5 of 6 tasks
7Sageer
pushed a commit
that referenced
this pull request
Nov 23, 2026
* refactor(core): run loop turns on an independent state machine (#5211) * refactor(core): run loop turns on an independent state machine - add an actor runtime for loop and turn execution - unify turn hooks and asynchronous lifecycle settlement - simplify loop contracts and cover turn lifecycle behavior * fix(core): park recorded notifications until intake * fix(core): settle forced aborts past stuck hooks and tools * docs(core): document loop emitted events and public API * fix(agent-core-v2): skip onDidFinishStep hooks for aborted steps * refactor(llm): legalize deferred tools in the resolver (#5142) * refactor(core): unify llm event stream and harden behavior tests - unify run boundaries, request summaries, delta events, retries, and outcomes - migrate Loop, agent-core-v2, and klient consumers to the unified event vocabulary - add aimock-backed transport coverage and restore historical LLM behavior tests - update the Nix dependency hash and affected snapshots * refactor(llm): legalize deferred tools in the resolver - strip deferred metadata during legalize for models without dynamic loading - stop convert from dropping deferred tools and dedupe declarations with top-level priority - merge protocol capabilities once at the encode pipeline entry - remove deferred tools in the dynamic loop resolver and announce their names first * refactor(llm): unify deferred tool request views - remove dynamic-only request branching from ToolSelect resolution - keep non-dynamic system schemas out of top-level tools - preserve baseline tools for side requests before capability shaping * refactor(llm): share the tool select request view - reuse deferred shaping in the resolver and request preview - preserve initial tool announcements in request previews - cover preview parity with deferred tools * refactor(llm): strip deferred metadata in tool select Remove deferred metadata from non-disclosure ToolSelect request views while preserving the loop baseline. Keep core legalization as the fallback for requests that bypass ToolSelect. * refactor(llm): contain tool disclosure in resolver * refactor(llm): hash the full request tool list - compute toolsHash over every input tool, including deferred ones - note the resolver and legalization timing on the llm run events * refactor(llm): remove the tool select experimental flag - drop the tool-select flag, env var, and [experimental] config entry - gate deferred tool disclosure solely on model capabilities - remove the desktop forced env and update the MCP and env-var docs - cover mid-loop active-tool requests with an empirical loop test * test(desktop): assert browser tool disclosure in the request view The previous assertions called loadableToolsAnnouncement() with no arguments, a calling form no production code uses; the model-facing disclosure is built per request by the ToolSelect resolver. Assert the request view instead: requestTools strips the deferred browser tool from the request tool list, shapeHistory injects the snapshot announcement naming it, and a reminder step after the control switch turns the removal into a <tools_removed> delta. * fix(core): recover compaction from empty text history (#5214) * test(core): cover empty text request recovery * fix(core): clean empty text before request encoding * chore: add empty text recovery changesets * test(core): cover cross-provider signed empty text * fix(core): drop unsupported signed blank text
7Sageer
pushed a commit
that referenced
this pull request
Nov 23, 2026
…edgement (#5239) * refactor(core): run loop turns on an independent state machine (#5211) * refactor(core): run loop turns on an independent state machine - add an actor runtime for loop and turn execution - unify turn hooks and asynchronous lifecycle settlement - simplify loop contracts and cover turn lifecycle behavior * fix(core): park recorded notifications until intake * fix(core): settle forced aborts past stuck hooks and tools * docs(core): document loop emitted events and public API * fix(agent-core-v2): skip onDidFinishStep hooks for aborted steps * refactor(llm): legalize deferred tools in the resolver (#5142) * refactor(core): unify llm event stream and harden behavior tests - unify run boundaries, request summaries, delta events, retries, and outcomes - migrate Loop, agent-core-v2, and klient consumers to the unified event vocabulary - add aimock-backed transport coverage and restore historical LLM behavior tests - update the Nix dependency hash and affected snapshots * refactor(llm): legalize deferred tools in the resolver - strip deferred metadata during legalize for models without dynamic loading - stop convert from dropping deferred tools and dedupe declarations with top-level priority - merge protocol capabilities once at the encode pipeline entry - remove deferred tools in the dynamic loop resolver and announce their names first * refactor(llm): unify deferred tool request views - remove dynamic-only request branching from ToolSelect resolution - keep non-dynamic system schemas out of top-level tools - preserve baseline tools for side requests before capability shaping * refactor(llm): share the tool select request view - reuse deferred shaping in the resolver and request preview - preserve initial tool announcements in request previews - cover preview parity with deferred tools * refactor(llm): strip deferred metadata in tool select Remove deferred metadata from non-disclosure ToolSelect request views while preserving the loop baseline. Keep core legalization as the fallback for requests that bypass ToolSelect. * refactor(llm): contain tool disclosure in resolver * refactor(llm): hash the full request tool list - compute toolsHash over every input tool, including deferred ones - note the resolver and legalization timing on the llm run events * refactor(llm): remove the tool select experimental flag - drop the tool-select flag, env var, and [experimental] config entry - gate deferred tool disclosure solely on model capabilities - remove the desktop forced env and update the MCP and env-var docs - cover mid-loop active-tool requests with an empirical loop test * test(desktop): assert browser tool disclosure in the request view The previous assertions called loadableToolsAnnouncement() with no arguments, a calling form no production code uses; the model-facing disclosure is built per request by the ToolSelect resolver. Assert the request view instead: requestTools strips the deferred browser tool from the request tool list, shapeHistory injects the snapshot announcement naming it, and a reminder step after the control switch turns the removal into a <tools_removed> delta. * fix(core): recover compaction from empty text history (#5214) * test(core): cover empty text request recovery * fix(core): clean empty text before request encoding * chore: add empty text recovery changesets * test(core): cover cross-provider signed empty text * fix(core): drop unsupported signed blank text * fix(agent-core-v2): truncate foreground output in bash detach acknowledgement (#5218)
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.
Requirement or Bug
Web 2.7.1 用户使用 Kimi K3.1 Pro 执行 compact 时,历史消息中的空
text会使压缩请求被 HTTP 400Invalid request: text content is empty拒绝,导致会话无法完成压缩。这个 PR 让包含空文本的旧会话在编码阶段得到清理,并让服务端的 empty-text 拒绝进入已有的 strict projection recovery。相邻的 #4300 处理空工具结果;本 PR 覆盖普通 user/assistant 空文本、跨 provider 的签名空文本,以及对应的恢复分类。
Bug Reproduction Steps
text,或从 Gemini 会话带来带thought_signature_b64的空文本。content: ""或含空textblock 的请求,服务端返回上述 400;该错误被归类为普通status,不会触发 strict recovery。修复后,空内容在发送前被移除,残余结构错误会进入 strict projection 重试。Root Cause
共享
runPipeline没有接入已有的cleanMessages(),所以空文本能一直到达协议出口。Gemini 所需的签名空文本也被无差别保留到其他协议,但这些协议不会保留其签名元数据,仍会发出空块。同时,
text content is empty不在结构错误识别列表中,导致已有 strict projection recovery 无法接管。这个 PR 是在共享编码与错误分类层修复根因,不是迁移会话数据或针对单一 provider 的绕过。Code Changes
legalize-structure,复用现有清理逻辑;工具调用、动态工具声明、媒体和有意义的文本继续保留,空工具结果仍由现有渲染逻辑生成非空状态文本。text content is empty识别为request_structure,复用现有 strict projection recovery,不新增 compact 专用恢复循环。@moonshot-ai/corepatch changeset。Behavior Changes and Affected Users
content: ""或空textblockthought_signature_b64的空文本text content is emptystatus,不进入 strict recoveryrequest_structure,执行一次 strict projection 重试验证结论:目标回归覆盖普通空白、签名空白、空 assistant、工具调用保留、空工具结果占位和错误分类;独立只读复审无 P0/P1/P2 发现。未做真实 provider 的 compact 端到端验证;最终基线的完整 core 套件交由 PR CI 验证。
验证明细
loop-refact基线:Kimi/OpenAI、Google GenAI、错误分类目标测试 3 passed / 60 skipped。packages/core与packages/agent-core-v2TypeScript 检查通过。pnpm lint通过,包括 comments、oxlint、import boundaries、guards、ratchet、test-doubles、quarantine 和 instructions。pnpm run check:duplication 3c7b8ecc7a8e85d2d06c38a6681ca4036288d876通过,无新增重复。Checklist
/approve).(无外部 issue;问题、复现和相关工作已在上方说明。)gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.