Skip to content

[BUG] Streaming chat shows "no visible reply" for a long time; later cancels and backend logs cleanup warnings #869

Closed

Description

@xrwang8

Summary

In the UI, streaming chats sometimes show no visible incremental reply for a long period. Eventually the request may cancel/time out on the frontend, and backend logs include cleanup warnings (e.g., Runner.close() was cancelled and MCP cancel‑scope messages). Users perceive this as the chat "hanging" or failing, and it can occasionally correlate with probe failures under load.

Version / Environment

  • kagent version: 0.5.5 (also observed on latest main)
  • UI image with embedded Nginx reverse proxy
  • A2A streaming via Next.js route /a2a/{namespace}/{agent}

Steps To Reproduce

  1. Deploy UI and Controller, create a streaming Agent (e.g., AIRE‑agent).
  2. Start a chat and observe the browser network panel for /a2a/....
  3. In certain runs, there are no incremental SSE events visible for an extended time; later the request cancels or ends.

Expected Behavior

  • The chat shows incremental updates in real time while the agent processes the request.

Actual Behavior

  • The chat appears to have no reply for a long time.
  • The request may cancel/time out on the frontend.
  • Backend logs show cleanup‑phase warnings and cancellations.

Evidence / Logs

Examples seen in backend logs:

WARNING:google_adk...: Runner.close() was cancelled; suppressing during cleanup
ERROR asyncio: Exception in callback EventConsumer.agent_task_callback()
...
asyncio.exceptions.CancelledError: Cancelled by cancel scope ...
Warning: Error during MCP session cleanup ... Attempted to exit cancel scope in a different task than it was entered in

Impact

  • Users see chats that appear stuck or fail.
  • May cascade into timeouts/cancellations and occasional probe failures under pressure.

Additional Context

📋 Prerequisites

  • I have searched the existing issues to avoid creating a duplicate
  • By submitting this issue, you agree to follow our Code of Conduct
  • I am using the latest version of the software
  • I have tried to clear cache/cookies or used incognito mode (if ui-related)
  • I can consistently reproduce this issue

🎯 Affected Service(s)

UI Service

🚦 Impact/Severity

No impact (Default)

🐛 Bug Description

Summary

In the UI, streaming chats sometimes show no visible incremental reply for a long period. Eventually the request may cancel/time out on the frontend, and backend logs include cleanup warnings (e.g., Runner.close() was cancelled and MCP cancel‑scope messages). Users perceive this as the chat "hanging" or failing, and it can occasionally correlate with probe failures under load.

Version / Environment

  • kagent version: 0.5.5 (also observed on latest main)
  • UI image with embedded Nginx reverse proxy
  • A2A streaming via Next.js route /a2a/{namespace}/{agent}

Steps To Reproduce

  1. Deploy UI and Controller, create a streaming Agent (e.g., AIRE‑agent).
  2. Start a chat and observe the browser network panel for /a2a/....
  3. In certain runs, there are no incremental SSE events visible for an extended time; later the request cancels or ends.

Expected Behavior

  • The chat shows incremental updates in real time while the agent processes the request.

Actual Behavior

  • The chat appears to have no reply for a long time.
  • The request may cancel/time out on the frontend.
  • Backend logs show cleanup‑phase warnings and cancellations.

Evidence / Logs

Examples seen in backend logs:

WARNING:google_adk...: Runner.close() was cancelled; suppressing during cleanup
ERROR asyncio: Exception in callback EventConsumer.agent_task_callback()
...
asyncio.exceptions.CancelledError: Cancelled by cancel scope ...
Warning: Error during MCP session cleanup ... Attempted to exit cancel scope in a different task than it was entered in

Impact

  • Users see chats that appear stuck or fail.
  • May cascade into timeouts/cancellations and occasional probe failures under pressure.

Additional Context

🔄 Steps To Reproduce

  1. Open the UI and initiate a streaming chat with a configured Agent.
  2. Observe the network panel for the /a2a/{namespace}/{agent} request.
  3. Note that incremental SSE events may not appear for an extended time, followed by cancellation.

🤔 Expected Behavior

Chat should stream incremental responses in real time without long gaps or unexpected cancellation.

📱 Actual Behavior

  • Long period with no visible incremental output.
  • Stream cancels/times out; backend logs show cleanup warnings.

💻 Environment

  • kagent 0.5.5 and latest main
  • UI with embedded Nginx, Next.js proxy route /a2a/...
  • Browser: Chrome/Edge (latest)

🔧 CLI Bug Report

No response

🔍 Additional Context

No response

📋 Logs

WARNING:google_adk...: Runner.close() was cancelled; suppressing during cleanup
ERROR asyncio: Exception in callback EventConsumer.agent_task_callback()
...
asyncio.exceptions.CancelledError: Cancelled by cancel scope ...
Warning: Error during MCP session cleanup ... Attempted to exit cancel scope in a different task than it was entered in

📷 Screenshots

No response

🙋 Are you willing to contribute?

  • I am willing to submit a PR to fix this issue

Activity

  1. added theissue type on Sep 9, 2025
  2. xrwang8 commented on Sep 9, 2025

    @xrwang8
    ContributorAuthor

    Hypothesis (SSE buffering)

    • Suspect the “no visible reply” is caused by SSE being buffered by a reverse proxy (Nginx).
    • SSE requires immediate delivery of small chunks; Nginx’s default proxy buffering aggregates and delays them.
    • As a result, the browser shows “no reply” until buffer flush/end, which can trigger frontend timeouts/cancellations and surface as backend cleanup warnings (e.g.,CancelledError).
  3. added a commit that references this issue on Sep 18, 2025
    2b5ea5c
  4. added a commit that references this issue on Apr 30, 2026
    989fc07
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

    No labels
    No labels

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions