Skip to content

[Bug]: Orphaned run holds session after one-shot client stream drop (stream_transport); no reclaim until manual session cancel #987

Open

Description

@endlesschasey-ai

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Version and environment (optional)

Astra 0.2.10 (MOI-bundled CLI) talking to a hosted Server with UC login; tools execute on the local Edge/CLI; macOS arm64. The code paths cited below are unchanged in 0.2.11 / main @ 2873a95.

Actual behavior

astra chat -y --session-id 780ba093-0daa-4488-a01e-a04218c3fc51 --model glm-5.3 -m "<long task>" (one-shot, auto-approve) printed only:

Turn finished partially (stream_transport). Inspect partial output before continuing.

and exited 5 almost immediately. No tool calls had executed and no files changed — the client stream appears to have dropped right at turn start and the CLI classified it as stream_transport interruption.

Re-sending a message to the same session then failed:

Error: [invalid_request] Error: another run still owns session 780ba093-0daa-4488-a01e-a04218c3fc51; wait for it to finish, or stop it with `astra session cancel 780ba093-0daa-4488-a01e-a04218c3fc51`, then run `astra --resume 780ba093-0daa-4488-a01e-a04218c3fc51` before sending another message   (exit 3)

astra session show kept "status": "active" with an unchanged updated_at (09:20:19 UTC) for over a minute; nothing progressed, and since tools execute on the local Edge/CLI — which had already exited — the run could not make progress. Only astra session cancel released the session; after that, the same chat --session-id command worked.

Severity: unattended automation (one-shot astra chat -y) hangs until a human cancels the session.

Expected behavior

When the owning client's stream drops (stream_transport), the server should settle or cancel the in-flight run, or reclaim it via a short lease/heartbeat timeout, so the session becomes usable again without a manual astra session cancel. A dropped stream must not leave the run active with zero progress while its tool executor is gone.

Steps to reproduce

  1. Start a one-shot astra chat -y --session-id <id> --model <model> -m "<long task>" against a hosted Server with Edge tool execution.
  2. Have the client stream drop right after turn start (observed: CLI exits 5 with Turn finished partially (stream_transport), no tool activity).
  3. Re-run the same command → 409 another run still owns session <id> (exit 3).
  4. astra session show <id> → status stays active, updated_at frozen for minutes.

Additional information

Root cause as confirmed from code (main @ 2873a95):

  • Admission is fenced by the session writer lease: a live lease is treated as an active run and rejects new messages with 409 session_writer_conflict — see the doc comment "A canonical writer acquisition conflict. A live lease is an active run." and the error text at crates/runtime/src/server/run/lifecycle/admission.rs:459-478.
  • The lease is only released when the run itself finishes (release_writer_on_finish): crates/runtime/src/server/run/lifecycle/mod.rs:5674-5694 and crates/runtime/src/server/run/lifecycle/mod.rs:6524-6525. No release path is tied to SSE client disconnect.
  • The only bound on an abandoned lease is the TTL: MAX_LEASE_TTL = 15 min (crates/services/src/session_context_coordinator.rs:99-100), so a stuck run can hold the session for up to 15 minutes with no user-visible progress.

Hypothesis (not confirmed from code): after the client stream dropped, the server-side run never reached terminal settlement — it stayed parked waiting for a counterpart that would never deliver (LLM stream or edge tool ledger), so it kept the writer lease and the session stayed active. I did not find server-side client-disconnect detection for the chat stream that would cancel the run; absence in the paths inspected is not proof it does not exist elsewhere.

CLI-side mapping for reference: the partial verdict line is crates/astra-cli/src/cli/command_router.rs:914-922, and any final_state == "interrupted" maps to ExitCode::Partial at crates/astra-cli/src/cli/command_router.rs:3271-3273.

Related but distinct: #916 (stopping the CLI mid tool call leaves the run going without a runner) and #854 (approval-callback detach leaving resumed sessions blocked by the active run). This report is specifically the turn-start stream drop case with no tool calls executed.

Activity

  1. added
    kind/bug
    on Oct 12, 2026
  2. XuPeng-SH commented on Oct 20, 2026

    @XuPeng-SH
    Collaborator

    Contract clarification: losing an observation stream is not authorization to cancel a durable run. Automatic cancellation solely on stream_transport would conflict with the existing detach/recovery contract. The reported unusable-session symptom still deserves a controlled turn-start disconnect reproduction correlating admission, provider/executor attachment, ownership and recovery; frozen updated_at and the maximum lease TTL do not establish its cause or deployed timeout. Keep the incident open for that evidence and repair only a demonstrated recovery/lifecycle gap.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions