Skip to content

fix(chat-ui): architectural fixes, LLM backend improvements, and UI rendering fixes - #561

Merged
kovtcharov merged 3 commits into
kalin/chat-uifrom
tomasz/chat-ui-fixes
Mar 17, 2026
Merged

kovtcharov merged 3 commits into
kalin/chat-uifrom
tomasz/chat-ui-fixes

Conversation

@itomek

@itomek itomek commented Mar 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Architectural fixes: Improved Agent, ChatAgent, and AgentSDK with better LLM backend handling
  • LLM backend: Added LemonadeManager for robust model loading lifecycle management; fixes to LemonadeClient and lemonade provider
  • Chat UI backend: Refactored chat.py router, fixed SSE handler, session management improvements, and database schema updates
  • Frontend: Fixed code block rendering in MessageBubble.tsx and improved file list tool summaries
  • Tests: Updated unit tests for SSE handler, LLM, and Lemonade model loading

Test plan

  • Run python -m pytest tests/unit/ — all unit tests pass
  • Verify gaia chat --ui launches and renders code blocks correctly
  • Confirm LLM model loading works end-to-end via LemonadeManager
  • Check SSE streaming in Agent UI produces correct tool summary output

🤖 Generated with Claude Code

Concurrency & correctness fixes:
- Serialize chat requests (Semaphore 2→1) to prevent _TOOL_REGISTRY
  cross-request data contamination
- Use setdefault for atomic per-session lock creation
- Replace unreliable locked() check with wait_for timeout → 409
- Hold session lock through full streaming response duration
- Save user message inside the streaming lock scope
- Clean up session locks on session delete to prevent memory leak
- Guard _transaction() against use-after-close (RuntimeError)
- Add cancelled event to SSEOutputHandler; check in producer between
  phases; set after consumer loop for clean thread teardown
- Restrict _compute_allowed_paths to document dirs only (home dir
  added as fallback when no docs, not unconditionally)
- Convert SSE streaming buffer Cases 1b/2/3 to elif chain to prevent
  double-processing on multi-match buffers
- Remove dead _fence_start variable in agent.py

LLM backend improvements:
- _ensure_model_loaded: pass ctx_size from MODELS registry to load_model
- _try_reload_with_ctx: auto-reload model with larger context window
  when requested ctx_size exceeds current; prevents infinite reload loop
  by always updating cls._context_size
- LemonadeProvider: fall back to reasoning_content when content is empty
- ChatAgentConfig: base_url defaults via env var LEMONADE_BASE_URL
- AgentSDK: forward max_tokens to generate() calls
- Strip Qwen3 <think> tags before JSON parsing in agent response handler

Test fixes:
- Update load_model assertions for new ctx_size parameter
- Update print_context_message assertions to reflect _context_size
  update behavior after reload attempt
@itomek itomek self-assigned this Mar 17, 2026
@itomek
itomek marked this pull request as ready for review March 17, 2026 13:53
@itomek
itomek requested a review from kovtcharov-amd as a code owner March 17, 2026 13:53
@github-actions github-actions Bot added agents chat Chat SDK changes llm LLM backend changes cli CLI changes tests Test changes performance Performance-critical changes labels Mar 17, 2026
@kovtcharov
kovtcharov merged commit b489470 into kalin/chat-ui Mar 17, 2026
8 checks passed
@kovtcharov
kovtcharov deleted the tomasz/chat-ui-fixes branch March 17, 2026 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chat Chat SDK changes cli CLI changes llm LLM backend changes performance Performance-critical changes tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants