Skip to content

[Bug]: Preserve task continuity across stream errors and background execution #1296

Open

Description

@XuPeng-SH

Problem

Astra can perform the individual model and tool calls, but a user request can lose continuity across an interrupted model stream, a text-only response, and background execution. The user is left to notice that work stopped and repeatedly send “continue”, even when the original request was to carry the task through to its results.

This issue is about the contract between model responses, tool execution, background-task outcomes, and the user's task. It does not assume every imperfect model response is an infrastructure defect.

Observed sequence

A user requested an expanded validation matrix, including additional scenarios, data sizes, and white-box checks.

  1. During execution, an SSE JSON parse failed with EOF while parsing a string on a 57-byte data payload. The runtime scheduled a safe recovery round and subsequent model and tool rounds made progress.
  2. Several minutes later another SSE payload failed with the same class of error, this time at 81 bytes. The model had already emitted a partial progress message. The run failed after 30 tool calls rather than continuing the unfinished task.
  3. After the user said “continue”, the agent successfully inspected existing results and checked a service port. It then said it would start the expanded SQL matrix, but made no corresponding execution call. Astra recorded the text as the final response and the run as completed.
  4. After another “continue”, the agent did launch the validation and a supporting database service as background shell tasks. It reported that the matrix was running, but the agent run completed while the finite test was still running. The process remained alive; its final result had not yet been observed. A background notification can be shown to the user, but the completed turn is not automatically continued to interpret that result.

The first “continue” case is not evidence that an issued test command was lost: no command to start that matrix was recorded. The later case did start it. These are different failure modes with the same user-visible consequence: the task does not reach an actionable final result without the user supervising the agent.

What the evidence establishes

Stream errors and recovery

  • The SSE path parses JSON both after a framed event and from a remaining tail at EOF. Both can produce the same invalid JSON in SSE event diagnostic. The retained evidence does not establish whether this incident originated with the provider, an intermediary or connection termination, or Astra's framing. Do not assume a provider bug or a network fault without a reproducible capture.
  • One safe recovery was observed. The later failure followed partial visible text. The current recovery admission excludes attempts with actionable visible text or selected tools, rather than continuing from the known completed results and the partial delivery. Avoiding blind replay is necessary, but a progress message alone should not leave an otherwise recoverable task dependent on manual intervention.
  • Relevant code: SSE framing and JSON parsing and provider recovery admission.

Completion versus task progress

  • The runtime accepted a text-only response and finished the run even though the text announced a next action that had not been performed. A model response ending is a protocol fact, not independent proof that the requested work was completed.
  • The observed trace does not prove why the model produced that response, or whether its full next-request context retained every detail of the failed turn. Investigate context reconstruction and tool-result delivery without assuming either loss or completeness from a summary trace.
  • Relevant code: text-only turn settlement.

Background completion handoff

  • The executor returned task identities and kept the commands running. The finite validation remained outstanding when the agent turn finished. A long-lived supporting service and a finite test are different kinds of work; waiting for every background process would be incorrect.
  • The TUI currently displays late background notifications and carries them into a subsequent user input, rather than automatically starting a new turn after an answer. Relevant code: background notification handling.

Additional evidence from continued execution

A long-running request can be acknowledged before its workload exists

The user later explicitly requested tens of minutes of continued validation. The agent started one detached, finite race-test command, described a 30-minute mixed workload including multi-node traffic, transactions, DDL, backup, and resource sampling, and ended the run after about 47 seconds. At that point no corresponding mixed-workload command had been issued. The race test was real; it was not the promised timed workload. In a subsequent turn, the agent did create and start the mixed workload. This independently demonstrates that a progress statement, an actual tool call, and the user's requested outcome must remain distinguishable.

This is a model behavior observed through Astra's lifecycle, not proof that an already-issued workload was silently dropped. Preserve the ability to present a plan or deliberately leave work running, while making incomplete work and real execution status apparent and enabling the agent to continue the requested task without repeated user supervision.

A silently shortened service lifetime invalidates a long-running test

For a later requested 30-minute validation, the agent started its supporting service with a Bash timeout request of 3,600 seconds and then launched the test several minutes later. The admitted tool request carried a command_timeout_cap_ms of 1,800,000 ms, so the executor actually limited the service to 1,800 seconds. The detached-tool response said only that the task was running and how to control it; the recorded response and task context did not disclose that the requested lifetime had been halved.

The service reached its actual time limit before the test's 30-minute window ended. The retained service outcome reported tool_timeout, and the test log changed from zero failures at 1,602 seconds to connection failures after the service disappeared; by 1,783 seconds it had counted 1,937 failures. This is strong evidence that the infrastructure lifetime invalidated that attempt; it does not establish that every counted failure had the same cause or that the product under test had a regression.

The cap is an existing execution policy and must not be bypassed or merely raised. The failure is that the effective lifetime and its relation to the requested lifetime were not actionable to the agent when the dependency was launched. Expose the actual bound/deadline through the existing shell/task result, or reject an unsatisfiable lifetime request with the effective limit before execution, so the model can make an informed choice. Keep task, command, observation, and callback deadlines distinct. Test a service launched before a longer dependent workload with a deliberately lower policy cap; the model-visible result must reveal the actual lifetime and the test must not silently run against a timed-out dependency.

Relevant owners: server cap calculation, executor cap application, and detached result construction.

Background task control can fail at tool binding

An attempt to stop an agent-started background service was rejected before execution with deferred_tool_descriptor_stale; the reported changed descriptor components included execution ownership and executable contract. The agent subsequently stopped the service through a separate shell command after checking the process identity. The evidence establishes that the task-control call was not executed and a fallback was used; it does not establish whether the provider binding actually changed or the stale detection was a false positive.

The existing task-control channel should remain reliably usable when its underlying authorized owner and contract are unchanged, and produce an actionable, safe outcome when they really do change. Keep the existing ownership and authorization checks; do not silently route a stop to a different executor or task. This complements the deferred-tool observations tracked in #1291.

Mixed tool batches can corrupt lifecycle correlation

In two separate model rounds, one call was rejected before execution while another was admitted. The admitted call appeared twice as ToolCallStarted with the same call identity but different slot indexes, followed by one ToolCallCompleted. One case involved task_output; the other involved a shell call after the rejected stop request. The tool journal records one corresponding completed invocation, so these records do not demonstrate duplicate execution or duplicate side effects.

The code points to a likely ownership mismatch to verify with a targeted reproduction: pre-execution rejection recording increments the recorder's slot counter, while headless round setup constructs a cursor for the remaining calls. The recorder then assigns starts by the existing counter and resolves completions against the cursor; this is consistent with the observed start on slot 1 followed by a synthesized start and completion on slot 0. The effect on checkpoint recovery or replay has not been reproduced and must not be assumed.

Trace events, cursor state, and recovery evidence need one consistent identity and terminal outcome per actual invocation, including mixed admitted/rejected and parallel batches. Verify a real owner change still rejects the stop safely, and verify rejection followed by admitted calls does not duplicate starts or misassociate slots.

A background wait is reported as a cancelled parent run

During the later long-running validation, the model called task_output with block=true and timeout_ms=300000. After approximately 126 seconds the result was:

Tool 'task_output' not executed: run was cancelled
error_kind=cancelled, next_action=stop_or_resume_parent_turn

The same agent run continued to make model and tool calls after this response, and the monitored validation process was still running. Thus the message that the parent run was cancelled is incorrect; the evidence does not require assuming whether the observation had actually begun. This is a fresh occurrence of the timeout/cancellation issue tracked in #1290, now affecting a live long-running validation.

The recorded tool request carried an effective execution deadline of 125,000 ms despite the requested 300,000 ms observation. After the misleading result, the agent checked the process and log, then fell back to a blocking shell command that sleeps for five minutes before reading the log instead of using the background-task observation channel. That extra shell and wait are observed consequences; whether user steering can interrupt that particular wait has not been established.

The source explains the mismatch: server admission derives the execution window from a timeout field in seconds, whereas the task-control implementation consumes timeout_ms. The server can therefore apply its 120-second default rather than the requested observation duration. The edge control path reports a cancelled tool with execution_started=false when its cancellation token fires, conflating the per-call deadline with a cancelled parent run. This mechanism is consistent with the observed timing and response.

Use the existing tool contract and policy to derive and communicate the effective observation window. A wait reaching its own bound must not imply the monitored task or the parent run stopped. If a user actually cancels the run, preserve that distinct fact and responsive cancellation. Add a targeted integration test with controlled time for a bounded observation, a live underlying task, an expired observation deadline, and subsequent agent progress; do not fix this merely by increasing a hard-coded timeout.

Correlated database OOM, failed callback, and stranded work

A subsequent interruption during the same investigation was traced through the runtime, container events, and the Docker VM kernel OOM report:

  1. The database became slow enough that active-run control reads and owner-lease renewal timed out; a later renewal could not obtain a pool connection.
  2. The Docker VM experienced a global OOM. Kernel and container events show the runtime database's MatrixOne process was selected as the victim (exit 137); its container restarted and became healthy shortly afterward. This was not a proven per-container memory-limit breach.
  3. During the disruption a tool-result callback returned a database EOF, while the executor was fenced after losing durable run ownership. The client reported unknown / stream closed before run_finished and instructed the user to cancel and resume. Once durable state was available, the old run was recorded as failed with crash_recovery; a later message in the same session received a response. The client must treat the run as unknown while it cannot query the owner, but reconcile to the actual terminal state after recovery rather than persistently requiring cancel/resume.
  4. The locally recorded final shell observation had started and was cancelled; its successful delivery to the server was not confirmed. A separate test service, started by a supervisor in a new OS session, remained alive after the supervisor was gone and final test-result artifacts were absent. This proves a remaining process and incomplete result, not that every remaining process is safe to kill or that the cancelled observation was executed twice.

The OOM report showed five MatrixOne processes with about 7.20 GiB of combined RSS in a Docker VM with about 7.75 GiB available to Linux; free swap was down to 188 KiB. Three of those services, totaling approximately 4.02 GiB RSS in the kernel snapshot, were started by earlier, already-finished QA tasks in the same agent session and were still running. The kernel's triggering allocation came from one of those test services; the victim was the separate database needed by Astra. An allocation triggering the OOM is not proof of a leak or that one workload alone caused it. Attributing the underlying memory growth to a specific query or component requires pre-OOM profiling that is not currently available.

This exposes an execution-resource lifecycle gap as well as recovery failure: temporary test services can outlive the work that launched them and compete with the agent's own control-plane dependency. Use existing executor/tool and container ownership information to make task-created resources and cleanup outcomes visible, and clean up temporary resources when their lifetime is known. Preserve deliberately long-lived or externally owned services; do not add a blanket process/container killer or claim authoritative cleanup where descendants escaped the execution scope. The detached host test service and Docker VM memory are separate resource domains and must not be conflated.

Degraded database retries and lost accounting

  • During a ten-second database outage the Work runtime event projector logged 40 failed sweeps. Its current implementation attempts a database projection every 250 ms per instance, including after errors. This is additional retry and log pressure during a dependency outage; there is no evidence that it caused this OOM. Use bounded, cancellation-aware backoff or the existing wake-up mechanism when the database is unavailable; avoid adding SQL per session or per model token.
  • After the failed run, its persisted projection reported zero prompt tokens, completion tokens, and tool calls, while retained evidence contained 69 tool requests and 51 completed model rounds with nonzero output usage. Missing settlement/accounting must be represented as unknown or reconstructed from existing authoritative observations rather than as zero. Do not equate requests with successful tool executions.

Add end-to-end coverage for database unavailability across an in-flight callback, owner fencing and later recovery, including honest local/remote outcome reconciliation, user-visible terminal state, existing-accounting preservation, bounded retry load, and incomplete cleanup. Preserve idempotency and do not blindly repeat side effects after an uncertain callback.

Long observation falls back to fixed shell sleeps

After the background observation produced the incorrect cancellation result, the agent monitored the ongoing test by repeatedly running shell commands that sleep for five or six minutes before reading the log. The interrupted run recorded 11 such calls totaling about 57 minutes of elapsed waiting in a 75-minute run. Waiting is expected for a long test; this does not mean all 57 minutes were wasted. The issue is that a fixed shell sleep cannot wake the model immediately on a task failure or completion. In the first long attempt, the supporting service timed out, while the workload continued recording connection failures until a later check.

The existing background-task control should support a bounded event-driven wait for status, output or failure, and user steering/cancellation should remain responsive. Do not replace the wait with frequent database polling, force a fixed small timeout, or assume this incident proves that a particular foreground shell wait ignored user input.

The ordinary session transcript omits the interrupted run

After the failed long run, the bounded Server transcript reported no further pages and contained the earlier progress statement followed by the next user message, but no transcript item associated with the failed run. Separately retained run events recorded 69 tool requests and the terminal failure. The ordinary transcript therefore does not tell a user reviewing it that substantial work was interrupted, which outcomes were known, or where to inspect the retained run evidence.

This does not by itself prove that every model-facing recovery context lost all of those facts: the transcript is only one projection. Verify the actual continuation request and checkpoint path. Make the interrupted outcome and an actionable link to existing run/tool evidence available in the ordinary recovery experience without copying all tool output into the transcript, inventing another storage projection, or claiming an uncertain side effect succeeded.

Expected behavior

  • Preserve the user's original objective, completed tool outcomes, partial visible delivery, and outstanding work across recoverable provider interruptions. Continue from established facts when safe, without blindly replaying a tool or duplicating side effects. If the execution or delivery outcome is genuinely unknown, report that uncertainty accurately and use existing reconciliation mechanisms.
  • Give the model clear, timely progress and tool-result information and working controls to wait, inspect, stop, or continue. A progress-only reply should not be presented as successful delivery of an unperformed task.
  • While an active request depends on a finite background task, make its completion available to the active agent so it can assess the result and finish the requested work. Preserve user steering and cancellation. Honor a deliberate request to leave work in the background; do not wait indefinitely for support services or automatically reopen an already completed conversation merely because any background process changes state.
  • Distinguish incomplete transport, a truncated EOF tail, and a complete but malformed SSE event when evidence allows. Retain enough bounded, sanitized metadata to diagnose the failure without exposing prompt, credential, or response contents. Report unknown causes as unknown.

Design constraints

Use existing run, executor, tool, and event ownership. Keep the solution simple, bounded, efficient, and robust; avoid additional state machines, storage projections, SQL traffic, busy polling, or provider-specific special cases. Do not introduce text-pattern rules that keep an agent alive whenever it says “next”, or unconditional retries that can duplicate actions. Preserve model autonomy and make the underlying facts and communication channel reliable.

Validation

Exercise the end-to-end lifecycle, rather than only isolated parser or mock completion tests:

  • An SSE interruption before and after visible progress: completed tool work and context remain available, recovery is bounded, and side effects are not replayed.
  • Incomplete EOF tail versus a complete malformed event, with ordinary chunk fragmentation and no raw sensitive content in diagnostics.
  • An agent that reports progress before the requested action: tool execution and final delivery remain accurately represented.
  • A finite background test plus a long-lived service: the test result reaches the active agent, user input and cancellation remain responsive, and the service does not hold completion open indefinitely.
  • Explicitly backgrounded work and an already completed user turn: notifications are truthful and do not create an unsolicited continuation.

Related: #1286, #1290, #1291, and #1261 cover other provider, callback, Work, and background-task failures; this issue tracks the continuity and completion boundary demonstrated above.

Activity

  1. self-assigned this
    on Nov 14, 2026
  2. MatrixAdventurer commented on Nov 15, 2026

    @MatrixAdventurer
    Contributor

    分级建议:s1(本仓库暂无严重级标签,可参照 matrixone 口径)——任务连续性契约已有量化破坏证据:请求 3600s 的后台服务被静默限到 1800s,致依赖它的测试大量失败。
    模块:crates/runtime(executive cap 计算、turn settlement)、crates/astra-cli/src/tui/event_loop.rs。
    疑似重复:未发现同范围单;#1291 关注 Work 持续性状态,互补不重复。
    建议负责人:XuPeng-SH(作者,亦为同族 #1291/#1199 的 assignee)。
    本操作由LW授权的MOI智能体提交

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