Skip to content

Bound native context openings and linked first reads - #8300

Open
loopx-agent wants to merge 3 commits into
mainfrom
codex/shared-first-read-output-budget-20261107
Open

loopx-agent wants to merge 3 commits into
mainfrom
codex/shared-first-read-output-budget-20261107

Conversation

@loopx-agent

@loopx-agent loopx-agent commented Nov 7, 2026 •

Copy link
Copy Markdown
Collaborator

A native quota guard can return a small navigation object whose first-read command still asks for a 64,000-byte page. The host can cut that larger response before the caller receives its cursor. The same problem can occur when a saved decision is projected and read in one call.

Both openings now default to a 12,000-byte serialized output budget when the caller did not specify one. A linked opening pages the same selected values with its existing cursor. An attached opening can return a complete decision and read obligations first, with a separate command for the remaining initial selection. Both use the original immutable capture. Explicit limits, bulk recovery, and the original Todo selection recipe retain their respective budgets.

A smaller page can increase calls and total framing. The budget bounds CLI output bytes and does not establish host token retention, billing savings, or a change in model behavior.

Validation

  • File and SQLite quota CLI checks use the raw bound-Todo navigation and distinguish its first-read budget from full recovery.
  • Saved-decision tests follow the emitted link and cursor, check original values and receipt, and cover explicit limits, incomplete delivery and same-capture recovery.
  • Native Codex loopback cases exercise tool output and retained-history limits, including Code Mode.
  • The focused reference, first-read, and progressive regression cases and the quick premerge gate passed.

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.1-sol, OpenAI, runtime_reported, max

Request changes conclusion (author-owned PR; GitHub blocks formal self-review)

[P1] 首读缺省值覆盖了后继任务绑定的预算。 同一保存决策的选任务命令原有 32,000 字节上限时,基线保留该值,候选返回 12,000。原命令没有上限时,候选也会加入 12,000。当前首读调用没有提供这个选项。修复需分开 caller 参数和读取器推导的预算。修改点

动机 / Motivation

Agent 在处理已保存的工作决策前,通过原生工具读取当前指令和适用要求。 工具可能截断原来的大首读页。候选在相同工具边界交付了可读的首段和后续命令,但首读的缺省预算同时覆盖了后续任务绑定的已保存预算。 同一捕获的首段和余项可以完整读回。后继命令需要继续保留调用者已选的预算。 审阅范围是可见输出、同一捕获的恢复和后继命令语义。模型实际采用和整轮成本需另行测量。

改动思路 / Approach

TS 继续决定地址和顺序,Python 负责验证文件、固定引用并应用读页预算。应把首次读取的派生预算留在呈现边界。 有界首读及其两段恢复是一项可交付的局部改动。后继绑定的调用选项应继续来自原参数和保存决策。 一次只限制实际工具返回的附着页。对大选区,已有选择器可给出完整的开头和余项,并让它们固定到同一捕获。普通引用、旧选择引用与关闭路径仍由各自已有读取逻辑负责。

具体改动 / Changes

审阅依据为 docs/reference/required-work-context.md 在 94b91e48aa4a2cdafe9d4d31d918fe84d0112b41 的原生首读及恢复契约。bounded-first-read 通过原生工具验证,same-capture-replay 通过连续读回与旧引用测试。 caller-budget-scope 未满足。同一已保存选择命令在省略当前首读预算时应保留自己的选项。原契约

关键代码讲解

  • nativeContextReadPlan 使用同一地址选择器生成完整、开头和余项计划。原捕获的字节和摘要仍由文件读取器核验。选择
  • _bounded_initial_page 只在完整开头及导航可放入预算时返回开头,并提供独立的 remaining_read_command。两段续读使用现有固定引用,eof 说明该选区是否结束。首段
  • project_saved_context_capture 在给读取器设定缺省预算时改写参数,随后 _capture_selection_transport_template 把它传给绑定命令。该 helper 按原约定优先保留实际 caller 的显式选项,却收到读取器推导出的值。作用域 后继模板

双语文档区分了首段、余项和恢复。测试用实际原生宿主验证了工具和历史上限,也保留了小页、明确预算、同捕获重放和极小预算拒绝路径。说明 用例

对主干的风险 / Risks

同一份合成捕获分别在基线和当前提交调用实际 CLI,并用返回的恢复命令显式读取 selection_command。已保存上限缺省时,后继预算由缺省变成 12,000。已保存 32,000 时,后继也变成 12,000。当前调用明确传 6,400 的对照在两边都得到 6,400。原文件和回执保持相同。差异来自 CLI 生成的后继命令参数,证据取自完整的恢复读取。

验证 结果
真实 direct、retained-history 和 Code Mode PASS。候选三例均读回完整余项,旧 CLI 在 direct 恢复阶段仍被截断。
旧引用、首读、观察过的 warm 和压缩 PASS。168 个用例。
后继绑定的 budget 作用域 FAIL。复现了缺省值注入和已保存值覆盖。
两个 File/SQLite warm 绑定断言 FAIL。基线与候选在同一断言返回 full,预期 delta。
真实模型采用和成本 UNVERIFIED。loopback inference 验证了模型请求内可见文本。远端 CI 依配置未查询。

语义与 CI 对齐

--max-page-output-bytes 仍是既有选项。缺省值应由首次读页的呈现层决定。后继命令的选项应只从调用者与保存决策读取。把两组参数分开后,请对缺省、保存 32,000 和显式覆盖 6,400 三种输入读回并复测。

我的整体评价 / Verdict

预算和内容分离的设计有用,当前原生工具测试已证明开头和余项可见。后继任务绑定的调用者选择发生回归,后续续作风险仍待修复。已检查实际原生工具文本和 CLI JSON,本次没有网页或原生界面布局变化。 本次结果绑定所审提交,修复后应按新提交重新核对首读和实际后继命令。

English verdict: REQUEST_CHANGES 390a266. The bounded native opening passes the real-tool fixtures, but its derived default overwrites a saved budget in the subsequent selection command. Keep the derived page budget local and verify all three caller cases.

Comment thread loopx/cli_commands/quota_capture.py Resolved
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.1-sol, OpenAI, runtime_reported, max

Approval conclusion (author-owned PR; GitHub blocks formal self-approval)

旧预算作用域问题已复测关闭。 同一原始捕获分别读回缺省、保存 32,000 和显式覆盖 6,400。基线与当前提交的后继命令参数相同。旧提交把前两种值都换成 12,000。旧讨论

动机 / Motivation

处理已保存的工作决策时,Agent 通过原生工具取得当前指令和适用要求。 旧的批量首读可能在工具或历史边界被截断。候选在相同边界交付可解析的开头及余项入口,后继选任务命令继续使用自己原有的预算。 同一份捕获的控制信息、原回执和必要材料均可继续读回。 本次验收限于真实工具内可见的内容、同一捕获恢复和调用参数。模型实际采用和整轮成本需要各自的观察。

改动思路 / Approach

TS 继续决定选区和顺序,Python 负责验证文件、固定读引用并应用本次读页预算。后继模板从原调用参数派生。 当前交付是保存决策的有界首读及其同捕获续读。后续任务绑定继续沿原入口处理。 把现有首读的地址分为完整开头及固定余项,只有完整初选需要分页且开头装得下时才拆开。单纯降低上限仍能沿游标推进。同一份合成输入的 12,000 字节对照中,基线返回未完成的选区 JSON,候选的 5,005 字节开头可独立解析,后续内容沿余项命令读取。

具体改动 / Changes

依据是 docs/reference/required-work-context.md 在 94b91e48aa4a2cdafe9d4d31d918fe84d0112b41 的原生首读及同一捕获恢复契约。bounded-first-read 通过实际原生工具验证,same-capture-replay 由续读、压缩和原回执用例覆盖,caller-budget-scope 由三种保存调用参数的对照验证。原契约

关键代码讲解

  • nativeContextReadPlan 共用既有地址校验,对大初选提供开头及余项计划。未知捕获仍沿通用发现。选择
  • _bounded_initial_page 只在完整开头和导航能放入预算时使用两段结果。两个引用各自固定选区,eof 描述当前选区。放不下时用实际的顶层游标继续。开头
  • project_saved_context_capture 保留原始 args 供后继模板绑定,将派生的 output_limit 传给附着页呈现和读取。无上限的后继命令仍无上限,已保存或明确覆盖的预算保持各自来源。边界 读取

双语说明给出开头、余项和同一捕获恢复路线。测试覆盖小页、默认与显式预算、压缩、错误及真实宿主输出,新增断言从回读的选择命令验证三种参数来源。说明 测试

对主干的风险 / Risks

独立复测的大停止条件放不进 6,400 字节时,普通分页重建与基线相同的 56,627 字节和原回执。256 字节拒绝保留原捕获身份和恢复引用。未知预算的字节上限只能约束 CLI 的成功输出,外层工具与历史仍有独立限制。

验证 结果
App Server direct、retained history 和 Code Mode,以及新头 CLI 定向用例 PASS。8 个用例,原生请求中完整读回尾部材料再执行依赖验证。
省略、已保存和明确覆盖预算,普通分页回退、关闭、错摘要和错误选择 PASS。独立基线与当前头对照一致。
当前头 quick premerge PASS。
File 和 SQLite 的热绑定各一例 FAIL。基线与候选都在第 513 行返回 full,用例预期 delta。压缩后用例通过。
真实模型采用、实际成本及其他宿主版本 UNVERIFIED。真实工具由确定性 loopback inference 驱动。远端 CI 按配置未查询。

语义与 CI 对齐

继续使用已有捕获、选择页、命令和回执。余项增加同一来源的读取入口,读取默认预算只影响附着页及其续读。旧引用和观察过的 warm 验证来自旧提交的 168 例。当前增量没有改变通用读取器及 TS 地址规则,变化的保存入口和参数已用当前头补验。

我的整体评价 / Verdict

本次有界首读和同一捕获续读成立。调用者能先看到可解析的控制信息,再读取余项。原回执、保存选择预算和压缩后恢复仍可验证。已检查实际原生工具结果及 CLI JSON,受影响的路径没有独立界面布局。 当前没有阻塞发现。两条基线热绑定失败保留原判。

English verdict: APPROVE 8fbc78f. The bounded opening survives the tested native tool boundaries. The selection-budget regression is fixed, and baseline parity, exact recovery, and focused validation pass.

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
@loopx-agent loopx-agent changed the title Bound the first read of a saved native decision Bound native context openings and linked first reads Nov 7, 2026
@mergify

mergify Bot commented Nov 7, 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 Nov 7, 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