Skip to content

[Bug] ask_user 等待期间追加指导后触发 waiting 状态冲突,运行以 contract_violation 终止 #985

Closed

Description

@mzy-gith

Agent | Codex | GPT-6

问题

Astra 交互执行中,ask_user 等待用户输入期间收到追加指导,CLI 显示指导已接收但尚未应用,随后 ask_user 失败,整轮运行以 contract_violation 结束。追加指导被恢复为未发送草稿,用户需要重新发送才能继续。

环境与定位信息

  • CLI:0.2.8,macOS
  • 服务:生产 https://astra.moi.matrixorigin.cn
  • 当时 astra health 返回服务端 build:e6b468123315ecbed8ab530a30374ccbbde0e2a4
  • 模型:deepseek-v4.1-flash
  • 时间:2026-10-12 17:14:41(Asia/Shanghai)
  • Run:98e8b401-61fa-440c-91ca-a2d778d8a321
  • Session:5a812753-4781-4a8c-94e0-d11ced045b77
  • 本轮耗时约 13 分 53 秒;Ask User 显示耗时 61.2 秒

用户现场操作与实际结果

  1. 在 Astra CLI 中执行调试任务。
  2. Astra 调用 ask_user,询问本次调试应使用生产还是 QA 环境。
  3. 执行期间用户追加指导;本地记录的投递方式为 guide_current_run。
  4. CLI 显示指导已接收,随后出现下列错误,运行终止,指导恢复为草稿。
  5. 用户重新发送说明后,后续运行能够继续。

以上来自用户现场截图及本地运行记录。尚未在独立环境完整复现;追加指导、问卷回应和等待结束的精确服务端事件顺序仍需按 Run ID 核对。

脱敏日志:

Guidance accepted; not yet applied. It replaces stale work before next unstarted action.

ask_user failed: user prompt response arrived after this run stopped waiting

The run ended before applying your guidance; it was restored as an unsent draft.

[contract_violation] [contract_violation] authoritative user guidance could not be durably acknowledged before the action boundary: cannot apply user intents while run 98e8b401-61fa-440c-91ca-a2d778d8a321 is waiting

原截图包含账号及凭证信息,因此仅提供脱敏文字证据。本地 intent 元数据虽标记为 applied,但与最终 durable acknowledgement 失败信息矛盾,不能据此认定指导已成功应用。

代码排查:疑似状态转换缺口,待服务端事件确认

检查当时服务端版本及最新 main(2873a950f2c9fea00343757933e96070d1631596,release metadata 0.2.11),以下相关处理仍存在。最新代码尚未做端到端复现,不能据此断言当前部署必然复现。

  • services/runs.rs:resolve_run_interaction 判断交互被更新的 intent supersede 后,设置 resume_wait=false,run 保留 waiting;apply_run_user_intents 仅允许 running。
  • runtime lifecycle:request_questionnaire 将 Superseded 映射为 no_longer_active(),对外显示“response arrived after this run stopped waiting”。
  • runtime engine:应用指导遇到 Inactive { status: waiting } 时返回 cannot apply user intents ... is waiting。
  • execution phase:动作边界强制处理指导失败后升级为 contract violation。

候选链路:ask_user → waiting → 新指导 supersede 旧交互 → 未恢复 running → 应用指导被 waiting guard 拒绝 → contract_violation。

现有 newer_intent_makes_approval_callback_durable_but_superseded 测试覆盖的是 approval 的 superseded 状态,不等于已覆盖完整 ask_user 与追加指导链路。需要结合上述 Run 的 durable event sequence 确认实际分支。

附带观察:截图中较早一次 ask_user 曾因 questions[0] 含未知字段 header 报参数错误。该错误与此次状态冲突分开记录,目前无证据证明它是本次失败根因。

期望与验收

  • 等待问卷时追加指导,应通过合法状态转换持久接收并应用,或明确提示需重新回答;不应以内部 contract violation 终止整轮。
  • 被 supersede 的交互应有准确提示,避免一律误报为用户回应太晚。
  • 指导状态、服务端 durable acknowledgement 与 CLI 展示保持一致,既不丢失也不重复应用。
  • 回归覆盖:等待 ask_user 时追加指导;等待结束/超时附近回应;正常及时回应;旧交互被新指导替代后的恢复执行。
  • 修复需保留 owner/交互权限边界,不能简单放开所有 waiting 状态下的 intent apply。

检索了现有 open issues:#919 是工具回调 HTTP 405,#785 是执行总结缺失,与本次触发条件及错误链不同。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

kind/bug

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions