Skip to content

fix(antigravity): preserve in-flight same-execution steering inputs across native chat turns - #10293

Merged
loopx-agent merged 1 commit into
mainfrom
codex/fix-agy-same-exec-steering-20261206
Dec 6, 2026
Merged

loopx-agent merged 1 commit into
mainfrom
codex/fix-agy-same-exec-steering-20261206

Conversation

@loopx-agent

Copy link
Copy Markdown
Collaborator

Delivery Brief

  • Goal / Source: Fix a trusted_owner native Chat / Lark Steward failure (upstream_transport_failure: The native Antigravity input changed; no result was adopted or invocation cancelled.) triggered whenever the operator sends an in-flight steering follow-up message directly inside the active Antigravity conversation while a LoopX Chat turn is running.
  • Current Gap:
    1. When an Antigravity cascade invocation is actively running (executionId = E_0) and the operator queues an explicit mid-turn follow-up message in Antigravity, the Antigravity Language Server appends a CORTEX_STEP_TYPE_USER_INPUT step (metadata.source == "CORTEX_STEP_SOURCE_USER_EXPLICIT") carrying the exact same server-minted metadata.executionId == E_0 into the active invocation, and the model incorporates that steering instruction into a single unified terminal response.
    2. _split_turn_segments() (loopx/capabilities/native_chat/antigravity_cascade.py) previously rejected every pos > 0 CORTEX_STEP_TYPE_USER_INPUT other than post-error ANTIGRAVITY_TRANSIENT_CONTINUE_PROMPT (return None), and _process_turn_steps() rejected any segment containing more than one CORTEX_STEP_TYPE_USER_INPUT regardless of runtime_profile. Meanwhile, _turn_opening_inputs() (loopx/capabilities/native_chat/antigravity_observations.py) treated same-execution steering USER_INPUT steps as separate turn boundaries, truncating post-hoc completed_result_observation, interrupted_answer_observation, and metadata_review_capacity reads.
  • Observable Result:
    1. Added _is_same_execution_steering_input() in loopx/capabilities/native_chat/antigravity_cascade.py requiring all invariants simultaneously: segment opened by CORTEX_STEP_TYPE_USER_INPUT with non-empty executionId, non-continuation USER_INPUT, non-error preceding effective step (!= CORTEX_STEP_TYPE_ERROR_MESSAGE), metadata.source == "CORTEX_STEP_SOURCE_USER_EXPLICIT", identical metadata.executionId, non-empty prompt text, and valid active/completed step status (CORTEX_STEP_STATUS_DONE required at turn completion).
    2. _split_turn_segments() and _turn_opening_inputs() keep verified same-execution steering inputs inside the active segment, while _process_turn_steps() preserves strict single-input isolation for runtime_profile == "restricted" and read_only_review == True (feature-off / untrusted isolation parity).
    3. Foreign or missing executionId, system/non-explicit sources, cancelled/cleared/errored USER_INPUT steps, and post-error non-continuation inputs continue failing closed.
  • Owning Boundary: loopx/capabilities/native_chat/antigravity_cascade.py and loopx/capabilities/native_chat/antigravity_observations.py.

Validation

  • pytest -q tests/test_antigravity_adapter_contract.py tests/test_antigravity_steward_adapter.py tests/test_steward_interrupted_answer.py (including strict zero-error mypy caller contract check, <1000 LOC module ceiling check, live trusted_owner steered turn completion, restricted feature-off rejection, foreign/missing executionId & cancelled-status fail-closed checks, and post-hoc completed_result_observation / interrupted_answer_observation / metadata_review_capacity verification).
  • ruff check, git diff --check, public/private boundary scan (loopx check), and loopx canary premerge.

…cross native chat turns

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>

@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 · Gemini · Google · self_reported

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

动机

使用飞书或 Workbench 接入 Antigravity 原会话的 trusted_owner 维护者,在一轮管家对话运行中直接在 Antigravity 会话里补充实时纠偏指令(Steer)时触发此问题。

修复前,Antigravity 语言服务在同一执行流(相同 metadata.executionId)内合法追加显式 USER_INPUT 步骤并生成最终综合回答后,旧版分段器把首条之后的非网络重试 USER_INPUT 一律拒绝,导致上层报 upstream_transport_failure 且飞书话题收不到完整答复;修复后,受验证的同执行流显式追问保留在同一执行段内完成投递与离线读回。

本 PR 在不放宽异源输入、取消状态或受限会话(restricted 与只读格式审查)单输入隔离的前提下,恢复 trusted_owner 同执行流实时追问的正常流式答复采纳与离线完成度、中断度及配额读回。

本次范围限于同一 cascade 同一 executionId 内的显式用户实时追问分段与读回,不引入跨 executionId 多轮合并、后台自动重放或新的权限模型。

改动思路

审阅精确 head d7c97da84c75d9a3173b47bcc64a822f176cfd87。入口位于 antigravity_cascade.py 的 _split_turn_segments、_turn_steps_allow_completion 与 _process_turn_steps,以及 antigravity_observations.py 的 _turn_opening_inputs。权威输入依据是 Antigravity Language Server 为单次执行流分配的 metadata.executionId、metadata.source == "CORTEX_STEP_SOURCE_USER_EXPLICIT"、步骤状态与前驱有效步骤类型。该设计复用既有分段与完成度校验骨架,不引入新的持久化状态或配置项:核心分段不变量保留在 antigravity_cascade._is_same_execution_steering_input,会话信任策略保留在 _process_turn_steps,只读投影复用同一谓词。本次边界覆盖同一 Antigravity cascade 同一 executionId 内的显式用户实时追问及其三类只读观测接口。其中 runtime_profile == "restricted" 与 read_only_review == True 继续保持严格单 USER_INPUT 隔离,任何异常或未决状态一律 fail-closed。

场景分支(基于精确 head d7c97da84c75d9a3173b47bcc64a822f176cfd87 源码推导,示意控制流) 关键判定条件 旧行为 新行为
trusted_owner 同执行流显式追问 同非空 executionId + USER_EXPLICIT + 前驱非 ERROR_MESSAGE + 终态 DONE _split_turn_segments 返回 None,抛 upstream_transport_failure 归入当前执行段,正常采纳综合终态答复并支持离线读回
restricted 或 read_only_review 出现多条 USER_INPUT runtime_profile == "restricted" 或只读审查后缀校验 抛 upstream_transport_failure 保持原判:立即退役当前轮并抛 upstream_transport_failure
异源/缺失 executionId、系统源或 CANCELED 状态 任一谓词不满足 抛 upstream_transport_failure 保持 fail-closed,拒绝采纳且不静默吞错

具体改动

相对主干 f9d5c99f23759765bca801d8acbac55db69fb939,本 PR 共修改 3 个文件(+341/-82),没有独立的外部书面规范文件(no_spec),完整修复实测复现的同执行流追问断连缺陷,同时将两个核心生产模块严格控制在 < 1000 行与零 Any 契约之内(antigravity_cascade.py 972 行,antigravity_observations.py 941 行)。

关键代码讲解

  • _is_same_execution_steering_input(loopx/capabilities/native_chat/antigravity_cascade.py 第 160 行):集中校验段首步骤为带非空 executionId 的 USER_INPUT、当前步骤非网络续跑提示词、前驱有效步骤存在且非 CORTEX_STEP_TYPE_ERROR_MESSAGE、当前步骤具备相同 executionId 与 CORTEX_STEP_SOURCE_USER_EXPLICIT、文本非空且状态合法。
  • _split_turn_segments 与 _process_turn_steps(loopx/capabilities/native_chat/antigravity_cascade.py 第 195 行、第 742 行):前者将满足上述谓词的步骤留在当前段内而非直接返回 None;后者在 runtime_profile == "restricted" 时显式拒绝单段内超过 1 条 CORTEX_STEP_TYPE_USER_INPUT,并在活跃段内对额外 USER_INPUT 发出 turn.steered 活动事件。
  • _turn_opening_inputs、observe_interrupted_answer 与 observe_metadata_review_capacity(loopx/capabilities/native_chat/antigravity_observations.py 第 92 行、第 122 行、第 649 行):跳过已完成的同执行流显式追问作为新轮次起点,使 observe_completed_result、observe_interrupted_answer 与 observe_metadata_review_capacity 对完整执行段做一致校验,同时在后续出现新 executionId 独立轮次时仍准确按新轮起点切分。
  • test_same_execution_steering_input_completes_on_trusted_owner_and_fails_closed_otherwise(tests/test_antigravity_steward_adapter.py 第 5948 行):覆盖真实本地 HTTP 桩上的 trusted_owner 流式追问完成、restricted 隔离拒绝、4 类伪造/取消负例(异源 executionId、空 executionId、SYSTEM 源、CANCELED 状态)及三类只读观测接口读回。

对主干的风险

核心回归风险在于放宽段内第二条 USER_INPUT 时,若误把错误后的独立新轮次、外部并发新轮次或未完成/已取消的输入并入当前轮,会造成串轮采纳或静默吞掉用户新请求。代码通过四道硬围栏阻断该风险:第一,前驱有效步骤一旦为 ERROR_MESSAGE 即禁止走同执行流追问分支(仅允许既有的 ANTIGRAVITY_TRANSIENT_CONTINUE_PROMPT 续跑段);第二,强制比对服务端生成的非空 executionId 与 CORTEX_STEP_SOURCE_USER_EXPLICIT;第三,在 _step_allows_completed_turn 与 _turn_steps_allow_completion 中要求段内所有 USER_INPUT 终态必须为 CORTEX_STEP_STATUS_DONE;第四,生产调用方 AntigravityAdapter._run_turn 对 restricted 与 read_only_review 保持单输入拒绝,负向回归用例已逐项验证。本地验证矩阵:398 个 Antigravity 与 Steward 中断读回相关 pytest 用例全部 PASS(含 19 个调用方零错误 mypy 静态契约与 <1000 行模块上限检查),ruff check、git diff --check、loopx check 公私边界扫描及 loopx canary premerge(含 control-plane-maintainability-ratchet-smoke 与 semantic-vocabulary-drift-smoke)全部 PASS。按 Goal 配置 wait_for_ci=false(ci_policy: not_consulted),未查询或等待远端 GitHub Actions。

我的整体评价

APPROVE。 在长程自治维度(long_horizon: improved),维护者运行中补充约束不再导致整轮长程调研作废或被迫重跑;在用户体验维度(user_experience: improved,无前端渲染变更故 visual_review: not_applicable),飞书与原会话协同恢复顺畅且保持 restricted 默认隔离等价。代码体量精简、复用充分,未新增共享协议词汇(semantic_alignment: not_applicable)。当前精确 head d7c97da84c75d9a3173b47bcc64a822f176cfd87 本地验证完备,无残余阻断项;若后续变更触及分段谓词或 antigravity_adapter.py 入口,需重新执行完整适配器契约与负向隔离测试。

English verdict: APPROVE - exact head d7c97da84c75d9a3173b47bcc64a822f176cfd87 cleanly preserves in-flight same-executionId explicit user steering on trusted_owner turns and post-hoc observations while keeping restricted, read_only_review, foreign executionId, and non-DONE inputs fail-closed; 398 local pytest cases, strict mypy contract checks, ruff, boundary scan, and canary premerge all pass.

@loopx-agent
loopx-agent merged commit c47d382 into main Dec 6, 2026
20 of 24 checks passed
@loopx-agent
loopx-agent deleted the codex/fix-agy-same-exec-steering-20261206 branch December 6, 2026 13:01
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