Skip to main content
Source Code: src/gaia/ui/
Import:
See also: User Guide | Agent SDK | API Specification
Tested Configuration: The Agent UI has been tested on AMD Ryzen AI MAX+ 395 with Qwen3.5-35B-A3B-GGUF. Other configurations are not officially verified. See the User Guide for full details and how to report issues on other hardware.

Overview

The Agent UI SDK is the Python backend that powers the GAIA Agent UI. It provides:
  • FastAPI REST server with session, chat, document, and memory endpoints
  • SQLite database for persistent sessions, messages, and document metadata
  • SSE streaming for real-time chat responses
  • RAG integration for document Q&A
  • Memory dashboard with knowledge browser, tool stats, and observability (Memory SDK)
  • Pydantic models for request/response validation
The backend runs on port 4200 by default and serves both the Electron desktop app and browser-based clients.
End users don’t need to interact with this SDK directly — prebuilt .exe / .deb desktop installers are on the GitHub Releases page, and npm install -g @amd-gaia/agent-ui gives the same app on any Node-capable platform. This page is for developers embedding or extending the backend. See the Agent UI guide for install options.

Quick Start

Start the Server

Run with uvicorn:
Or from the command line:

Use the Database Directly


Core Classes

ChatDatabase

The persistence layer for all Agent UI data. Uses SQLite with WAL mode for concurrent read access.
Constructor:

Session Methods

Example:

Message Methods

Example:

Document Methods

Example:

Statistics


create_app()

Factory function that creates and configures the FastAPI application with all endpoints.
Shared state is stored on app.state and is accessible in tests:

Pydantic Models

All request and response bodies use Pydantic models from gaia.ui.models.

System

Sessions

Chat

Messages

Documents


REST API Endpoints

System

Check system readiness for the agent UI.Response:
Health check with database statistics.Response:
Trigger loading a model on the Lemonade server. Returns 202 immediately; loading proceeds in the background. Poll GET /api/system/status to detect when loading completes.Request:
Response (202):
Trigger downloading a model via the Lemonade server. Returns 202 immediately; the download proceeds in the background. Poll GET /api/system/status to detect when the model becomes available. Set force to true to re-download even if the file already exists (repairs corrupted or incomplete downloads).Request:
Response (202):
Get current user settings including the custom model override and its status on the Lemonade server.Response:
Update user settings. Set custom_model to a model ID to override the default, or to an empty string / null to clear the override and revert to the default model.Request:
Response: Same shape as GET /api/settings.

Sessions

Create a new chat session.Request:
Response: SessionResponse
List all sessions, ordered by most recently updated.Query params: limit (default 50), offset (default 0)Response: SessionListResponse
Get session details including message count and attached document IDs.Response: SessionResponse
Update session title or system prompt.Request:
Delete a session and all its messages (cascading delete).
Get messages for a session, ordered oldest first.Query params: limit (default 100), offset (default 0)Response: MessageListResponse
Export a session to Markdown or JSON.Query params: format (“markdown” or “json”, default “markdown”)

Chat

Send a message and receive a response. Supports both streaming (SSE) and non-streaming modes.Request:
Streaming response (SSE events):When stream: true, the server returns a text/event-stream response. Each line follows the SSE format data: <JSON>. The SSEOutputHandler (src/gaia/ui/sse_handler.py) bridges agent console events to the following typed events:Thinking and ProgressTool Executionresult_data variants in tool_result:
  • File list: {"type": "file_list", "files": [...], "total": int} — up to 20 file entries
  • Search results: {"type": "search_results", "count": int, "scores": float[], "previews": string[]} — top 5 chunk previews (200 chars each)
command_output shape in tool_result:
Response ContentStream TerminationExample stream showing a typical multi-step interaction:
Non-streaming response:

Documents

List all documents in the global library.Response:
Index a document by file path. The file is hashed for deduplication — if the same file was already indexed, the existing document is returned.Request:
Response: DocumentResponse
Remove a document from the library and all session attachments.
Attach a document from the library to a session.Request:
Detach a document from a session (does not delete the document).

Files

Open a file or folder in the system file explorer. On Windows this launches Explorer, on macOS it uses open, and on Linux it uses xdg-open. Symbolic links are rejected for security.Request:
Response:
Error responses:
Upload an arbitrary file for use as a chat attachment (not added to the RAG library). Use POST /api/documents/upload instead if you want the file indexed for Q&A.
Browse filesystem contents. Returns entries under a directory with size, mtime, and type metadata.
Search files by name/pattern across watched or allowed locations.
Return a preview (first N bytes / first N lines) of a text file.
Stream an image file from the filesystem for display in the UI.

Agents

List all agents registered via AgentRegistry — built-in agents plus any custom agents discovered under ~/.gaia/agents/. See plugin-registry for the registration format.
Return details for a single registered agent (description, models, conversation starters, source = builtin or custom_python).

MCP

The MCP router manages external Model Context Protocol servers the agent can connect to.
List configured MCP servers and their enabled state.
Register a new MCP server configuration.
Remove a registered MCP server configuration.
Enable a previously-registered MCP server.
Disable a server without removing its configuration.
List tools exposed by a specific MCP server.
Return the curated catalog of known-good MCP servers (Context7, etc.).
Overall MCP client status — number of connected servers, aggregate tool count, last-error details.

Tunnel

Expose the local Agent UI over the internet via an ngrok/Cloudflare tunnel. Used to reach the UI from a phone.
Start a tunnel. Returns the public URL.
Stop the active tunnel.
Current tunnel status — active/inactive, public URL, provider, uptime.

Chat (advanced)

Tool-confirmation handshake. When a tool in the agent’s confirmation_required_tools() set (the generic base set merged with the agent’s own CONFIRMATION_REQUIRED_TOOLS) triggers the agent to pause, the UI prompts the user and posts the outcome (approve / deny) back on this endpoint.

Documents (advanced)

Multipart drag-and-drop upload. Stores the file in the library and enqueues it for indexing.
Status of the background document_monitor.py file-watcher.
Indexing progress for a single document.
Cancel an in-flight indexing job.
Recursively index all supported files under a folder.

Sessions (advanced)

Delete a single message from a session.
Delete a message and every message after it (the “resend from here” pattern).

System (advanced)

Inspect the background dispatch queue (model downloads, indexing jobs, etc.) used by src/gaia/ui/dispatch.py.

Memory

The Memory endpoints expose the agent’s persistent knowledge system. See the Memory SDK Reference for the underlying MemoryStore and MemoryMixin APIs.
Aggregate statistics across all memory tables.Response:
Paginated, filterable knowledge browser.Query params:Response:
Create a knowledge entry from the dashboard. Items created via the UI use source='user' and confidence=0.8.Request:
Edit a knowledge entry. Only provided fields are updated.Request:
Delete a knowledge entry.
Time-sensitive items due within N days, including overdue.Query params: days (default 7)Response:
List all unique entities with knowledge counts.Response:
Per-tool performance statistics.Response:
List conversation sessions with turn counts and first message preview.Query params: limit (default 20)
Get all turns for a specific conversation session.
Daily activity counts for the activity timeline chart.Query params: days (default 30)Response:
Embedding status for the knowledge base.Response:
Manually trigger conversation consolidation. Distills old sessions (>14 days, >=5 turns) into durable knowledge items.Response:
Manually trigger background memory reconciliation. Checks for contradictory facts across sessions.Response:
Trigger embedding backfill for items missing embeddings.Response:
Rebuild FTS5 indexes if search results seem wrong.Response:

Database Schema

The Agent UI uses SQLite with four tables:
SQLite settings: Foreign keys enabled, WAL journal mode for concurrent reads.
The indexing_status, file_mtime, agent_steps, and inference_stats columns (plus the settings table) are added via migrations for databases created before these existed. New databases include them in the initial schema.

Testing

Unit Testing with In-Memory Database

Database Testing


Integration with the Agent

The Agent UI server delegates to the GAIA Agent for LLM communication and tool execution:
Document indexing uses the RAG SDK:

npm Package

GAIA Agent UI is also available as an npm package for quick installation:
This provides the gaia-ui CLI command:
On first run, gaia-ui automatically installs the Python backend (uv, Python 3.12, amd-gaia) if not already present. On subsequent runs, it auto-updates if the version doesn’t match.

Package Contents

The npm package includes:

Release Management

The package version is sourced from src/gaia/version.py (single source of truth for all of GAIA):
Tags matching v* trigger the automated npm publish workflow.