Skip to content

bug(chat): LangGraph chat stream dies mid-response — root cause unknown, needs backend log investigation #3491

Closed

Description

@mrveiss

Problem

Chat session 4f825e59-9ab4-479b-8ed3-ddf7daaf68ec (2026-04-05) shows the LangGraph stream consistently dying:

  • Message 1 ('Hello Autobot testing.'): immediate error before any LLM output
  • Message 2 ('Sound testing.'): thought + planning chunks streamed successfully via qwen3.5:9b, then stream died before the final response

The stream death triggers _run_graph_task's except Exception handler, which puts the error in the queue and deletes the Redis checkpoint for the session.

What's Known

  • Backend VM (172.16.168.20) was unreachable via SSH during investigation — backend logs not accessible
  • The _run_graph_task already logs with exc_info=True at ERROR level — the exception details are in the journal
  • After fix in issue bug(chat): empty Python exception message causes 'Unknown error' instead of diagnostic info #3488, future failures will include the exception class name in the displayed error
  • Possible causes: Ollama/vLLM timeout during generation, LangGraph checkpoint Redis failure, malformed model response, network interruption between backend and AI stack (172.16.168.24:8080)

Steps to Diagnose

  1. Reproduce the stream failure (send a chat message)
  2. SSH to backend VM: ssh autobot@172.16.168.20
  3. journalctl -u autobot-backend --since '10 minutes ago' | grep -A20 'Graph execution error'
  4. Identify the exception type and full traceback
  5. Fix the root cause

Acceptance Criteria

  • Root cause identified from backend logs
  • Fix implemented and tested
  • Chat streaming works consistently with qwen3.5:9b model

Activity

  1. mrveiss commented on Apr 5, 2026

    @mrveiss
    OwnerAuthor

    Fix Complete

    All root causes identified and resolved:

    1. AI stack crash-loop — missing source files

    • Commit fa07aab0f: Added Ansible tasks to deploy ai_api_server.py, ai_container_main.py, requirements-ai.txt from shared/docker/ai-stack/; created src/agents and src/autobot_shared symlinks; fixed service to use backend venv + PYTHONPATH

    2. SSE error display — wrong key name

    • Commit 400d5553c: Three error handlers in api/chat.py used "message" key; frontend reads data.content → undefined → fell back to literal 'Stream error'. Fixed to "content"

    3. Empty exception string — meaningless errors

    • Commit 400d5553c: str(asyncio.TimeoutError()) == '' → frontend fallback. Fixed with str(exc) or f'{type(exc).__name__}: unexpected error'

    4. Error status overwritten — sent overrides error

    • Commit 400d5553c: Post-loop cleanup unconditionally set status:'sent'. Fixed with if (msg.status !== 'error') guard

    5. _ConfigStub missing methods — re-entrant init crash

    6. asyncio.Lock / threading.Lock collision — health check always unhealthy

    • Commit 46eb3c275: StandardizedAgent.__init__ overrode BaseAgent._stats_lock (threading.Lock) with asyncio.Lock(). BaseAgent.health_check() used sync with self._stats_lock: which fails for asyncio.Lock. Renamed to _async_stats_lock to avoid collision. All 3 agents (chat, rag, classification) now report healthy.

    7. Agent LLM provider env vars — missing config

    • Commit 46eb3c275: Added AUTOBOT_CLASSIFICATION_PROVIDER, AUTOBOT_CHAT_PROVIDER, AUTOBOT_RAG_PROVIDER to ai-stack.env.j2 with ollama defaults.

    Verified

    • AI stack health: all 3 agents healthy at /health endpoint
    • Backend restarted with deployed fixes
    • Frontend rebuilt with ChatController.ts fix
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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions