Skip to content

[Bug]: SSE control read-ahead (1 MiB) aborts a long turn as stream_transport, then the orphaned run blocks the session #1220

Open

Description

@guolvlin-cn

Is there an existing issue for the same bug?

Version and environment (optional)

Astra CLI 0.2.13, macOS 15 arm64, hosted Server + local Edge (transport=edge_ledger), model kimi-k3 for the affected run, TUI (prompt surface). Source references below are against main.

Actual behavior

A long turn (33m50s, ≥86k tokens context, 67 LLM rounds) died mid-flight with:

✖ Error · ✗ [stream_transport] Error: SSE control read-ahead exceeded 1048576 bytes while Edge work was running

The client recorded it as an interruption (session c0538fda-…, turn 11):

{"type":"interruption_recorded","ts":"2026-11-04T11:03:26.651865+00:00","turn":11,"agentic_step":1,
 "user_input":"interruption: stream_transport (resumable=true)",
 "metadata":{"interruption":{"error_detail":"Error: SSE control read-ahead exceeded 1048576 bytes while Edge work was running",
  "has_checkpoint":false,"kind":"stream_transport","resumable":true,
  "resume_action":"continue_immediately","resume_mode":"continue",
  "tool_calls_completed":0,"turns_completed":0,
  "user_message":"The model response connection failed. Continue this session to resume."}}}

After that, the session was unusable. Four consecutive messages were rejected:

✖ Error · Another run still owns this session
    Your message was not sent; the draft is back in the composer.
    Wait for it to finish, or stop it with `astra session cancel c0538fda-…`, then run
    `astra --resume c0538fda-…` before sending another message.
    No model or tool ran.

Meanwhile the server-side run kept executing with no client attached — run 93f034ae-… emitted durable step events from 10:29:36Z (turn 11, step 1) through 11:11:38Z (turn 11, step 66, round 7), ending with a turn_evaluation for that run at 11:11:38Z, i.e. ~8 minutes of tool/LLM work after the client had already recorded the interruption. astra session show still reports status: active, ended_at: null, updated_at frozen at 2026-11-04T11:11:40 (re-checked at 11:20:03Z). Only a manual cancel frees the session.

A second, smaller symptom in the same incident (different session): an approval settle returned 409, surfaced as a fatal user-facing error:

✖ Error · ✗ [invalid_request] Astra could not settle the approval callback because the callback endpoint
returned an HTTP error. … Details: request failed (409): Approval response was recorded, but newer user
guidance at event 32 superseded it
    error_code: run_interaction_superseded

and every tool call in that round was then rejected: Newer user guidance superseded this pending action; the tool was not executed. (cidcedfb07f, 4 × tool_call_error).

Root cause (code, main)

crates/astra-turn-core/src/sse/stream_host.rs

  • MAX_EDGE_EXECUTION_READ_AHEAD_BYTES = 1024 * 1024 (:55), fed in EDGE_EXECUTION_READ_AHEAD_FEED_BYTES = 64 * 1024 chunks (:58).
  • EdgeExecutionReadAhead::push_feed returns Err("SSE control read-ahead exceeded …") when queued_bytes + framing.len() + live_gap_bytes + bytes.len() exceeds the cap (:96-107); ensure_bounded applies the same check after every queued block (:149-166).
  • In consume_sse_stream_cancellable, that Err is promoted to a fatal abort: abort = Some(ErrorKind::StreamTransport), the Edge tool cancel token is cancelled, and the loop breaks (:1056-1066). The turn is discarded — no partial reply, no replay of the already-queued frames.
  • The lane already knows how to degrade: replaceable live observations are collapsed into live_gaps (record_live_gap_if_only_live, bounded by MAX_EDGE_EXECUTION_LIVE_GAP_KEYS/_BYTES). But ordered blocks (agent_live_event, lifecycle, tool results) accumulate to the hard cap instead of degrading.
  • The behavior is currently encoded as intended: the existing test ordered_live_read_ahead_overflow_cancels_running_edge_tool (:4691) drives overflow with 300 × 4 KiB agent_live_event frames and asserts abort == Some(StreamTransport). That means ordinary, chatty control traffic during a single Edge execution window deterministically kills a long turn.

I have not isolated which specific frames filled the lane in this incident (child-agent live events vs. large tool-result/lifecycle frames vs. durable replay of an 86k-token transcript), so the trigger is a hypothesis; the fatal-abort-on-cap behavior itself is confirmed from code and from the recorded interruption.

Expected behavior

  1. A defensive memory bound should not be able to fail a long-running turn. On cap pressure, prefer: drop/collapse replaceable live observations (already implemented for gaps), keep ordered lifecycle facts, and apply backpressure/replay — rather than aborting the whole run.
  2. If an abort is unavoidable, it should carry its own stable error_code (e.g. stream_read_ahead_overflow) instead of generic stream_transport, so the client can distinguish it and resume deterministically.
  3. The cap should account for legitimate traffic volume during one Edge window (child-agent live events can easily exceed 1 MiB over a long turn), or be configurable.
  4. When the client stream detaches, the server should settle/cancel the in-flight run so the session is immediately reusable — this is [Bug]: Orphaned run holds session after one-shot client stream drop (stream_transport); no reclaim until manual session cancel #987; here the orphaned run is a consequence of the read-ahead abort, and it outlived the client by 8+ minutes while all new user input was rejected.
  5. For the 409 run_interaction_superseded settle path, the TUI should auto-recover (the text is durable and newer guidance already superseded the approval) instead of surfacing a fatal [invalid_request] and leaving the round with every tool call rejected — same class as the uncoded-409 gap described in TUI hits two uncoded run-lifecycle 409s: 'completed' guidance rejection and stale-guard new-run rejection #884.

Steps to reproduce

  1. Astra TUI against a hosted Server with local Edge tool execution.
  2. Run a long multi-round turn whose control traffic during a single Edge execution window exceeds 1 MiB (e.g. child-agent agent_live_event frames, or a large tool-result/lifecycle burst).
  3. The turn aborts with SSE control read-ahead exceeded 1048576 bytes while Edge work was running; the reply is lost and tool_calls_completed: 0.
  4. Send any further message to that session → Another run still owns this session, repeatedly, each run reporting No model or tool ran.
  5. astra session show <id> → status: active, ended_at: null, updated_at frozen, while durable step events keep appearing server-side.
  6. Only astra session cancel <id> (then astra --resume <id>) restores the session.

Additional information

Timeline (UTC), session c0538fda-13d1-44da-ab75-38d8306d3735:

time event
10:29:36 run 93f034ae-… starts, turn 11 step 1
11:03:26 client records interruption_recorded / stream_transport read-ahead overflow (tool_calls_completed: 0, has_checkpoint: false)
11:03:26 → 11:11:38 server keeps emitting durable steps for the same run (through turn 11 step 66, round 7, 35 more LLM/tool events)
11:03:26 → 11:15 4 user messages rejected: Another run still owns this session
11:11:38 turn_evaluation recorded for run 93f034ae-…
11:20:03 astra session show → status: active, ended_at: null, updated_at: 11:11:40

The session also accumulated 13 approval_timeout and 22 tool_call_error events over its lifetime, which may be relevant to how much ordered control traffic one Edge window had to absorb.

Related: #987, #854, #884.

Activity

  1. guolvlin-cn commented on Nov 5, 2026

    @guolvlin-cn
    Author

    Recurrence on the same session — and the overflow path is still live on main

    Same machine, same CLI (astra 0.2.13, macOS 15 arm64, hosted Server + local Edge). After the 11:03:26Z interruption described above, the same session c0538fda-… hit the identical abort again, roughly two hours later, in the middle of an unrelated long turn (53m12s, ≥189.1k tokens context, 85 tool calls):

    ✖ Error · ✗ [stream_transport] Error: SSE control read-ahead exceeded 1048576 bytes while Edge work was running
    

    Evidence from the local session transcript

    ~/.astra/sessions/…/sessions/c0538fda-….jsonl:

    record type ts (UTC) bytes
    turn_error 2026-11-04T11:03:26 898
    turn_error 2026-11-04T12:53:36 6,026

    The literal string read-ahead exceeded occurs exactly twice in that file, matching those two turn_error records one-to-one.

    Largest single turn records in the same file — i.e. the ordered blocks that accumulate inside one Edge window, all individually well under the 1 MiB cap:

    ts (UTC) bytes
    12:07:31 537,908
    12:10:11 708,722
    12:15:24 728,523
    12:20:32 748,294

    So the overflow is reached by cumulative ordered blocks in a single Edge execution window, not only by one oversized frame.

    Verification against main (fetched today)

    crates/astra-turn-core/src/sse/stream_host.rs (224,030 bytes) is unchanged in the relevant places:

    • :55 const MAX_EDGE_EXECUTION_READ_AHEAD_BYTES: usize = 1024 * 1024;
    • :58 const EDGE_EXECUTION_READ_AHEAD_FEED_BYTES: usize = 64 * 1024;
    • :94-107 push_feed compares queued_bytes + framing.len() + live_gap_bytes + bytes.len() against the cap and returns Err("SSE control read-ahead exceeded …")
    • :158-162 the same comparison in ensure_bounded
    • :770, :794, :802, :821, :905, :930, :938 still promote transport errors to abort = Some(ErrorKind::StreamTransport)
    • :4691 ordered_live_read_ahead_overflow_cancels_running_edge_tool still asserts that 300 × 4 KiB agent_live_event frames cancel a running Edge tool
    • :2844 read_ahead_overflow_cannot_accept_a_probe_only_failed_terminal covers the single-oversized-frame case

    So this is not fixed as of today, and the current test suite still encodes the abort as the expected behavior.

    Repeated consequences

    1. The server-side run keeps executing after the client has already recorded interruption_recorded (stream_transport, resumable=true), so the work is not lost but is also not visible.
    2. The session then rejects new input with Another run still owns this session; recovery needs a manual astra session cancel + astra --resume.
    3. A detached approval callback surfaces as a fatal user-facing 409 run_interaction_superseded ("Approval response was recorded, but newer user guidance at event 32 superseded it"), and every tool call in that round is then rejected with Newer user guidance superseded this pending action.

    Suggested direction (non-binding)

    The lane already degrades replaceable live observations into live_gaps, but ordered blocks (agent_live_event, lifecycle, tool results) accumulate to a hard cap and then kill the turn. Two options, not mutually exclusive:

    • degrade instead of abort: when the cap is hit, flush the already-queued ordered blocks to the consumer (or suspend data-frame intake while the control probe is retried) rather than abort = Some(StreamTransport);
    • make the bound frame-aware rather than purely cumulative — a long but healthy turn with many small ordered frames should not be indistinguishable from a stalled control read.

    Either way the :4691 expectation has to change with it.

  2. added
    kind/bug
    on Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions