Repository navigation
fix(context): honor explicit output limits on initial native frames - #7521
Conversation
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
…' into codex/release220-final-regression-repair-20261028 Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
…limits Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent; gpt-6.1-sol; OpenAI; runtime_reported; reasoning_effort=max
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
APPROVE,精确 head 0c3c68b6f15df87d54fc5203ee0e264bd974fe97,没有未解决的阻塞发现。
动机 / Motivation
在原生 Codex 中显式启用差分上下文、且工具输出或保留历史预算较小的用户与验证维护者。 首个 guard 固定返回64KB,而现有输出上限只允许用于后续读取;首帧截断后,模型可能连续页命令也拿不到。 同一显式参数现可限制已启用原生 guard/context-project 的完整首帧,并在返回的续页与完整恢复命令中保留;完整字节、digest、游标及原结算仍独立核验。 不启用差分功能、不增加宿主历史容量、不改原决策或配额权限,也不把本地脚本化 provider 当作真实模型或正式发布资格。
改动思路 / Approach
复用既有 reader 的完整stdout预算和native activation owner,只把原显式上限传至首帧;不以环境变量控制输出、不新增协议、状态或第二次准入。 本PR交付已有原生上下文入口的显式小输出限制、真实fixture预算匹配和对应双语说明;同时修正两个当前发布回归的null/EOF断言与已合并内容的发布说明。 首帧和后续分页使用同一个完整stdout预算,先验证现有原生启用范围,再执行原准入/读取。省略参数仍是64KB;显式较小值只改变本次表示,不改变源内容、宿主历史配置、lease、配额或原结算。原生模型必须从实际收到的完整首帧发现续页,不能读磁盘上的正确副本来掩盖模型输入截断。
具体改动 / Changes
按 base f40d2930dea9426c2e86daef37d31bce7d4d4ab5 的 docs/reference/required-work-context.md 核对 COMPLETE-STDOUT、ORIGINAL-RECOVERY、EXPLICIT-ONLY。三个生产文件复用已有CLI参数、activation和reader:启用的JSON should-run/context-project接受正上限,完整metadata/换行计入上限,返回的续页和完整恢复命令保留同一cap。复制恢复命令而不改sealed capture。显式off、未启用或非正值在quota authority之前拒绝;原默认64KB和环境声明无关。
关键代码讲解
native_context_capture_view:Clamp whole-frame cap through existing reader;copy returned recovery command.handle_native_context_command:Validate allowed JSON enabled scope and positive limit before quota authority.project_saved_context_capture:Pass caller cap for original saved projection without collecting another decision.test_native_known_history_budget_keeps_larger_batches_and_recovery:Keep10k history/eight-read batch;cap every serialized page and match UTF8 offsets.test_native_context_cli_without_retention_stays_full_and_preserves_receipt:File/SQLite complete original readback,explicit7900/default64k,one receipt/zero spend.
测试没有把预算上调来跳过失败。显式10,000 token历史和八次批量读取保留,每份serialized输出4KB,UTF8 offsets按相同payload上限规划;所有batch元素都携带cap。生成的20,000 token宿主配置仍使用64KB输出,首帧和续页都使用该profile声明的直接工具预算。未知历史继续一次一份、有界读取,原2,000 token工具限制和native deadline保留;原256字节短读和大页场景仍执行。包装shell的pipefail与tee保持原结构,cap放在producer命令上,避免把整条pipeline重新shlex序列化成另一条命令。
File/SQLite正例分别重建完整UTF8 bytes和digest,重复guard仍只有一条heartbeat receipt、零spend且source不变;saved context-project读同一原capture,不产生新guard。真实native独立byte map要求所有原字节连续到齐,包含最后的停止条件,恢复后仍只有原来两个guard。未知依赖断言接受typed owner的null,must_attempt=true和全部轮询上限3保持;EOF只删空白。发布说明补入实际已合并的7510自claim默认及12位社区贡献者,未把这些文档当发布凭证。
PASS:Exact head:complete native/CLI/lifecycle/dependency cohort 280passed/0skipped;required Ruff,mypy,syntax,9path public boundary,12surface bilingual usage and risk-based premerge passed;source unchanged/cleanup successful. CLI help/manpage预检也通过。CI依现有Goal策略未查询。旧的低预算失败、错误pipeline尝试及已中断的旧head整模块运行均保留,不计为通过。
对主干的风险 / Risks
主要风险是cap仅限制内容而metadata仍溢出、后续命令丢cap、分页缩小却保留旧offset,或把磁盘存在/EOF当成实际保留。现有完整stdout reader计入所有framing,真实File/SQLite与实际Codex下一次输入逐字验证,并保留digest、原source、unique receipt、零重复guard/settlement反例。没有新协议版本或兼容分支;旧capture/receipt格式与默认路径保留,回退可撤销本PR。每条命令的cap不改变宿主总历史或整批预算,也不设置长期宿主偏好;不支持的环境与外部真实provider仍需独立资格。
我的整体评价 / Verdict
复用既有 reader 的完整stdout预算和native activation owner,只把原显式上限传至首帧;不以环境变量控制输出、不新增协议、状态或第二次准入。 本PR交付已有原生上下文入口的显式小输出限制、真实fixture预算匹配和对应双语说明;同时修正两个当前发布回归的null/EOF断言与已合并内容的发布说明。 架构上这是现有native IO/presentation adapter的参数传递,控制面语义owner继续拥有准入、lease与结算;fixture本地工具预算选择复用一个helper,避免多个分支再漂移。相较增大历史预算、压缩任务指导或另起准入,该方案直接解决可复现的完整首帧缺口,并保持原实际输入的独立反例。没有UI布局或新业务能力,现有原生交互入口完成验证;不能由此推断App/Bot或长期研究收益已经资格。统一发布commit的全仓、安装、付费模型与公开渠道仍待资格;本PR没有新科学结论、实际长期收益或完整跨平台资格声明。
English verdict: APPROVE 0c3c68b6f15df87d54fc5203ee0e264bd974fe97. Explicit native first-frame limits, complete original recovery and default/off parity are verified through real CLI and native-input tests. Required local gates passed; integrated release, installed artifacts and paid-model qualification remain separate.
Problem and resulting behavior
An enabled native guard always emitted its first frame with the 64,000-byte default, even when a caller needed a smaller host output budget. The existing
--max-page-output-byteswas accepted only by the continuation reader, so truncation could hide the first continuation command before recovery was discoverable.The same option now applies to enabled JSON native
should-runandcontext-project. It bounds the complete successful frame, including metadata and newline, and preserves the cap in returned continuation and full-recovery commands. Omitting it retains the existing 64,000-byte default and ambient-environment invariance. Disabled or invalid uses reject before quota admission; presentation never creates another decision, renews a lease or spends quota.Native regression fixtures now size each batch and its UTF-8 offsets consistently, apply the generated 20,000-token profile's declared direct-output budget to the first frame too, and retain the explicit 10,000-token history/eight-read case. Real model-visible bytes, original hashes/cursors, full recovery and exactly two original guards remain independent assertions. An unknown dependency accepts the typed owner's null status while retaining must-attempt and the bounded-three poll limit; one trailing blank line is removed.
The bilingual 2.2.0 notes document this per-command option, merged ordinary self-claim behavior and verified community attribution. No optional feature is enabled by this change, and no host history limit or frozen qualification criterion increases.
Validation
At exact head
0c3c68b6f15df87d54fc5203ee0e264bd974fe97: the complete actual-native context module and related CLI/lifecycle/dependency/machine-guard modules passed 280 tests, 0 skips, using the real Codex binary and a deterministic isolated local provider. Required Ruff, mypy, syntax, nine-path public-boundary, all 12 bilingual release-usage surfaces and risk-based premerge passed with no failures or manual holds. CLI help/manpage preflight passed. Source-before/source-after identity matched and isolated cleanup succeeded. Failed and interrupted earlier attempts remain failed and are not relabeled as qualification.Final integrated workspace, installed package, paid model and publication-channel qualification remain separate.
Existing contract
docs/reference/required-work-context.md,docs/development/testing-and-quality.mdbudget decisions, and the existing digest-bound reader/native activation owners. The implementation extends an existing explicit transport limit rather than making a shell variable authoritative or adding another state owner. No frontend layout or business capability changes.