Skip to content

[Bug]: Unreliable agent execution context, tool outcomes, and recovery #1290

Closed as duplicate

Description

@XuPeng-SH

Summary

Astra needs a coherent execution contract across the agent loop, server, edge executor, and external tools. Currently, incorrect assumptions about the execution environment, inconsistent tool outcomes, and failures while settling results can compound into interrupted work, misleading feedback, and difficult recovery.

These are system-level issues: the agent must have enough freedom to perform real work, but it also needs accurate execution context, reliable tool communication, and a straightforward way to recover. Individual model mistakes and external service failures should not be mistaken for proof of an Astra defect; the focus is on the infrastructure and information that make those mistakes consequential or prevent recovery.

Observed behavior

Execution target and side effects

  • An agent prepared an isolated test target and supplied a configuration override to an external test runner. The runner ignored that override, loaded its default target, and began cleanup against a shared database used by Astra.
  • The cleanup attempted to remove an application database. The connection failed and the database process was subsequently terminated and restarted.
  • Evidence boundary: the attempt and disconnect were observed. Whether the deletion committed, whether other data was affected, and whether that operation directly caused the process termination were not established.
  • The underlying gap is not that the shell routed the command incorrectly: the agent assumed an override was effective without verifying the actual target or the runner's cleanup behavior. A shared control-plane dependency increased the blast radius.

Observation deadlines are reported as cancellation

  • A background-task observation requested a 300-second wait. On two occasions it returned after approximately 125 seconds saying the run was cancelled, while the run continued.
  • The server-side deadline calculation uses a default for calls without a timeout argument, whereas the observation tool accepts timeout_ms. Expiry of the tool's child cancellation token is then surfaced as cancellation of the parent run, including an incorrect “not executed” message.
  • This wastes time and makes the model's picture of both the run and background task unreliable. Observation ending, the task stopping, and the run being cancelled are distinct facts.

Relevant owners: crates/runtime/src/server/server_loop_host.rs, crates/astra-cli/src/cli/stream/stream_render.rs, and crates/astra-cli/src/edge_tools.rs.

Dependency failure breaks result settlement and continuation

  • When the runtime database became unavailable, the tool-result callback returned a database error while the run also lost the ability to renew execution ownership. The client detached and displayed a generic stream error with instructions to manually cancel and resume.
  • The local executor recorded that the command had started, was interrupted, and may have produced side effects. The server could not confirm the result during the outage.
  • Existing callback retries and idempotency do not by themselves make this case recover: execution ownership can be fenced while delivery is unresolved. After the database recovered, the old run was eventually marked failed; a later message worked, but the interrupted task was not automatically handed off.
  • This does not establish that an uncertain external operation can be repeated safely, or that every interrupted run can be resumed without sufficient retained evidence.

Errors and accounting diverge from recorded execution

  • The primary displayed error was unknown / stream closed before run_finished, while the actionable database failure appeared only in appended callback details.
  • A recovered run's summary showed zero tool calls and zero token totals, while retained events included 50 tool requests and multiple completed model rounds. Missing or unfinalized accounting must not be presented as measured zero.
  • The model and user need consistent facts about whether work started, what is known, whether side effects are possible, and what can be done next.

Context and delegated work lose useful information

  • A cumulative tool-output budget automatically downgraded full-file reads to outlines repeatedly within a long turn; one file was requested four times and returned as an outline each time. The response did explain that ranged reads were available, but the model did not adjust. The behavior reflects both a system design tradeoff and model behavior, not a missing hint alone.
  • The cumulative counter is scoped to the executor/turn and is not tied to the content still retained in the active context, so compaction within a long turn does not by itself reset that pressure.
  • Delegated review initially inspected the wrong checkout and lacked the tooling needed to obtain the requested target; the parent supplied the correct workspace and the review continued. Tool availability, target version, and workspace should be clear at the delegation boundary.
  • A selected task-observation tool was also rejected after its binding was reported stale and worked after reselection. The exact reason the binding changed is not established; retain authority checks while investigating whether selection lifetime and actionable feedback are coherent.

Expected behavior

  • Preserve a single, truthful ownership model for tool execution and run control. Distinguish observation timeout, process exit, explicit cancellation, transport failure, loss of ownership, and unknown outcome.
  • On transient callback or storage failure, use the existing request identity and idempotency contract to reconcile delivery without re-executing the original tool. A fenced owner must not silently deliver an old result as a new execution.
  • When the run can no longer continue, make the next interaction usable and carry forward the task, known tool outcomes, and any unresolved uncertainty. Do not require users to infer run state from a fixed sequence of manual commands.
  • Give the model actionable errors and preserve known output and status. Mark unavailable or incomplete statistics as such; do not fabricate completion or zero usage.
  • Make the selected workspace, effective capabilities, and execution boundary visible. Support isolated, writable environments for work that may affect shared resources, without relying on command-specific pattern matching or disabling legitimate access to explicitly selected resources.
  • Bound tool output and history based on their actual purpose and retained context. Keep targeted reads available and make truncation or incompleteness explicit.

Validation

Use focused behavior-level coverage across the existing boundaries:

  • Observation deadline expires while a task and run remain live; separately exercise real task cancellation and run cancellation.
  • Result delivery is delayed or fails before and after the server may have accepted it; cover ownership loss, late delivery, and recovery without duplicated side effects.
  • The runtime dependency becomes unavailable during execution and later recovers; verify truthful status, retained evidence, and usable continuation.
  • A destructive test workload uses an explicitly selected isolated target; verify that target and cleanup scope are correct without requiring application-specific command allowlists.
  • Long-turn output pressure and compaction preserve access to targeted content; delegation receives the intended workspace and actual tool capabilities.
  • Error classification and counters remain consistent with available execution evidence, including partial or unavailable data.

Design constraints

Activity

  1. changed the title [-]Fix execution reliability, truthful tool outcomes, and interruption recovery[/-] [+][Bug]: Unreliable agent execution context, tool outcomes, and recovery[/+] on Nov 13, 2026
  2. self-assigned this
    on Nov 13, 2026
  3. XuPeng-SH commented on Nov 13, 2026

    @XuPeng-SH
    CollaboratorAuthor

    补充 #1289 合并后的 deep review 结果。审查提交为 5e6a12751e395361d363b77d99e970781fd29c5c,在 57 机器独立审查并验证,未使用 subagent,未修改或推送 PR 分支。发现两项可复现的 P2 问题,记录在本 issue 作为 follow-up。

    1. P2:真实 context-window 错误没有接入已有的无损归档恢复

    位置:compaction_replay.rs:229,调用方:execution_phase.rs:4686。

    重试 pipeline 改为仅精确去重后,唯一工具证据会直接返回 Futile。调用方随后记录 RequiresIntervention,要求用户换模型或缩减请求,没有尝试现有 spill_old_messages_to_artifact。预估压力未达到阈值,并不能排除真实 provider 的 context-window 拒绝;代码也明确承认 provider-owned input 可能不在本地估计中。

    已执行完整 agent loop 反例:

    • 历史包含 20 对不同的 read_file 调用和唯一回执;本地估计 33,768 / 100,000,低于 pre-turn 阈值。
    • 已具备归档 reader/writer admission 和有效 canonical rewrite permit。
    • 分别注入请求准备阶段直接返回、流式返回的 typed ContextWindow 错误。
    • 两种入口均在 1 次请求、0 次归档 后结束。
    • 对完全相同的历史调用现有归档 owner,均成功释放 11,475 个估计 token,证明并非没有可用的无损候选。
    • 现有 overflow 测试使用重复回执,精确去重即可恢复,掩盖了唯一证据的分支。

    修复方向:在实际 context-window 错误的恢复入口复用已有归档 owner,再决定是否真的无法推进;沿用其权限、rewrite permit、取消和 deadline 检查。验收应覆盖两个失败入口、唯一回执、归档成功后的重建请求,以及存储失败或取消时原历史保持完整。

    2. P2:反应式压缩的节省跨轮次失效,导致已降压后额外写归档

    位置:lifecycle.rs:2041,关联压力 floor:lifecycle.rs:2567。

    handle_token_budget 已重写被测量的历史并返回 ContinueLoop 后,下一轮重新使用原始 last_measured_prompt_tokens。新的 proactive 归档分支只扣除本次调用的节省,没有承接上一轮已确认的压缩收益。

    已执行完整 agent loop 反例:

    • 输入上限 80,000,初始本地估计 59,080,低于 proactive 阈值。
    • provider 回报 90,000 后,反应式精确去重释放 40,698,剩余 49,302,已经低于 60,000 的 proactive 阈值。
    • 尚未取得新 provider 测量,下一轮又以 90,000 判断压力,额外写入 1 份历史归档并替换原本仍能放入上下文的证据。
    • 其他条件相同、回报 70,000 的对照在 proactive pass 去重,写入 0 份归档。
    • Server host 的该调用会进入实际数据库 artifact transaction,因此影响包括不必要的 SQL、持久化和后续证据恢复成本。

    修复方向:在现有恢复边界正确承接适用的预算节省,保留原始 provider usage 作为遥测;避免增加平行预算状态机或新的 SQL 观察。验收必须包含 reactive → 下一轮 proactive 的组合场景,确认已降压时不写归档,同时仍能处理真正剩余的压力。

    验证证据与范围

    两个 reviewer-only 回归测试均稳定触发断言失败:

    • recovered_budget_does_not_archive_again_before_a_new_measurement
    • provider_overflow_uses_the_available_lossless_artifact_recovery

    现有 context_overflow_preparation_and_streaming_rebuild_the_next_request 和 exact_duplicates_relieving_pressure_do_not_write_a_history_artifact 均通过。测试使用现有 scripted host 和实际 agent loop / artifact rewrite owner;这轮没有重新运行真实数据库或外部模型场景。

    57 机器证据目录:

    /home/xupeng/.codex/reviews/Astra/1289/5e6a12751e395361d363b77d99e970781fd29c5c/

    保留了 review-probes.patch、两个反例日志和两个对照日志,可在同一提交的隔离 worktree 重放。生产、测试增删和设计文档分别审查;原先的 review/comment 线程为空。本轮发现的是恢复入口与预算衔接的真实缺口,不构成对原始 MCP、浏览器事故或历史性能指标已经全部修复的证明。

  4. XuPeng-SH commented on Nov 15, 2026

    @XuPeng-SH
    CollaboratorAuthor

    已合并追踪至 #1302 的第 6 节。真实数据库不可用、owner 失效及恢复的完整链路仍需验收。

    此关闭仅表示将追踪入口合并,不表示原问题已全部修复。原报告、讨论和尚未满足的验收条件继续作为新 issue 的证据与验收来源。

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions