Skip to content

Agent Architecture ​

QDash Agent connects the chat UI to a durable Pi runtime and calls QDash tools as the signed-in user. For operating the assistant, see Agent.

Component Diagram ​

Chat page /agent Task result chat Ask Agent · sidebar MongoDB chat sessions · results API agent router Runtime state agent-runtime-state Agent runtime pi · pi-qdash · pi-qcaleval config/agent chat · evaluation.yaml Chat model OpenAI-compatible API Evaluation model vLLM · Ising POST /chat/stream (SSE) same route + task sessions · task context POST /chat NDJSON events back tools · Python sandbox as the signed-in user durable sessions models.json at startup planner turns qcal_evaluate UI API Agent runtime Data or config External model
The API forwards a chat turn to the runtime; tools call QDash with the user's project and permissions.

Pi runtime authentication ​

The API forwards the user's access token and selected project on every turn, including approval responses. Without a project header, it uses the user's default project. A separate internal secret authenticates API-to-runtime requests. Neither credential belongs in model input or conversation storage.

Compose's agent-runtime-auth service creates the shared secret in a dedicated volume. The API and runtime read it through AGENT_RUNTIME_TOKEN_FILE.

Durable conversations ​

The runtime stores conversations in SQLite under agent-runtime-state. Branches share the source store and workspace. Disconnecting the browser does not stop a turn; stopping and reconnecting use explicit turn IDs. See Chat Streaming.

Back up the state volume before upgrading Pi: opening an older store can migrate its schema, and restoring an older runtime may require restoring that backup.

Code Mode and deferred tools ​

codemode composes tool calls in JavaScript; tool_search discovers deferred tools. Their policy still enforces tool visibility and write approvals. Shell and file operations run in the separate workspace, never in the runtime process.

Page context and editor edits ​

A turn can include the open page and unsaved editor text. Proposed edits change the editor only when accepted; saving or executing remains a separate action. Failure investigations load their evidence through project-authorized API reads.

Configuration ​

Model selection belongs to Model Configuration. Task knowledge and shared instructions belong to Knowledge Layout. Recorded figure judgments belong to Calibration Evaluation.

Developing a pi extension against the runtime ​

Follow package setup before editing the bundled packages. Run task ci-pi-packages and task ci-agent-runtime, then rebuild:

bash
docker compose up -d --build agent-runtime

The runtime loads the bundled extensions with their tool allowlist and approval boundary. See Pi Extension Design before adding tools.

Key Files ​

FileResponsibility
src/qdash/api/routers/agent.pyAuthenticated chat routes
src/qdash/api/services/pi_chat_service.pyAPI-to-runtime bridge
agent-runtime/src/runtime.tsDurable sessions and runtime lifecycle
agent-runtime/src/chat-registry.tsPer-chat tools, context, and policy
agent-runtime/src/page-context.tsPage context and edit proposals

Released under the Apache 2.0 License.