Skip to main content

Architecture Overview

PilotDeck uses a layered modular architecture. Each module has a clear responsibility and public interface.

System View​

User Interaction LayerCLIChannelTUIChannelWeb UIChannelDesktopElectronFeishuChannelGatewayWS / HTTPMessage Gateway LayerSessionRouterCreate / Find / ManageSession Routing LayerAgentSessionTurnRunnerAgentLoopAgent Runtime LayerRouterModelContextMemoryToolSessionStore

Module List​

ModuleDirectoryResponsibility
Adapterssrc/adapters/Channel adapters and Web static mounting
Agentsrc/agent/AgentSession, TurnRunner, and AgentLoop
Always-Onsrc/always-on/Discovery runtime
CLIsrc/cli/CLI entry points such as server, tui, and cron
Contextsrc/context/Prompt assembly, projection, budget, compaction, and memory
Cronsrc/cron/Scheduled task runtime
Extensionsrc/extension/Lifecycle hooks, plugins, and contributions
Gatewaysrc/gateway/In-process and WebSocket Gateway with SessionRouter
Lifecyclesrc/lifecycle/Lifecycle runtime and hook effects
MCPsrc/mcp/Model Context Protocol client integration
Modelsrc/model/Canonical model protocol and provider adapters
Permissionsrc/permission/Permission policy and decision runtime
Pilotsrc/pilot/Path management and config loading
Routersrc/router/Scenarios, fallback, TokenSaver, custom routers
Sessionsrc/session/Transcript persistence, metadata, listing, and restore
Tasksrc/task/Background task management
Toolsrc/tool/Tool registry, runtime, built-ins, scheduler
Websrc/web/Web static resource service

Agent Execution Layer​

AgentSession is the runtime container for a conversation. It manages transcript, context state, tool registry, and model routing.

TurnRunner manages one user turn:

User input
│
▼
┌─────────────────┐
│ Prepare context │ ← PromptAssembler + MessageProjector + MemoryResolver
└────────┬────────┘
▼
┌─────────────────┐
│ Route model │ ← Router.decide()
└────────┬────────┘
▼
┌─────────────────┐
│ Execute request │ ← Router.execute() → ModelRuntime.stream()
└────────┬────────┘
▼
┌─────────────────┐
│ Run tools │ ← ToolRuntime.execute()
└────────┬────────┘
▼
┌─────────────────┐
│ Stream response │ ← Gateway → Channel
└─────────────────┘

AgentLoop handles multiple rounds of model tool calls until the model stops calling tools.

Context Management​

Context manages the full window for each request, including core instructions, project instructions, skills, memory, tool definitions, historical message projection, token budgets, and compaction.

Model Layer​

All providers are normalized into PilotDeck's Canonical Protocol:

  • CanonicalModelRequest
  • CanonicalModelEvent
  • CanonicalMessage
  • CanonicalUsage
ProtocolProvider examples
anthropicAnthropic API and compatible proxies
openaiOpenAI API, Azure OpenAI, DeepSeek, compatible proxies

Tool System​

PilotDeck includes built-in tools such as bash, read_file, write_file, edit_file, glob, grep, web_fetch, web_search, agent, ask_user_question, structured_output, and background task tools.

Tool scheduling supports:

  • ConcurrentToolScheduler for independent operations
  • SequentialToolScheduler for dependent or write-heavy operations

Extension System​

Extensions add plugins, skills, lifecycle hooks, commands, and MCP server instructions.