Repository navigation
Description
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
timeoutargument, whereas the observation tool acceptstimeout_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
- Extend existing lifecycle, execution, journal, and callback owners. Do not introduce a parallel agent backbone, redundant state machine, duplicate storage, or an additional SQL hot path.
- Preserve execution ownership, policy, sandbox, and authentication boundaries. Avoid blindly retrying tools or replaying unconfirmed side effects.
- Keep the solution simple, efficient, bounded, observable, and general. Give the model accurate information and usable controls instead of adding rigid, case-specific behavior.
- Related work: feat(runtime): simplify task execution, interaction, and context recovery #1234, [Bug]: Make delegated tool and background task outcomes reliable and actionable #1261, Fix misleading provider errors, interrupted runs, and unreliable agent tools #1286. Reassess current behavior before implementation; do not assume those issues are fully resolved.
Activity
[-]Fix execution reliability, truthful tool outcomes, and interruption recovery[/-][+][Bug]: Unreliable agent execution context, tool outcomes, and recovery[/+]XuPeng-SH commentedon Nov 13, 2026
补充 #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 反例:
read_file调用和唯一回执;本地估计 33,768 / 100,000,低于 pre-turn 阈值。ContextWindow错误。修复方向:在实际 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 反例:
修复方向:在现有恢复边界正确承接适用的预算节省,保留原始 provider usage 作为遥测;避免增加平行预算状态机或新的 SQL 观察。验收必须包含 reactive → 下一轮 proactive 的组合场景,确认已降压时不写归档,同时仍能处理真正剩余的压力。
验证证据与范围
两个 reviewer-only 回归测试均稳定触发断言失败:
recovered_budget_does_not_archive_again_before_a_new_measurementprovider_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、浏览器事故或历史性能指标已经全部修复的证明。XuPeng-SH commentedon Nov 15, 2026
已合并追踪至 #1302 的第 6 节。真实数据库不可用、owner 失效及恢复的完整链路仍需验收。
此关闭仅表示将追踪入口合并,不表示原问题已全部修复。原报告、讨论和尚未满足的验收条件继续作为新 issue 的证据与验收来源。