feat: add goal resume guard / 添加目标续跑保护#1358
Open
Yuimi-chaya wants to merge 2 commits into
Open
Conversation
中文说明: 新增可选的目标续跑保护开关。开启后,Codex++ 会在检测到 Codex goal 上下文的 Responses 请求中追加轻量保护提示,要求恢复时优先当前 active goal 和 checkpoint 文件,避免压缩后把旧手动引导或旧目标结果当成新任务。 保护提示会要求读取 .codexpp-goal-state.md 或 GOAL_STATE.md,并在长任务中按小批次或阶段及时更新 checkpoint,减少中断、压缩或隔天恢复时重复执行旧步骤。 本提交同时补齐管理器设置、英文 i18n、设置保存/合并,以及目标检测和去重单测。另同步上游 rustfmt 对 cdp_bridge.rs 的一处格式化,保证 cargo fmt --check 可通过。 English Summary: Add an optional goal resume guard. When enabled, Codex++ appends a lightweight guard instruction to Responses requests that contain Codex goal context, so resumed work prefers the current active goal and checkpoint files instead of replaying stale manual steering or old goal results. The guard asks Codex to read .codexpp-goal-state.md or GOAL_STATE.md and to update checkpoints after meaningful small batches or completed stages during long-running goals, reducing duplicated work after compaction, interruption, or later resume. This commit also wires the manager setting, English i18n, settings persistence/merge behavior, goal-context detection, de-duplication tests, and one upstream rustfmt-only cdp_bridge.rs formatting sync needed for cargo fmt --check.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
中文说明
改动内容
.codexpp-goal-state.md或GOAL_STATE.md作为恢复锚点,并要求长任务在完成小批次或阶段后及时更新 checkpoint。cdp_bridge.rsrustfmt 格式,保证cargo fmt --check干净通过。功能入口
这个开关在 Codex++ 管理器的供应商设置里:进入对应供应商配置,在“Codex 目标”区块勾选“启用目标续跑保护”。它不是 Codex App 对话框内的按钮,也不是全局启动页入口。
修复原因
Codex App 在长目标任务中发生上下文压缩、手动中断或隔天恢复时,历史摘要和旧消息可能会混入当前上下文。实际风险是模型把旧的 manual steer、旧 goal token 或旧完成状态误当成当前任务,导致重复执行、回退到旧目标,或者在恢复时丢掉最新目标。
这个补丁不是替代 Codex App 的原生目标功能,而是在 Codex++ 的中转层提供一个可选兜底:只有开启开关且请求里确实包含 goal 上下文时才追加提示,普通对话不会被改写。
实测结果
本地做过一次高上下文真实压力测试:
contextCompaction。AFTER_75_GOAL_STATE.md恢复。NEW_GOAL_SURVIVED_AFTER_75_20260706,没有执行OLD_BAD,也没有把旧 token 当答案。安全边界
验证
cargo fmt --checkcargo test -p codex-plus-core goal_resume_guardcargo test -p codex-plus-core settingsnpm run checkgit diff --checkEnglish Summary
What changed
.codexpp-goal-state.mdandGOAL_STATE.mdas recovery anchors, and asks long-running goals to update checkpoints after meaningful small batches or completed stages.cdp_bridge.rsrustfmt-only formatting change socargo fmt --checkstays clean.Feature Entry
The switch is in Codex++ Manager's provider settings. Open the target provider configuration, then enable “Goal Resume Guard” in the “Codex Goals” section. It is not a button inside the Codex App composer and not an entry on the global launch page.
Why
During long Codex goal runs, context compaction, manual interruption, or next-day resume can leave stale summaries and old messages close to the active context. The practical failure mode is that the model may treat an old manual steer, an old goal token, or an already-completed step as the current task, causing duplicated work or a rollback to a previous goal.
This patch does not replace Codex App's native goal feature. It adds an optional relay-layer guard in Codex++: the prompt is appended only when the setting is enabled and the request actually contains goal context. Regular chat requests are left untouched.
Validation Notes
A local high-context pressure test was run:
contextCompactionoccurred during the new goal.AFTER_75_GOAL_STATE.md.NEW_GOAL_SURVIVED_AFTER_75_20260706, did not executeOLD_BAD, and did not use the old token as the answer.Safety Boundary
Checks
cargo fmt --checkcargo test -p codex-plus-core goal_resume_guardcargo test -p codex-plus-core settingsnpm run checkgit diff --check