Skip to content

fix(heartbeat): keep compact prompts within budget - #4219

Closed
BigDataDZ wants to merge 1 commit into
loopx-project:codex/native-goal-prompt-contractfrom
BigDataDZ:codex/pr-4201-cli-output-budget
Closed

BigDataDZ wants to merge 1 commit into
loopx-project:codex/native-goal-prompt-contractfrom
BigDataDZ:codex/pr-4201-cli-output-budget

Conversation

@BigDataDZ

Copy link
Copy Markdown
Contributor

Summary

  • compress repeated heartbeat notification, safety, repair, scheduler, and vision wording
  • retain the complete quota guard and separate LOOPX_TURN assignment introduced by fix(heartbeat): share automation-first Goal execution contract #4201
  • keep exact authority, privacy, destructive-operation, scheduler-action, and projection-repair markers while bringing thin/brief/compact output back under the existing differential budgets

Why

PR #4201 currently fails Qualify agent-facing CLI output: heartbeat prompt variants grow by roughly 490–501 characters, exceeding the existing base/head limits. Raising the absolute prompt ceilings does not satisfy that independent regression gate.

This stacked patch fixes the failure by removing duplicate prose rather than weakening the global output-growth allowances.

Validation

  • examples/control_plane/cli-output-budget-regression-smoke.py: passed
  • heartbeat notification, Goal prompt dispatch, and host-loop activation suites: 96 passed
  • loopx check on both changed files: 0 errors, 0 warnings; public boundary clean
  • standard risk-based premerge: 12/12 selected checks passed, no manual holds
  • git diff --check: passed

Base: #4201 at 258d380f59501453a87cd722bb904ad3eac54c29.

Signed-off-by: BigDataDZ 76271875+BigDataDZ@users.noreply.github.com

Signed-off-by: BigDataDZ <76271875+BigDataDZ@users.noreply.github.com>

@huangruiteng huangruiteng left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

动机

这个 PR 试图压缩 heartbeat 的 compact、brief 与 thin task body,同时保留 turn identity、执行义务和通知语义。方向是对的:当前 prompt 已经接近预算边界,重复措辞确实应该从共享规则里收敛。

改动思路

改动把多处较长的 heartbeat 规则换成更短的共享常量,并让不同渲染模式选择不同压缩级别。整体仍由现有 heartbeat 渲染边界拥有,没有引入新的能力层或第二套状态权威,范围也比较克制。

具体改动

  • rules.py 收紧通知、执行义务、turn guard 和 writeback 文案。
  • task_body.py 让 brief 与 thin 模式复用更短的规则组合。
  • 现有回归覆盖了合成 scope 下的三种预算,以及 turn id 与部分 authority 字段。

关键代码讲解

这里仍有一个需要修复的 P1 语义/预算缺口。我在 exact head 上用真实 loopx-meta registry profile 运行公开 CLI:thin 从 1921 降到 1481、compact 从 6085 降到 5879,均在预算内;但 brief 仍为 3822/3500,within_budget=false。而 brief 使用的 HEARTBEAT_NOTIFICATION_RULE_THIN 只保留了裸的 agent_must_attempt,没有保留 canonical locator heartbeat_recommendation.agent_must_attempt,仅完整保留了 execution_obligation.must_attempt_work。现有预算 smoke 使用很短的合成 scope,因此没有捕获真实 registry-derived App prompt 的超限;现有语义断言也只匹配裸字段名,因此没有捕获路径被缩写。

此外,PR 记录的 base 为 258d380f...,当前 base branch 已前进到 b572baf3...,GitHub 当前为 DIRTY;本地 merge-tree 也确认 task_body.py 存在冲突。请先 rebase 当前 base,再在不提高 3500 ceiling 的前提下让真实 brief prompt 回到预算内,并同时保留两个完整路径;回归应使用 production-like registry-derived scope/preflight。

对主干的风险

我运行了相关 pytest(85 passed)、CLI output budget smoke、Ruff、git diff --check,远端 19 项检查也均成功或按设计跳过。这些证据说明改动没有一般性回归,但不足以推翻真实公开 CLI 的反例。若按现状合并,低上下文 brief fallback 仍可能超预算并丢失一个明确的 authority locator,且当前分支无法干净合入其 base。

我的整体评价

压缩方向、模块归属和批次大小都合理;未来向检查也没有发现需要顺手引入的新抽象。当前需要补的是这个 PR 自己声明要守住的核心契约,而不是扩大范围。修复 rebase 冲突、真实 brief 预算和完整 authority locator 后可以快速复审。

English verdict: REQUEST_CHANGES at exact head 2939e4b056bd87fd593b10a3bf6795e5f5321571; the real Codex App brief prompt remains 3822/3500, omits the fully qualified heartbeat_recommendation.agent_must_attempt locator, and conflicts with the current base branch.

@huangruiteng
huangruiteng deleted the branch loopx-project:codex/native-goal-prompt-contract September 11, 2026 07:27
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.

2 participants