Skip to content

fix(context): restore large native reads and recognize mixed stdout - #7509

Merged
loopx-agent merged 1 commit into
mainfrom
codex/heartbeat-context-output-20261028
Oct 27, 2026
Merged

loopx-agent merged 1 commit into
mainfrom
codex/heartbeat-context-output-20261028

Conversation

@loopx-agent

@loopx-agent loopx-agent commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Goal And Delivered Outcome

Native context delivery added a small-output boundary that ordinary full-packet output did not have. Without a shell environment declaration, continuations fell back to 8192-byte reads under a 7900-byte output cap; the initial guard always returned at most 3072 content bytes. Combining pre-quota text and that first JSON page also prevented the native hook from recognizing the delivered range.

This repair uses the existing 64000-byte profile for inline and continuation output regardless of that environment declaration. Packets that fit finish inline. Complete newline-delimited JSON records in mixed shell output reach the existing trusted-capture verifier. No additional split-command instruction is needed.

  • Outcome basis: maintainer-requested code repair of mixed-output recognition and unnecessarily small pagination.
  • Intended base: main; reviewed baseline 787f15e82283ae4cd590dc0ec91d88b09db4e122.
  • Observable change: identical synthetic CLI inputs of 46959 bytes require 7 → 1 reads; 468159 bytes require 65 → 8. Mixed stdout now establishes the complete baseline and the next projection is delta. These are transport observations, not model-token or whole-cost savings.

Author Declaration

  • Written by: OpenAI Codex model agent (GPT-6.1 Sol).

Implemented against

No separate written specification; the maintainer request described above is the basis. Existing capture integrity and native lifecycle boundaries are retained from docs/heartbeat-automation-prompt.md at the reviewed baseline.

Criterion Disposition Symbol / path Evidence
Repair mixed stdout in code implemented _context_pages, existing native hook Complete/multiple records accepted; embedded, quoted, truncated, corrupt and failed output rejected; original-range recovery tested
Restore reasonably large default reads implemented native_context_page_budget, JSON reader, generated recovery commands, inline guard Missing/invalid/old environment declarations retain 64000-byte profile; small captures complete inline; paired CLI comparison
Preserve original capture and authority implemented Existing capture verifier and typed lifecycle owner Exact bytes/digest/cursors, scope isolation, no extra admission/spend, explicit small-budget recovery, File/SQLite integration

Scope And Continuation

Complete within this transport-repair scope. Python remains the existing native IO adapter; shared lifecycle/state decisions remain with the current typed owner. No new module, command flag, state vocabulary, scheduler, provider or UI is introduced. The obsolete guard-only-small instruction is removed, and the existing English/Chinese required-work-context contract now describes the same defaults; configured-profile instructions otherwise remain byte-identical across six scenario/location combinations.

The explicit JSON recovery reader's default also changes to the large profile. Explicit smaller page/output budgets retain their existing behavior for constrained recovery. Ordinary successful quota output and reuse activation/default-off behavior retain their existing owners. Large stdout does not raise a host's direct-output or retained-history limit.

Validation

  • Tested revision: a88619fa02f3269db30e25c044ed7253640477cd.
  • Run state: finished.
  • Input classes: synthetic, public_fixture.
Check kind Result Evidence / limitation
unit passed Lifecycle and JSON-reader suites: 196 passed
integration passed Seven adjacent context/host/heartbeat modules: 260 passed; 54 existing explicit native-Codex opt-ins skipped
regression_parity passed Actual immutable-base/source-after CLI on identical synthetic inputs: 7 → 1 and 65 → 8 reads; mixed-output baseline failure reproduced before and repaired after
real_entrypoint passed Isolated final wheel repeats complete inline/large reads and full → delta; 1752 Python/TypeScript modules match source, wheel and isolated installation
static passed Required Ruff trees, configured strict mypy (17 sources), semantic advisory, bilingual diff, whitespace and nine-file public-boundary scan
integration passed Standard Chat build and wheel build; existing CLI-output-budget regression smoke
manual passed Six configured-profile comparisons retain all other instructions/configuration exactly after retiring the obsolete small-guard clause
integration passed Standard premerge: 6 direct checks and 19 selected checks, zero failures/manual holds; exact quality receipt cqr_90c4e28e371834b888c2 verified valid

Initial validation failures are preserved: default-budget/legacy handling regressions were repaired, old small-inline assertions were updated to the intentional behavior, and larger saved-page fixtures still exercise continuation/restart with exact bytes. An initial stale-frontend wheel build was repaired by the normal Chat build before the final successful wheel, without a packaging bypass.

Coverage: source and isolated package/CLI transport. The skipped opt-in native-Codex matrix, live App installation, actual HTTP/model-input retention, full hook/IO/billing costs and long-horizon net benefit are not newly qualified by this PR. No model campaign was launched.

The exact-base comparison repeats the same 7 → 1 / 65 → 8 result. A paired disabled-path check preserves the complete off projection and inert hook except for the intentionally enlarged recovery command (including its nested reference). Final documentation refinement changes no Python/TypeScript/test bytes from the tested revision.

Frontend / Visual Evidence

  • UI impact: none. Existing native hook/configuration/CLI journey only; no rendered layout changed.
  • Before / after / first viewport: N/A.

Type of Change

  • Bug fix
  • Documentation update
  • Test update

LoopX Area

  • Control plane
  • Host or runtime integration

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
@loopx-agent
loopx-agent force-pushed the codex/heartbeat-context-output-20261028 branch from 33688ed to a88619f Compare October 27, 2026 17:25

@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; reasoning_effort=max.

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

动机 / Motivation

没有发现本准确 head 的未解决阻塞问题。使用原生上下文读取的 Agent,尤其是合并前置命令输出与首个上下文页的调用方。

约 47 KB 的完整包原先需要 7 次读取,现在一次返回;约 468 KB 的混合输出原先需要 65 次且无法建立基线,现在 8 次读完并进入下一轮差分。同一不可变输入的字节、摘要和连续游标完整保留,减少分页往返,混合输出无需新增分开执行的提示。本次只修复传输读取;不证明模型保留、完整 token 或费用收益,也不升级运行中的 App。原长程目标中的真实模型输入、全部调用成本和可比任务收益仍未验收。

改动思路 / Approach

复用现有分页器、可信捕获校验和 TypeScript 生命周期 owner;新增代码只识别完整 JSON 行,预算在已有 owner 内统一,未增加状态或授权分支。交付首屏、续页、恢复命令、混合输出识别与相符文档这一完整传输切片。首屏和续页都由现有分页器按完整 JSON stdout 大小收缩正文;基线是否可信仍由原摘要、实际字节、作用域及生命周期判断。它不会因为找到一行 JSON 就相信其中自报的路径或 EOF。

以下是实际 CLI 的相同输入比较,基线为 787f15e82283ae4cd590dc0ec91d88b09db4e122,审阅 head 为 a88619fa02f3269db30e25c044ed7253640477cd,没有 shell 预算声明:

输入及触发 基线 当前 head
46959 字节普通完整包 7 次读取 1 次,首屏 EOF
468159 字节、首页前有其它输出 65 次,下一轮 full 8 次,下一轮 delta

仅加“请分开执行”指令会把框架缺陷留给调用方;无界返回整包又会增加截断风险。现在复用既有 64000 profile,并保留同捕获的显式小预算恢复,是与已授权目标相称的取舍。没有增加手工准备、确认或新配置步骤。

具体改动 / Changes

本次新增需求没有另立已接受的书面规格,依据是维护者当前的代码修复、大页及合并请求。补充核对的既有来源为 docs/reference/required-work-context.md 与 docs/heartbeat-automation-prompt.md,不可变基线 787f15e82283ae4cd590dc0ec91d88b09db4e122;新预算由该请求明确更正,不能用修改后的说明反过来证明实现正确。

9 文件共 +195/-88,生产代码 +42/-22,测试 +93/-10,文档 +60/-56。评审已把仍写旧 3 KiB/7900 默认的中英文协议同步修正;保留历史测试条件、完整源/权限/新鲜度、恢复与不确定性语义。

关键代码讲解

  • _context_pages 先保留整个 JSON 解码,再识别完整物理行。嵌入文本、JSON 字符串和截断记录不能当页;最终仍走可信原捕获逐字节校验。
  • native_context_capture_view 使用同一首屏/续页预算。完整 stdout 的转义、指令、恢复命令及换行都计入上限,能容纳的包直接结束,不能容纳就保留原游标续读。
  • read_context_capture 把省略参数的 JSON 默认改为 64000/64000。Markdown 4096 和显式更小预算保留;过小 metadata 预算报同捕获错误,不产生零进展页。
  • native_context_page_budget 删除缺少环境声明就回小页的分支;生成恢复命令也复用原大页配置。

验证为 PASS:196 项 lifecycle/CLI,260 项相邻 resume、retention、saved、host/heartbeat;54 项既有显式原生 Codex opt-in 未运行,单列 SKIPPED。产品源码和测试在最后文档修订后逐字未变;隔离 wheel 已重复 1/8 页、下一轮 delta,1752 个 Python/TS 模块与源码/安装一致。规定 Ruff、mypy17、公开边界和双语/差分检查通过。

对主干的风险 / Risks

64000 字节只是请求和输出呈现预算,不能提高宿主硬容量。最强反例是 CLI 与 hook 都完整,而下游保留历史被截断;当前合成工具测试不能否定它。已观察的缺页、坏字节、错误 scope 或失败退出不建立基线,补读同一原捕获缺失范围可恢复,不重准入、扣额或刷新权限。必要时显式减小 page/output 预算;不会因本地完整 EOF 就声称模型已保留。

复用仍默认关闭。真实 base/head 关闭态比较验证:响应完整字段与指引相同、hook 为 {},不创建 journal/authority;顶层和嵌套恢复命令均有意从 4096 改为 64000/64000,这个全局 reader 默认变化已经披露。已配置的六组生成指令只去掉过时 small-guard 句,其余配置/指令逐字相同。没有新增 actor、协议、权限或费用门;既有 TS owner 继续负责状态。

语义与 CI 对齐

本次复用既有词表和边界,仅按维护者方向调整输出默认及完整记录框架。首轮验证中的预算/legacy 处理回归已修;旧小页预期改为完整原包断言,续页夹具增大后仍检验精确字节和重启,未删除恢复 oracle。旧构建失败经正常 Chat build 后完成打包,没有豁免;最终准确 head 的标准预合并 PASS:6 项直接检查、19 项选中检查,零失败及人工留置;准确质量回执 cqr_90c4e28e371834b888c2 有效。当前 wait_for_ci=false,未查询、轮询或等待远端 CI。

我的整体评价 / Verdict

这是原长程任务的 justified_increment:减少重复完整读取和工具往返的具体路径已有实证,long_horizon 与 user_experience 在此传输边界 improved,尚不能认证整体任务收益。机制与问题相称;没有新模块、flag 或第二状态 owner,兼容保留对应已有显式小预算/持久捕获消费者。检查了原生 hook、CLI 和配置入口;没有改动渲染布局,因此不需要新的页面截图。正式 App 安装、下游模型输入和长期阅读效果未验证。

准确审阅 head:a88619fa02f3269db30e25c044ed7253640477cd。无阻塞 finding,作者自评采用 COMMENTED,不冒称 GitHub formal approval、第三方独立验收或合并授权。合并仍须最终本地预检与准确 head 的原生 readiness。

English verdict: APPROVE a88619fa02f3269db30e25c044ed7253640477cd for the bounded native transport repair; model retention, live installation and complete cost benefits remain unverified.

@loopx-agent
loopx-agent merged commit dab1eda into main Oct 27, 2026
19 of 39 checks passed
@loopx-agent
loopx-agent deleted the codex/heartbeat-context-output-20261028 branch October 27, 2026 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant