Skip to content

Session in status:failed remains bound as agent:main:main, crashing next TUI launch #89167

Closed

Description

@devin-ai-integration

After a session ends with status: failed (e.g. from provider 400 or timeout), it remains bound as the active agent:main:main. The next TUI launch attempts to rehydrate the failed session and crashes. Expected: a failed session should not remain bound; the runtime should rotate to a new session on failure. Observed 2026-05-02 and 2026-05-03.


Related issues (same quota-hit incident):

Activity

  1. clawsweeper commented on Jun 1, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 21, 2026, 5:10 AM ET / 09:10 UTC.

    Summary
    Keep open: current main and the latest release still preserve a failed main session when its transcript exists, and the TUI history path still rehydrates the selected session without a failed-session guard. The overlapping recovery PR is open but unmerged and appears only partially aligned with this issue because it clears terminal state in place while this issue asks for rotation or unbinding.

    Reproducibility: no. not for the exact TUI crash. Source and tests show that current main can keep a failed main session reusable when its transcript exists, and the TUI history path does not filter that failed entry.

    Ways to help us reproduce this

    • Add a screenshot or short recording showing the behavior.
    • Add expected vs actual behavior.

    Next step
    Do not queue a new automated fix while this issue has no-new-fix-pr/product-decision routing and #89045 is the active overlapping recovery candidate.

    Review details

    Best possible solution:

    Choose one shared terminal-session recovery policy for main/TUI and channel sessions, coordinate it with #89045, and add focused TUI/session regression proof for the chosen behavior.

    Do we have a high-confidence way to reproduce the issue?

    No, not for the exact TUI crash. Source and tests show that current main can keep a failed main session reusable when its transcript exists, and the TUI history path does not filter that failed entry.

    Is this the best way to solve the issue?

    Unclear. The open recovery PR fixes related terminal-session behavior by clearing failed state in place, but maintainers still need to decide whether this TUI case should rotate, unbind, or preserve transcript continuity.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • The exact next-launch TUI crash stack was not reproduced in this read-only pass; the source proof establishes failed-session reuse and unguarded TUI history loading, not the final crash frame.
    • The active recovery PR preserves transcript identity by clearing terminal state in place, while this issue asks for rotation or unbinding, so maintainer product judgment is still needed.

    Codex review notes: model internal, reasoning high; reviewed against e9b694ef9cd8.

    Label changes

    Label justifications:

    • P1: The report describes a failed persisted main session breaking the next TUI launch, which is an urgent user-facing session workflow failure if confirmed end to end.
    • impact:session-state: The issue is about failed lifecycle state and session identity remaining bound to the main session key.
    • impact:crash-loop: The reported user-visible outcome is a crash on the next TUI launch after the failed session remains selected.
    Evidence reviewed

    What I checked:

    • Repository policy applied: The root AGENTS.md and scoped session/Gateway/TUI/channel guides were read and applied; the policy requires source, tests, current and shipped behavior, related-item checks, and owner-history review for this cleanup decision. (AGENTS.md:1, e9b694ef9cd8)
    • Current main still allows failed-session reuse: The Gateway main-agent path computes canReuseSession from session id, freshness, missing transcript, and terminal transcript freshness; it does not reject status: "failed" when the transcript exists. (src/gateway/server-methods/agent.ts:1906, e9b694ef9cd8)
    • Current tests preserve failed-session reuse: The current Gateway test suite explicitly expects a failed main session with an existing default transcript to reuse the same session id and keep status: "failed". (src/gateway/server-methods/agent.test.ts:1078, e9b694ef9cd8)
    • TUI history loading does not filter failed entries: The embedded TUI backend loads the selected session entry, takes entry.sessionId, and reads messages for that session without checking for failed lifecycle status in this history path. (src/tui/embedded-backend.ts:429, e9b694ef9cd8)
    • Startup recovery skips already-failed rows: Main-session restart recovery only marks rows whose status is running; rows already in failed status are skipped by this recovery pass. (src/agents/main-session-restart-recovery.ts:338, e9b694ef9cd8)
    • Latest release has the same failed-session behavior: The v2026.6.9 release commit contains the same Gateway reuse logic and the same test expectation that an existing failed transcript remains bound and failed, so this is not fixed in the latest release. (src/gateway/server-methods/agent.test.ts:1078, c645ec4555c0)

    Likely related people:

    • Vincent Koc: Current-line blame in the available grafted history points the relevant Gateway reuse, auto-reply session reuse, TUI history loading, and restart-recovery snippets to recent commits by this person. (role: recent area contributor; confidence: medium; commits: 273eb888749f, c645ec4555c0; files: src/gateway/server-methods/agent.ts, src/auto-reply/reply/session.ts, src/tui/embedded-backend.ts)
    • Jerry-Xin: Authored the open terminal-session recovery PR that changes the same session, dispatch, and Gateway agent paths implicated by the failed-session lifecycle problem. (role: active adjacent PR author; confidence: high; commits: 3d8f8ea547e9, 431157739cc7, f19c2c010282; files: src/auto-reply/reply/session.ts, src/auto-reply/reply/dispatch-from-config.ts, src/gateway/server-methods/agent.ts)
    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
    • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
  2. abhinas90 commented on Jun 1, 2026

    @abhinas90

    Good catch. This is a session-lifecycle binding issue — the runtime treats a failed session as still owning agent:main:main, so the TUI tries to rehydrate a dead session and crashes.

    This has broader implications for unattended deployments. When a session fails (400/timeout/crash), the session manager should either mark it status: zombie and rotate, or auto-purge sessions that fail before the first assistant message.

    Recovery matrix:

    1. Manual unbind (recovery, no restart needed):

      openclaw session unbind agent:main:main
    2. Pre-launch guard (prevent recurrence):

      # ~/.openclaw/scripts/pre-launch.sh
      if openclaw session list --filter "status=failed" 2>/dev/null | grep -q "agent:main:main"; then
        openclaw session unbind agent:main:main
      fi
    3. Root cause prevention: Since HTTP 400 quota/usage_limit errors do not trigger provider fallback chain #89165 (no provider fallback on 400) and HTTP 400 from model provider not surfaced to chat UI; session silently waits for idleTimedOut #89166 (silent 400 in chat UI) are linked, fixing the fallback chain prevents the failed session from ever being created. The cascade is: quota/400 → no fallback → failed session → still bound → TUI crash.

    This is the kind of cascading failure pattern that makes unattended deployments unreliable — one 400 error from the provider takes down your entire next session.

  3. added
    P1
    impact:crash-loop
    impact:session-state
    issue-rating: 🐚 platinum hermit
    clawsweeper:needs-live-repro
    clawsweeper:no-new-fix-pr
    clawsweeper:needs-maintainer-review
    clawsweeper:needs-product-decision
    clawsweeper:fix-shape-clear
    and removed
    clawsweeper:fix-shape-clear
    clawsweeper:needs-maintainer-review
    on Jun 15, 2026
  4. openclaw-barnacle commented on Jul 6, 2026

    @openclaw-barnacle

    This issue has been automatically marked as stale due to inactivity.
    Please add updates or it will be closed.

  5. added
    stale
    on Jul 6, 2026
  6. steipete commented on Jul 9, 2026

    @steipete
    Contributor

    Closing as fixed by 1f36539ab04fbbbcdbd4fa743e903a010b35ecdf, now on main. Terminal-session recovery clears the failed session fields before the next TUI launch.

  7. locked as resolved and limited conversation to collaborators on Aug 9, 2026
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

    P1clawsweeper:needs-live-reproclawsweeper:needs-maintainer-reviewclawsweeper:needs-product-decisionclawsweeper:no-new-fix-primpact:crash-loopimpact:session-stateissue-rating: 🐚 platinum hermitstale

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions