Repository navigation
fix(native-chat): recover steward active-cascade resume_failed and bound thinking-only error loops - #9170
Conversation
…und thinking-only error loops Signed-off-by: LoopX Agent <[email protected]>
loopx-agent
left a comment
There was a problem hiding this comment.
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
Reviewer: model_agent (declared_model=Gemini, declared_provider=Google, declaration_source=self_reported)
Target exact head: 9170@fe10fa4cc10a0b3447aab9b75313618f310fa6a0
动机
- Affected caller or operator: LoopX personal-steward and local Antigravity Language Server callers.
- Before/after scenario: Before: restarting the chat service during an Antigravity turn left the upstream cascade retrying thinking-only error loops while the next Steward turn failed pre-dispatch after manager.context and could never auto-recover. After: post-error thinking-only loops time out and cancel, _preparation_scope_available waits until CASCADE_RUN_STATUS_IDLE, and planRuntimePreparationRecovery admits exactly verified Steward manager.context pre-dispatch resume_failed turns.
- Observable outcome: 70/70 TS conversation_binding tests pass, 216 Python tests pass including live Steward active-cascade recovery and thinking-only error-loop timeout tests, ruff and quick canary premerge pass with 0 failures.
- Non-goals: Does not alter Codex routing recovery or post-dispatch result review contracts.
实际运行中一旦宿主重启中断了 Antigravity 原生对话,原有级联会持续陷入纯思考重试死循环并拒绝后续排队的 Steward 消息;若不修复预派发恢复条件与级联空闲门禁,用户消息将永久卡在失败态而无法自动续接。
改动思路
本 PR 在既有状态机边界内做最小可逆修复:Minimal reversible fix directly in the three owning modules (TS recovery policy, Python preparation availability readback, and Antigravity adapter progress/discovery).。边界约束:Limited strictly to Antigravity Steward pre-dispatch active-cascade resume_failed recovery, LS env address fallback, and non-progressing post-error thinking-only retry timeout; Codex recovery and post-dispatch flows remain untouched.。
具体包含三条协同机制:第一,在 TypeScript 控制面允许经过严格前置事件校验(包含 manager.context 与 turn.failed 且 upstream_turn_id === null、delta_count === 0、response === null、execution_dispatch == null)的 Antigravity Steward resume_failed(The original Antigravity conversation is still active...)进入有界准备恢复;第二,在 Python 准备可用性检查中读取 GetCascadeTrajectory,仅当状态为 CASCADE_RUN_STATUS_IDLE 时开放接续;第三,在 Antigravity 适配层补全 ANTIGRAVITY_LS_ADDRESS 发现并在 _run_turn 中忽略非 CLEARED 错误后的纯思考无进展重试步,确保死循环能触发 idle 超时取消。
具体改动
loopx/control_plane/collaboration/conversation_binding.ts(planRuntimePreparationRecovery,第 1649 行):扩展expectedErrors仅在current.agent_id === "antigravity"时接受"The original Antigravity conversation is still active. Stop it in Antigravity before retrying.";同时放行带有完整manager.context前置事件链、未派发且无正文增量的 Steward 预派发失败记录,并通过反向单测验证任意upstream_turn_id、execution_dispatch或缺失manager.context的请求继续被拒绝。loopx/capabilities/native_chat/external_conversations.py(_preparation_scope_available,第 732 行):当会话使用antigravity且存在upstream_thread_id时,读取GetCascadeTrajectory,在运行中时返回False延后重入(不消耗重试预算),仅在CASCADE_RUN_STATUS_IDLE时返回True。loopx/capabilities/native_chat/antigravity_adapter.py(discover_antigravity_language_server与_run_turn):在未设置ANTIGRAVITY_LS_URL但提供ANTIGRAVITY_CSRF_TOKEN时兼容回退ANTIGRAVITY_LS_ADDRESS并校验回环地址;在_run_turn进度计算中排除首个非CLEARED错误之后既无响应文本也无toolCalls的纯thinking重试步,防止空转无限重置空闲计时器。- 测试覆盖:
tests/control_plane_ts/conversation_binding.test.ts新增 Steward 预派发恢复与负向边界用例(70/70 通过);tests/test_chat_runtime_preparation_recovery.py新增运行中延迟恢复至空闲后完成交付的端到端测试;tests/test_antigravity_steward_adapter.py新增环境变量发现与错误纯思考循环超时取消测试(216 passed)。
对主干的风险
对主干的影响高度受控且局限于 Antigravity Steward 路径:对于正常执行的会话以及 Codex 会话,控制面判定与适配层进度刷新逻辑完全保持不变。唯一边界条件是当 Antigravity 在一次非 CLEARED 错误之后连续处于纯思考而超过 600 秒未产生任何可见输出或工具调用时,适配层会按 idle 超时主动中断并调用 CancelCascadeInvocation,这是期望的兜底保护而非回归。若未来需要调整错误识别策略,只需回退或调整三处局部守卫,不涉及任何持久化 Schema 迁移或配置变更。
我的整体评价
该改动精准定位并闭合了 Antigravity 管家在服务重启后的两个连锁缺陷(死循环无法超时与预派发无法自愈),控制面与适配层职责清晰,正反测试与本地预合并门禁(TS 单测 70/70、Python 单测 216 passed、ruff check、canary premerge quick failures: 0)全部通过。架构边界评估:Limited strictly to Antigravity Steward pre-dispatch active-cascade resume_failed recovery, LS env address fallback, and non-progressing post-error thinking-only retry timeout; Codex recovery and post-dispatch flows remain untouched. 原因:Minimal reversible fix directly in the three owning modules (TS recovery policy, Python preparation availability readback, and Antigravity adapter progress/discovery).。视觉评审结论:No rendered frontend or UI component modified; backend control-plane and Python native chat adapter only. 未验证范围:none。
English Verdict: APPROVE
Goal And Delivered Outcome
resume_failedrecovery and stream-interruption timeout handling (personal-native-bots-20261004).manager.contextbefore native dispatch and hitresume_failedwith"The original Antigravity conversation is still active. Stop it in Antigravity before retrying.",planRuntimePreparationRecoveryinconversation_binding.tsrejected recovery because it only matched"The previous Agent conversation could not be restored."and requiredstarted_at === null && first_event_at === null && events.length === 2, while_preparation_scope_availableinexternal_conversations.pyonly checked Language Server reachability without verifyingGetCascadeTrajectory.status == "CASCADE_RUN_STATUS_IDLE".discover_antigravity_language_serverinantigravity_adapter.pychecked onlyANTIGRAVITY_LS_URLalongsideANTIGRAVITY_CSRF_TOKENand returnedNonewhen hosts providedANTIGRAVITY_LS_ADDRESSinstead.AntigravityAdapter._run_turn, repeatedCORTEX_STEP_TYPE_ERROR_MESSAGE -> thinking-only CORTEX_STEP_TYPE_PLANNER_RESPONSEretry cycles with no visible response text or tool calls repeatedly resetlast_progress_at, preventingANTIGRAVITY_IDLE_TIMEOUT_SECfrom cancelling a wedged cascade.resume_failed("The original Antigravity conversation is still active...") aftermanager.contextcould never auto-recover;_preparation_scope_availabledid not gate onCASCADE_RUN_STATUS_IDLE;ANTIGRAVITY_LS_ADDRESS+ANTIGRAVITY_CSRF_TOKENenv configuration returnedNone; thinking-only retry loops after non-cleared errors never hit the idle timeout.planRuntimePreparationRecoveryadmits strictly verified Antigravity Stewardmanager.contextpre-dispatchresume_failedturns (upstream_turn_id === null,delta_count === 0,response === null),_preparation_scope_availabledefers retry while the cascade is running and admits recovery onceCASCADE_RUN_STATUS_IDLE,discover_antigravity_language_serverresolvesANTIGRAVITY_LS_ADDRESS+ANTIGRAVITY_CSRF_TOKEN, and_run_turnignores non-progressing thinking-only retry steps after non-cleared errors so idle timeout cancels the wedged cascade cleanly.node --experimental-strip-types --test tests/control_plane_ts/conversation_binding.test.ts(70 passed, 0 failed)uv run --extra test python -m pytest tests/test_chat_runtime_preparation_recovery.py tests/test_antigravity_steward_adapter.py tests/test_antigravity_host_runtime.py tests/test_audit_cli_and_runtime_fixes.py -q(216 passed)uv run --extra test ruff check ...(All checks passed!)uv run --extra test loopx canary premerge --from-git-diff --git-diff-base origin/main --tier quick(ok: true,failures: 0)Author Declaration
model_agent(Gemini family, Google)