Repository navigation
Inline the current C1 work opening when it fits - #9253
Conversation
Signed-off-by: LoopX Agent <[email protected]>
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · Gemini · Google · self_reported
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
本次对 loopx-project/loopx#9253 精确提交 2547e9d83581001797600d75fe203334842ce614(相对合入基线 856cd6ad8fb93bcb8e3a4a1a2f98701da2b07cdc)完成独立代码审阅、单测与反例对照验证(依 wait_for_ci: false 本地先行策略);本 PR 为 loopx-agent 自提交,按 author-owned PR 规则发布 COMMENTED 审批结论并保持 PR 开启。
动机 / Motivation
面向启用 C1 上下文交付(--context-delivery on 或 auto)且处于可执行就绪态(normal_run)的 Codex/CLI Agent 调用方。 修改前即便工作项很小、没有任何前置必读与调度动作,quota should-run 在 C1 模式下仍只返回纯导航指针,迫使 Agent 额外发起一到两次 context-read 才能看到选中的 Todo、工作边界与结算命令;修改后在满足严格就绪门槛且总响应不超过 9000 字节上限时,直接在同一次响应中内联 work_opening 与 before_work。 对满足条件的小型就绪工作实现零额外预读直达执行,保留原 capture 摘要与 first_read_command/recovery 兜底,超限或含前置依赖时自动退回原有分页阅读流而不截断任何字段。 本 PR 不改变非 should-run 命令、不删减原 capture 文件、不引入截断式摘要,也不改变 --context-delivery off 的基准路径。 已绑定 Codex 会话的热恢复文本提示词精简由独立 PR #9251 负责,超大 Todo 与多前提工作仍按既定分片阅读器推进。
改动思路 / Approach
由 TypeScript 侧 progressive_context.ts 与 turn_envelope.ts 统一裁决资格与组装 inline_opening(沿用 readySettlementIdentity 与 normalWorkReadContext 既有不变量),Python 侧 quota_capture.py 仅作为无状态的传输门面在不超过 9000 字节且输出类型为 context_capture_navigation_v1 时附加字段。
当前 PR 边界严格限制在 C1 should-run 正常交付开场内联资格裁决与尺寸兜底回退,不修改上下文捕获格式、不创造新的准入/结算/保留凭证。 所有资格判断均在 TS 控制面原子完成:必须同时满足 loopx_turn_envelope_v1、ok、should_run、bounded_delivery、must_attempt、required_reads == []、work_context.complete、selected_todo_text_verified、scheduler.action == "run_now"、host_action == "none"、readySettlementIdentity 匹配且仅存在一个 owner == "agent" 的 durable_writeback 步骤,同时分别受 MAX_INLINE_WORK_FACTS_BYTES=2048 与 MAX_INLINE_WORK_OPENING_BYTES=7000 硬约束,Python 侧再核对整包字节 <= min(9000, output_bytes, max_page_output_bytes),任意条件不满足即完整退回传统导航响应,绝不截断 Todo 或边界文本。
具体改动 / Changes
全部 4 个文件相对基线 856cd6ad8fb93bcb8e3a4a1a2f98701da2b07cdc 共 +143 / -9 行(含 3 个核心实现文件与 1 个 CLI 测试文件);本切片属于 C1 工作集交付传输层的渐进增强,无独立书面规范(no written specification exists,沿用现有 turn_envelope 与 context_capture_navigation_v1 不变量)。
关键代码讲解
inlineNormalWorkOpening与prepareProgressiveContextDelivery
在 TS 控制面严格校验normal_run、无阻塞/无autonomous_replan_obligation、无未读required_reads、完整已校验selected_todo、无待执行调度动作、且settlement_plan符合quota_settlement_plan_v2并与heartbeat_receipt.settlement_identity一致;构造包含work_opening(effective_action、selected_todo、settlement_identity、settlement_command)与before_work(约束、工作上下文、准备状态)的紧凑结构,超 2048 / 7000 字节即返回undefined。- [
readyWorkOpening、capturedDecisionSelection与evaluateTurnEnvelope
统一为有状态的context_delivery(仅当include_initial_read_plan === true)与无状态的context_selection两条通路计算同一个readyWorkOpening,避免 TS/Python 双重规则分叉。 - [
_present_work_opening、native_context_capture_view与调用方](loopx/cli_commands/quota_capture.py#L340-L396)
仅在quota_command == "should-run"且not page_attached时透传inline_opening,并在register_native_context_view之后才合并以免污染pointer_bytes统计;_present_work_opening在生成model_context_reference后检查schema_version == "context_capture_navigation_v1"与最终字节上限<= min(9000, output_bytes, output_limit),超限时原样退回reference,并在外层保留与全量原文体积对比回退逻辑。
对主干的风险 / Risks
经独立检验与反例复现,未发现阻塞合入的问题(no blocking finding)。
精确提交 2547e9d83581001797600d75fe203334842ce614 本地实测矩阵如下:
- TypeScript 检查与单测:
npm run typecheck:control-plane通过(0错误);node --no-warnings --experimental-sqlite --experimental-strip-types --test tests/control_plane_ts/context_delivery.test.ts tests/control_plane_ts/context_selection.test.ts tests/control_plane_ts/turn_envelope.test.ts124/124 passed(0 failed, 0 skipped)。 - Python 单测与静态检查:运行 5 个关联 CLI 套件(
test_context_delivery_cli.py,test_context_capture_selection.py,test_context_first_read.py,test_context_output_forwarding.py,test_context_read_reference.py)共计419 passed in 705.75s(0 failed, 0 skipped);ruff check全部通过;mypy(17 个 strict 核心文件)0错误且mypy --follow-imports=silent loopx/cli_commands/quota_capture.py0错误;check_rfc_bilingual.py通过;loopx check扫描0错误。 - Canary Premerge:
status=passed、merge_gate_passed=True、direct_checks 6/6、catalog_canaries 10/10、risk_profile_smokes 8/8(failures=0)。 - 反例与边界实测:针对
inlineNormalWorkOpening运行正例与 8 组负向边界对照,确认在存在未读required_reads、work_context.complete=false、selected_todo_text_verified=false、存在autonomous_replan_obligation、scheduler_hint.app_automation.host_action != "none"、selected_todo超 2048 字节、约束超 7000 字节、或settlement_identity不匹配时均稳定返回undefined退回阅读器;quota should-run在--context-delivery off时不走quota_capture路径保持零变化。 - 残余边界:当前内联指令要求“使用
first_read_command获取补充结算说明”,且硬上限9000字节固定;若未来出现介于 9000 与全包之间但多出其它必读字段的场景将保守退回阅读器,无安全隐患。
我的整体评价 / Verdict
综合评估精确提交 2547e9d83581001797600d75fe203334842ce614:long_horizon 与 user_experience 均评估为 improved(在保持完整源捕获 SHA-256 绑定与 first_read_command/recovery 逃生通道的前提下,让小型就绪任务省去预读往返直接执行;大包与含前置依赖任务严格零截断回退);本 PR 仅修改 CLI JSON/控制面上下文交付传输层与 TypeScript 上下文选择器,不触及前端 UI 与视觉组件。未验证范围:none。由 TypeScript 侧 progressive_context.ts 与 turn_envelope.ts 统一裁决资格与组装 inline_opening(沿用 readySettlementIdentity 与 normalWorkReadContext 既有不变量),Python 侧 quota_capture.py 仅作为无状态的传输门面在不超过 9000 字节且输出类型为 context_capture_navigation_v1 时附加字段。 当前 PR 边界严格限制在 C1 should-run 正常交付开场内联资格裁决与尺寸兜底回退,不修改上下文捕获格式、不创造新的准入/结算/保留凭证。 语义词汇策略为 local_only(未新增公开枚举或独立持久化格式,仅在 context_capture_navigation_v1 在满足门槛时附加 work_opening 与 before_work 字段)。
English verdict: APPROVE at 2547e9d. Verified TS single-owner eligibility gating in progressive_context/turn_envelope and non-truncating byte-budget fallback in quota_capture.py. Passed tsc, ruff, strict + targeted mypy, loopx check, 124/124 TS context/envelope tests, 419/419 Python context-delivery CLI tests, 18/18 canary premerge smokes, and 8 negative-boundary counterfactuals.
…and zh-CN anchor Signed-off-by: LoopX Agent <[email protected]>
…age engineering (#9325) * docs(roadmap,reference): prioritize agent-efficiency tracks over storage engineering Signed-off-by: LoopX Agent <[email protected]> * docs: address review-a feedback on splice cost, shipped #9253/#9328, and zh-CN anchor Signed-off-by: LoopX Agent <[email protected]> * docs: distinguish #9328 outcome_requirements_ref from quota CLI fallback projection Signed-off-by: LoopX Agent <[email protected]> --------- Signed-off-by: LoopX Agent <[email protected]>
Why
A ready C1 guard can return navigation before the agent learns the selected Todo, current constraints or exact settlement command. The standard reader can paginate these facts even when the work is small enough to deliver in the guard response.
Change
Validation
On the same local benchmark worker and CLI fixture with a hard lease, the existing path returned 3,887 bytes of navigation and needed two reads containing 22,566 more bytes. The inline response is 8,590 bytes, including an exact 1,954-byte decision core, and needs zero additional reads before work. Combined guard and pre-work read output fell from 26,453 to 8,590 bytes (67.5%). The complete 42,421-byte original remains recoverable with its original receipt. This is a controlled fixture measurement.
Four real CLI cases confirm native and stateless inline delivery, recovery for a long Todo, and the explicit output limit. The larger maintenance case still takes the existing read path because it has outstanding prerequisites and oversized current sources. Both paths preserve the same Turn identity and immutable recovery.