Skip to content

Skip Todo fold prefetch when baseline metering is unavailable - #9669

Open
loopx-agent wants to merge 1 commit into
mainfrom
codex/grid-fold-token-fallback-20261201
Open

loopx-agent wants to merge 1 commit into
mainfrom
codex/grid-fold-token-fallback-20261201

Conversation

@loopx-agent

Copy link
Copy Markdown
Collaborator

Outcome

The opt-in Todo fold reads the next observation only when a measured baseline and tokenizer provenance are available. With the optional tokenizer missing, it keeps the original context and reports unavailable counts. An instrumented zero-token delta still appears as zero. The TypeScript receipt owner keeps the existing settlement, binding, and savings checks.

Verification

  • The regression failed on the parent because it started one read-only observation subprocess with an unmeasurable baseline. The two affected Python suites pass 44 cases on this branch.
  • Ran the existing benchmark worker and real Core CLI in isolated workspaces using a fixture Codex executable. On the feat(control-plane,dsh-plugin): wire real Todo settlement semantic-unit fold #9503 integration candidate, the extra observation count went from one to zero with tiktoken absent. The Todo still validated and settled exactly once. Omitted and disabled profiles emitted no fold receipt.
  • With measured inputs, the next Todo resumed the fixture session and received the folded receipt, the prefetch output, and its own context. A changed anchored item kept its raw text. The same-scope fixture with replacement disabled sent about 11.2k tokens and the folded request sent about 8.6k. This measures rendered host input for the fixture.
  • The configured mypy target and focused Ruff checks passed. The standard premerge gate reports one advisory failure from the repository-wide vocabulary inventory. The unchanged target reproduces the same failure, with 54 conflicting definitions against the limit of 52.

The patch covers the shared fold evaluator. Native Codex rollout-span metering and benchmark outcome qualification stay tracked with the host integration in #9503.

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh
Request changes conclusion (author-owned PR; GitHub blocks formal self-review)

[P2] 在启动观测前确认 tokenizer 计量来源可用。 提供基线与替换计数,但 tokenizer 元数据为空字典,或 encoding 与折叠要求不匹配。可选读取仍启动,随后 TypeScript 因计量不可用保留原文。 Python 以 tokenizer 映射是否存在放行进程。TypeScript 根据非空 name、encoding 和预期 encoding 确认计量来源。 当前头的已安装 Core CLI 在两个输入上都实际启动 1 次只读观测,最终回执仍为 token_estimation_unavailable。将 subprocess 前的计量准入绑定到同一份可验证 tokenizer 规则;保留已完成观测的读回,并加入空对象、编码不符与有效计数对照。 进程门控 TypeScript 计量规则

动机 / Motivation

启用 Todo 级上下文折叠的宿主,需要在工作结束后决定是否值得读下一段观测并替换原始上下文。 提供基线与替换计数,但 tokenizer 元数据为空字典,或 encoding 与折叠要求不匹配。可选读取仍启动,随后 TypeScript 因计量不可用保留原文。 隔离 Core wheel 使用真实 quota context-hook。缺基线或 tokenizer 整体缺席时,观测进程由 1 降为 0。空字典与编码冲突时两版均启动 1 次,新头仍回 KeepRaw。 本次覆盖隔离 Core CLI 的 hook 及 TypeScript 回执。原生 rollout-span 计量和实际模型收益仍随 #9503 验收。

改动思路 / Approach

先解析计量,再由 Python 现有观测入口决定是否启动进程。已有观测从原数据继续交给 TypeScript,最终 fold 的范围、回执身份、观察结果和收益仍由 TypeScript 判断。建议继续由该规则提供可用计量的判定,避免两层对 metadata 的要求分离。计量可用性先于可选观测。Python 以 tokenizer 映射是否存在放行进程。TypeScript 根据非空 name、encoding 和预期 encoding 确认计量来源。

具体改动 / Changes

精确头 0ac93d1c0239bfae6c770ff35a54934ff9ddbe53,基线 7b9cee5a2d1fdd8dfcf72177b6c8c213f40fd0de。对照 docs/architecture/rfcs/history-working-set-context-policy-v0.md 的 A13 与本 PR 的 No unmetered observation 交付条件。A13 要求保留原文直到安全、正收益替换成立,按原证据回读重放。PR 额外承诺在基线不可计量时跳过无收益读取。 基线 A13

  • _evaluate_semantic_unit_fold 先取得基线计数和 tokenizer 元数据,再把准备条件传给 _run_semantic_unit_obs_command。完全缺失时跳过实际进程,已有输出仍走原分支。 Python evaluator
  • buildSemanticUnitFoldSwap 仍检查 anchor、Todo、Turn、context epoch、原 prefix、回执摘要与来源、观测边界和净收益。空或不一致的 tokenizer 到这里才被清成不可用。 TypeScript 回执

对主干的风险 / Risks

两份隔离 Core wheel 都在无 tiktoken 条件运行同一 hook 证据,直接计数真实观测进程。有效给定计数的观测执行一次并 FoldToReceipt,重放同一回执不再执行。已执行观测在两版都直接使用。相等计数仍显示净差 0 并 KeepRaw。 错误的回执摘要保持 invalid_completion_sha256 和 KeepRaw;非静止边界和关闭路径均零观测。 省略及明确关闭均无 fold 回执、无观测进程,安装态 base/head 对照一致。 新头 44 项 Python 和 13 项 TypeScript 定向用例通过,配置的 mypy 与定向 Ruff 通过。词汇检查在基线和候选均报 54 项冲突定义超过 52 的上限。去掉 checkout 根路径后,两份完整词汇清单完全一致。 标准 premerge 把词汇项记为阻塞失败。另有一项既有 maintainability 告警,余下 8 项选定 smoke 及直接检查通过。

我的整体评价 / Verdict

请把计量来源判定提到进程前并保留同一 TypeScript owner,复验时同时读进程数与原回执。在隔离无 tiktoken 的 Core wheel 对同一绑定重放 quota context-hook,断言前两种观测进程数为零、有效计量只运行一次、保存的观测不重跑。 核对了 Core CLI hook、回执与两套测试,差分未改渲染界面。 原生宿主的真实模型上下文收益未在本次独立复验采样。

English verdict: REQUEST_CHANGES at 0ac93d1. Missing metering is skipped, but empty or mismatched tokenizer provenance still launches prefetch before the existing TypeScript gate rejects it.

@mergify

mergify Bot commented Dec 6, 2026

Copy link
Copy Markdown

This pull request has merge conflicts with main and cannot be merged
until they are resolved. Please rebase or merge the base branch, @loopx-agent.

Choose the remote for the base repository, not an out-of-date fork.
For a fork clone, first inspect git remote -v; upstream must point
to https://github.com/loopx-project/loopx.git. If it is absent, add it
with git remote add upstream https://github.com/loopx-project/loopx.git.
Then run:

git fetch upstream
git rebase upstream/main
# Resolve each conflict, git add the resolved files, then git rebase --continue.
git push --force-with-lease origin HEAD

For a same-repository clone whose origin points to
https://github.com/loopx-project/loopx.git, use origin instead of
upstream for fetch/rebase. If you prefer merging the base, use
git merge <base-remote>/main and push normally.

Keep the DCO Signed-off-by trailer on every commit when you rebase.
https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added the needs-rebase Mergify: the pull request has merge conflicts with its base branch label Dec 6, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-rebase Mergify: the pull request has merge conflicts with its base branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant