LLMs Technical Reviews

How is the assistant architected?

Agent loop and runtime; frontend/backend split; main packages; how a user request flows to an action.

Verdict

The main split is where the agent loop lives: in a long-running gateway process, behind a durable job queue, or in a fixed request pipeline. Waku is the clearest loop to read. QM and Rakazo are the most robust when workers crash.

One always-on process that owns its loop. OpenClaw runs a Gateway on port 18789. Channel plugins feed an embedded runner whose runLoop starts tool calls while the stream is still arriving and injects mid-run “steering” messages. Hermes Agent puts one AIAgent, built from 14 mixins, behind its CLI, gateway and API. Tool rounds persist the assistant message before they execute anything. Agenvoy is a Go daemon bound to 127.0.0.1. A dispatcher LLM picks the model, then Execute runs up to 256 rounds. Leon routes Socket.IO utterances to an agent loop or to legacy skills. Each tool runs in its own worker process, and a reviewer call checks that the task is complete. Waku is the small, synchronous version: a 209-line run_loop in the Anthropic message shape.

Durable runs. QM stores turns as Postgres runs, claimed with FOR UPDATE SKIP LOCKED and kept in order per thread. It delegates the loop itself to Pi, OpenCode, Codex or Claude Code. Rakazo writes a queued run, and a Graphile worker leases it and drives Pi from one 8,000-line executor. OpenBot runs CopilotKit’s runtime, accepts any AG-UI server as a Bot, and sends every computer action through one ComputerGateway.

Pipelines more than loops. Khoj makes one LLM call to choose sources, then runs tools in a fixed order. It iterates only in /research mode, for up to 5 rounds by default. Inbox Zero is driven by mail webhooks: static rule conditions run before any model call. Its chat assistant is a separate Vercel AI SDK ToolLoopAgent.

Pick: Waku to learn from or fork. Pick: QM or Rakazo when runs must survive restarts and pause for approval. Pick: OpenClaw or Hermes Agent for one agent reachable from many surfaces.

Per-project answers

openclaw/openclaw

answered

Agent loop and runtime. The Gateway (src/gateway/) is the central control plane — an HTTP/WebSocket server that manages all sessions, tool execution, events, and channel connections. Session lifecycle is governed by src/sessions/session-lifecycle-admission.ts which serializes mutations and work admission via SQLite-backed store writers. When a user message arrives, the agentRunHandler in src/gateway/server-methods/agent-run-handler.ts performs preflight validation, creates an agent turn service via createAgentTurnService, and dispatches the run. The agent turn service coordinates with src/agents/ — the agent run loop — which manages MCP tool bundles, memory search, and LLM invocation through the provider runtime.

Frontend/backend split. The backend is the Gateway (HTTP server in src/gateway/server-http.ts). Frontends include a Control UI (Web), a CLI (src/cli/), a TUI (src/tui/), and native companion apps. The Gateway serves the Control UI, an OpenAI-compatible API, plugin HTTP surfaces, and WebSocket upgrades. It also exposes server-method modules (src/gateway/server-methods/) for agent runs, session history, model listing, tool invocation, user profiles, and more.

Main packages. Organized as a pnpm workspace monorepo. Key source directories: src/gateway/ (routing, approvals, chat projection), src/agents/ (agent harness, MCP tool manager, memory prompt prepare), src/sessions/ (lifecycle, state events, transcripts), src/channels/ (channel plugin system), src/llm/ and packages/ai/ (provider transports), packages/memory-host-sdk/ (memory engine), src/state/ (SQLite DB schemas for agent state, config, user profiles), src/secrets/ (credential management), src/security/ (audit, policy).

Request flow. A message arrives via a channel plugin (e.g., Discord webhook) — each channel implements ChannelPlugin (src/channels/plugins/types.plugin.ts:48). The plugin routes it into the Gateway chat runtime (src/gateway/server-chat.ts), which creates a session via lifecycle admission. The session runs by calling the agent turn service, which invokes an LLM through the provider transport layer (packages/ai/src/host.ts), executes any tool calls (MCP, filesystem, exec), and streams responses back through the channel.

NousResearch/hermes-agent

answered

Agent loop and runtime: The AIAgent class (run_agent.py:241) is the central orchestrator, composed of ~15 mixins for streaming, compression, approval, activity tracking, etc. Every user turn flows through run_conversation() (conversation_loop.py:1695) which calls _run_conversation_turn() (conversation_loop.py:1533). That function drives: pre-flight compression checks, build_turn_context() (turn_context.py:1017) to assemble messages and system prompt, build_api_request() → perform_api_call() to the LLM, normalize_model_response() to parse tool calls or text, run_tool_round() (turn_tool_round.py:46) to dispatch tools with parallel/segmented execution, check_api_response() for finish-reason handling, and finalize_turn() for post-turn hooks (memory sync, background review). The loop retries on errors up to max_iterations.

Frontend/backend split: The CLI (hermes_cli/) provides the interactive TUI via prompt_toolkit, the messaging gateway (gateway/run.py) runs platform adapters that receive messages and call AIAgent.run_conversation() per incoming message. The gateway caches agents per session with an LRU cap of 128 and 1h idle TTL. A web dashboard serves config, sessions, and cron management. The Desktop app wraps the CLI in Tauri (Rust).

Main packages: agent/ — core loop, compression, memory, providers; tools/ — 40+ tool implementations (terminal, browser, file, MCP, skills, etc.); gateway/ — messaging platform adapters; hermes_cli/ — CLI, config, profiles, auth; hermes_state*.py — SQLite state store.

Request-to-action flow: User message → run_conversation() → context assembly (system prompt + memory recall + history) → LLM API call → response parsing → if tool_calls: _execute_tool_calls() which runs the tool (terminal command, file edit, API call, etc.) → tool result appended to messages → loop back to LLM call until final text response is produced → post-turn memory sync + background review spawn.

Editor's note. Correction: the desktop app in apps/desktop/ is built with Electron, not Tauri; Tauri is only used by the separate bootstrap installer in apps/bootstrap-installer/.

khoj-ai/khoj

answered

Khoj is a Python application with a FastAPI backend and a Next.js (React) frontend served together in a single Docker image. The entry point is main.py:run() which initializes Django (for ORM, migrations, admin), sets up FastAPI with CORS middleware, mounts the Django app at /server, and starts a Uvicorn (dev) or Gunicorn (prod) server.

Agent loop and runtime. The core agent loop lives in api_chat.py:event_generator() — a large async generator that processes each user request step by step. It first detects the conversation command from the user's query (e.g., /notes, /online, /code, /research, /operator) via helpers.py:get_conversation_command(). For the "default" command, an LLM call determines which tools to use (aget_data_sources_and_output_format). Tools are then executed sequentially in order: (1) research iterations, (2) document/note search (semantic vector search over user content), (3) online search, (4) webpage reading, (5) code execution, (6) operator/computer-use. Each tool yields status events back to the client via SSE (HTTP) or a buffered WebSocket protocol. After all tools run, agenerate_chat_response() dispatches to the appropriate LLM provider (OpenAI, Anthropic, or Gemini), streams the response back, and saves the conversation turn.

Frontend/backend split. The frontend is a Next.js app (in src/interface/web/) built with Bun. FastAPI serves it as static files and also provides a Jinja2-based web client for the app and a landing page. Django provides the admin panel (via django-unfold) and the database ORM.

Main packages. The khoj/ package contains: routers/ (API endpoints), processor/ (conversation models, content ingestion, operator agents), database/ (Django models and adapters), search_filter/ (date/file/word query filters), search_type/ (text/image search backends), and utils/ (config, helpers, state).

User request to action flow. A request arrives at an HTTP POST or WebSocket endpoint → FastAPI authenticates (Django session, bearer token, or anonymous mode) → event_generator is invoked → command detection → tool execution phase (each tool calls the LLM as needed) → final LLM call generates the natural-language response with all compiled context → conversation is saved to PostgreSQL via save_to_conversation_log().

leon-ai/leon

answered

Leon's architecture centers on three runtime modes — agent (default), controlled, and smart — selected in config.sample.yml via routing.mode (server/src/../config.ts). In agent mode, the core loop lives in server/src/core/llm-manager/llm-duties/react-llm-duty/agent-loop.ts (lines 1–54): a continuous, single-transcript provider tool-calling loop where the LLM calls tools, observations are fed back, and recovery/completion-review check progress. The loop is orchestrated by react-llm-duty.ts which imports from agent-constants.ts, tool-execution.ts, agent-plan.ts, and agent-history-manager.ts. The Brain (server/src/core/brain/brain.ts, lines 59–77) manages the answer queue, paraphrasing, TTS, and skill execution via handlers (dialog-action-skill-handler.ts, logic-action-skill-handler.ts). Tool schemas load progressively from the ToolkitRegistry (server/src/core/tool-manager/toolkit-registry.ts), and the ToolExecutor (server/src/core/tool-manager/tool-executor.ts) runs calls concurrently in isolated workers. The frontend/backend split uses client-agnostic Socket.IO (server/src/core/socket-server.ts) — text (and attached files) comes in as utterances, and the response streams back as tokens and final answers. Legacy [controlled mode] routes through NLU (natural language understanding) which classifies intent and triggers native skill actions (Skills -> Actions -> Tools -> Functions). Packages are organized as a pnpm workspace: server/ (core + Node.js bridge), app/ (terminal UI), web-app/ (React web UI), bridges/ (Node.js & Python bridges), skills/ (native + agent skills), tools/ (toolkits with JSON declarations). A user request flows: client emits an utterance via Socket.IO → socket-server.ts dispatches to the NLU or directly to the agent loop → based on routing mode, the LLM chooses/calls tools → results return as observations → final answer is queued through Brain.talk() and emitted back to the client.

yc-software/qm

answered

QM is a headless core service with plugin surfaces, all in TypeScript on Node.js (≥24.15). The core (src/index.ts → src/wiring.ts) starts a Fastify HTTP server, attaches identity/directory services, the orchestrator, and optional Slack and portal plugins. There's an agent loop with durable execution against a central write-ahead log: the "session tape" (src/sessions/session-store.ts, the write-ahead log abstraction). A session offers up a write lease, a worker claims it from the run queue, and the orchestrator (src/core/orchestrator.ts) assembles system prompts, memory, context history, tools, and security screening before dispatching to a swappable harness (src/harness/harness-router.ts). Harnesses include Pi (src/harness/pi-harness.ts), OpenCode, Codex, and Claude — each implements runTurn(), calling into the model catalog (src/model/pi-models.ts, src/model/model-catalog.ts) which resolves model IDs and provider credentials. A user request arrives via Slack (Bolt-based events plugin at src/slack/) or the web UI (plugins/web-ui/, Vite+Lit). The API routes (src/api/routes/) validate auth, dispatch a turn, run the orchestrate→harness→model pipeline, and stream results back. Tool calls (src/tools/primitives.ts, src/harness/agent-tools.ts) are fulfilled against the scope's sandbox (src/sandbox/sandbox.ts) — an isolated compute environment backed by AWS, Fly, Docker, Modal, Sprites, etc. The model response and tool results are committed to the session tape. The whole system scales to swarms of agents for background work (crons, webhooks, sub-agents).

elie222/inbox-zero

answered

Agent loop and runtime. The user request flows through the Next.js API route at apps/web/app/api/chat/route.ts, which receives messages via POST. The route validates the input, loads the chat + compaction history from PostgreSQL, optionally compacts old messages, loads up to 20 ChatMemory entries, then calls aiProcessAssistantChat (apps/web/utils/ai/assistant/chat.ts). This function builds a system prompt, constructs a ToolLoopAgent from the Vercel AI SDK (via toolCallAgentStream in apps/web/utils/llms/index.ts:886), and streams tool calls and text back as a UIMessageStream. The agent runs in a loop — each step can call one tool, the result is fed back, and the loop continues until the model decides to respond or the tool budget expires (720s for web, 60s for messaging).

Frontend/backend split. The frontend is a Next.js app-router server-rendered React application with Tailwind CSS and shadcn/ui components. Data is fetched client-side using SWR hooks; mutations go through next-safe-action server actions (e.g., confirmAssistantEmailAction in apps/web/utils/actions/assistant-chat.ts:15). POST API routes are reserved for mobile-native integrations.

Main packages. The monorepo (pnpm-workspace.yaml) contains: apps/web (Next.js), apps/desktop (Electron shell), apps/worker (background queue consumer), packages/mail-core/mail-react/mail-ui (email rendering), packages/api (shared API types), packages/loops (automation jobs), packages/scheduling (booking/availability), packages/tinybird (analytics).

Request-to-action flow. The user types in the chat UI → POST to /api/chat → messages converted to ModelMessage[] → ToolLoopAgent runs with ~25 tools (searchInbox, manageInbox, sendEmail, etc.) → each tool calls the Google Gmail or Microsoft Graph API via the GmailProvider/OutlookProvider classes — tools that change state (send, delete rule, save inferred memory) return requiresConfirmation: true and confirmationState: 'pending' (e.g., apps/web/utils/ai/assistant/tools/rules/create-rule-tool.ts:69-75), which the frontend renders as a confirm button that fires a server action.

CopilotKit/OpenBot

answered

Agent loop and runtime. The runtime is built on @copilotkit/runtime/v2 in Intelligence mode (server/src/copilot.ts:52-62). The server mounts a CopilotRuntime via Hono that drives agents over the AG-UI protocol. Built-in agents (the 13 shipped coworkers) run as BuiltInAgent instances; external agents are HttpAgent instances — anything that speaks AG-UI (LangGraph, Mastra, CrewAI, Pydantic AI, Google ADK, or hand-written servers) works without adapters. The runtime is always in Intelligence mode because CopilotKit Intelligence is required for durable threads, memory, and learning.

Frontend/backend split. The browser app (app/) is a React application built with TanStack Router (app/src/router.tsx:1-8). It communicates with the server via TanStack Query (React Query). The server (server/) is a Hono app running on Bun (server/src/app.ts). Both are colocated in the monorepo and share the shared/ package for types. The frontend renders the AG-UI stream and manages sign-in; the server handles all agent orchestration, policy, memory, and data.

Main packages. The monorepo at package.json declares workspaces: app, server, worker. Thirteen agent-* directories each implement one agent framework adapter (agent-mastra, agent-langgraph, agent-crewai, agent-pydantic-ai, agent-adk, agent-ag2, agent-agno, agent-langroid, agent-llamaindex, agent-strands, agent-claude-sdk, agent-bot, agent-computer). The desktop/ and mobile/ directories hold Tauri desktop and mobile builds. supervisor/ manages per-Bot Docker containers. shared/ contains model provider specs, bot prompts, and utilities.

Request flow. A user types in the browser → the AG-UI stream arrives at the server → the runtime resolves the target agent via ActorAgentResolver (server/src/agents/agent-resolver.ts) → the agent's prompt is assembled with standing role, memory and learning injected as system messages → the agent runs against its provider (OpenAI/Anthropic/Google) → every tool call the agent makes passes through the gateway (server/src/computer/gateway.ts:1-15), which: (1) resolves snapshot refs on the server, never from what the model claimed; (2) evaluates the action policy (server/src/computer/policy.ts); (3) passes through the approvals gate for human-in-the-loop; (4) records every action in the audit trail — then and only then acts.

Editor's note. Correction: the server runs Hono on Bun, not Elysia (see server/package.json, server/src/app.ts). Desktop is Tauri, but mobile is an Expo app, not Tauri. There are 15 agent-* packages, including agent-microsoft and agent-langgraph-agui.

elie222/rakazo

answered

Architecture overview. Rakazo is structured as a monorepo (packages/ for domain logic, apps/ for deployable surfaces) built in TypeScript. The backend is two processes: a Hono/oRPC API server (apps/api/src/app.ts) that handles HTTP requests, authentication (Better Auth), WebSocket realtime fanout, and RPC endpoints, and a Graphile Worker (apps/worker/src/index.ts) that runs the actual agent loops as background jobs. The API enqueues run jobs; the worker picks them up and calls the executor.

Agent loop and runtime. The core execution lives in packages/adapters/src/executor.ts in createRunExecutor(). The exported continueRun() method (line 3166) leases the run from Postgres, sets up a computer execution lease, resolves the model credential, builds the system prompt, assembles conversation history (including compacted summaries and semantic recall), and calls deps.runtime.run() (line 6134). The runtime is either the Pi agent runtime (PiAgentRuntime, which uses @earendil-works/pi-agent-core for tool-calling LLM loops) or a ScriptedAgentRuntime for deterministic replay. The Pi runtime (packages/adapters/src/pi-runtime.ts) orchestrates the model stream, tool execution, and approval pauses.

Frontend/backend split. The three frontends (web React/Electron via apps/web/, and Expo mobile via apps/mobile/) are pure clients of the API. The web app uses shadcn/ui components from packages/ui-web and semantic tokens from @rakazo/ui-tokens. Desktop Electron hosts the web UI with added native setup/sandbox management. Mobile is native-first with Expo Router and StyleSheet, diverging only where native patterns are stronger.

User request flow. A user sends a message via the web/mobile composer → API RPC handler (apps/api/src/router.ts enqueues a run via runContinueJob) → Graphile Worker picks up the job → continueRun() in executor.ts leases the run, resolves the bot's model and tools, and calls PiAgentRuntime.run() → the LLM streams tokens and tool calls → results are persisted as MessageBlock rows and fanned out via Postgres realtime to the frontend.

ShenSeanChen/waku-agent

answered

Waku is wired together in waku/app.py (the Waku class). Entry points in waku/main.py dispatch to gateways: CLI, dashboard, Telegram, Discord, WhatsApp, voice. Each gateway feeds text into Waku.respond(), which builds working memory via Session.build_system() (waku/runtime/session.py): a SOUL.md persona file, current datetime, gated memory retrieval, and matching skill instructions. The core loop is run_loop() in waku/loop/agent.py: a synchronous while loop that calls the LLM with tool schemas from waku/tools/registry.py, executes tool calls, feeds results back as new messages, and repeats until the model stops asking for tools or hits max_iterations (default 15). Guardrail 2 produces a final tools-off call. Working memory is a sliding window of the last 24 rows (history_turns * 2). An optional graph layer (waku/graph/engine.py) wraps the loop with deterministic node-and-edge workflows; the triage workflow sends trivial messages through a quick small-model path and everything else through the full loop as a graph node. Frontend is waku/ops/dashboard.py, a stdlib HTTP server serving static files. The loop uses Anthropic Messages wire format natively and adapts OpenAI wire format via OpenAICompatClient in waku/loop/models.py.

agenvoy/Agenvoy

answered

Agenvoy is a single Go binary that runs as a local daemon (cmd/app/daemon.go). The daemon boots, initialises filesystem/DB/ToriiDB, spawns a Gin HTTP server on 127.0.0.1:17989, and serves an embedded web dashboard (internal/runtime/webapp/) plus a TUI (internal/runtime/tui/). The agent execution loop lives in internal/agents/exec/execute.go::Execute(). A user request arrives via HTTP POST to /v1/send, which calls Execute() with an ExecuteMeta struct containing the agent config, content, session ID, tools, and skill. Inside Execute() there is a for range limit loop (max 256 iterations) that: assembles messages via compact.AssembleMessages(), streams the LLM call (via go-llm-router/core), handles tool calls via toolCall(), and feeds results back to the model. The LLM is wrapped as a provider.Agent from go-llm-router. Tools are executed through an Executor that dispatches by name to registered handler groups (tools/register.go registers built-in tools like run_command, read_files, edit_file, plus dynamic groups api_, script_, ext_ for API tools, script tools, and extension tools). The full pipeline: request → route handler → Execute() → streamSend() → LLM response → tool call → tool result → loop back to LLM → final text. The frontend has no separate server — the daemon serves the web UI from embedded assets (page/page.go) and all API endpoints are localhost-only except session chat and confirm endpoints, which CORS-restrict to local origins.

How are integrations (email, calendar, chat, docs) implemented? →