Skip to content

bug: Session-mode turn shows 'failed to send' on long-running work while the execution succeeds in the background #1376

Closed

Description

@vybe

Summary

In Session mode (the --resume chat surface), sending a message that triggers a long stretch of agent work surfaces a "Failed to send message" error in the UI even though the backend execution is running normally and completes successfully — the assistant reply lands in the DB and appears on a later refresh, contradicting the failure shown to the user.

This is the same class of false-failure as the previously-fixed #759 (bug(session-tab): shows 'failed to send' on return navigation while execution is still running), but for the stay-on-page, long-running turn path rather than the navigate-away-and-return path. Both existing mitigations are in place yet the symptom still reproduces, so this is filed as a distinct bug.

Context

The Session-tab turn endpoint (POST /api/agents/{name}/sessions/{id}/message) is synchronous — the browser holds the HTTP request open for the full duration of the agent's turn. Two mitigations already exist:

  1. HTTP-timeout ceiling match — the axios call in src/frontend/src/stores/sessions.js sets timeout: 7260000 (~121 min) to match the backend execution cap (TIMEOUT-001, 7200s + slack). The inline comment there describes exactly this symptom as the old behavior the ceiling was meant to remove.
  2. Reattach on return navigation (bug(session-tab): shows 'failed to send' on return navigation while execution is still running #759) — a Redis in-flight sentinel (session_inflight:{session_id}) surfaces as turn_in_progress=true on the session GET; the frontend startPolling() reattaches and shows a "running" indicator instead of a failure.

Despite both, users with heavy/long turns still see the false failure. The most likely remaining causes:

  • A reverse-proxy read timeout shorter than the axios ceiling (e.g. nginx proxy_read_timeout, or a Cloudflare ~100s edge timeout) severs the synchronous socket before the backend finishes. The 121-min axios ceiling cannot help if an intermediary closes the connection first — axios sees a network error and the catch in sendMessage renders "Failed to send message".
  • The stay-on-page error path does not reattach: the catch block in sendMessage (src/frontend/src/stores/sessions.js) sets errorBySession[sessionId] unconditionally on any thrown error. Unlike the navigation path, it never checks turn_in_progress / the latest assistant message before declaring failure. The poll-reattach (startPolling) only fires on onActivated (KeepAlive return), and is itself capped at MAX_ATTEMPTS = 60 (~22 min), so a turn longer than ~22 min on the polling path also gives up.

Steps to Reproduce

  1. Open an agent's Session tab (session mode ON).
  2. Send a message that triggers a long stretch of work (many tool calls / large task), longer than the deployment's reverse-proxy read timeout.
  3. Stay on the page.
  4. Observe: UI shows "Failed to send message" while the agent is still working.
  5. Wait / refresh: the assistant reply appears — the turn actually succeeded.

Expected Behavior

A long-running Session-mode turn must never surface "Failed to send message" while the backend execution is still running or has already succeeded. On a client-side request error, the UI should check whether the turn is still in progress (or whether an assistant reply has landed) and reattach to the in-flight/completed turn rather than rendering a failure.

Acceptance Criteria

  • A Session-mode turn that outlives any intermediary connection timeout never shows a false "failed to send" while the execution is running or has succeeded.
  • On a client-side error from the synchronous turn request, sendMessage checks turn_in_progress / latest assistant message and reattaches (poll/stream) instead of unconditionally setting errorBySession.
  • The reattach/poll path is not capped below the agent's max execution timeout (or polling falls back cleanly so a >22-min turn isn't abandoned).
  • If a reverse-proxy read timeout is severing the synchronous socket, it is identified and either raised to match the execution cap or the turn is made resilient to a dropped synchronous connection.
  • A genuine backend failure still surfaces a real error (no regression of true-failure reporting).

Technical Notes

  • Frontend false-failure path: the catch in sendMessage — src/frontend/src/stores/sessions.js.
  • Existing reattach machinery to reuse: turn_in_progress flag + startPolling() (src/frontend/src/stores/sessions.js), SessionPanel.vue onActivated reattach.
  • Backend: synchronous turn endpoint + session_inflight:{session_id} sentinel in src/backend/routers/sessions.py.
  • Related (fixed) prior art: bug(session-tab): shows 'failed to send' on return navigation while execution is still running #759 (return-navigation variant). This bug is the stay-on-page / proxy-timeout variant.
  • Check deployment proxy config (proxy_read_timeout / Cloudflare edge timeout) against the TIMEOUT-001 execution cap.

Activity

  1. added
    priority-p1
    type-bug
    theme-reliability
    status-ready
    on Jun 29, 2026
  2. AndriiPasternak31 commented on Jun 29, 2026

    @AndriiPasternak31
    Contributor

    /claim

  3. added
    status-in-progress
    on Jun 29, 2026
  4. github-actions commented on Jun 29, 2026

    @github-actions

    Claimed by @AndriiPasternak31. Label status-in-progress added.

    Next steps:

    1. Create branch: feature/1376-<short-slug>
    2. Implement the feature
    3. Open a PR with Fixes #1376
  5. added
    status-in-dev
    and removed
    status-in-progress
    on Jun 30, 2026
  6. removed
    status-in-dev
    status-ready
    on Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

priority-p1theme-reliabilitytype-bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions