3.9 kB 93 lines
61eb6474
⋯
packages/coding-agent/docs/architecture.md
download raw history
at main Markdown

Architecture Overview #

Prime Agent separates terminal presentation, process coordination, agent execution, model-facing Python, and persisted state. Normal interactive sessions use the daemon-backed path below; explicit SDK and fallback integrations can run the same AgentSessionRuntime in process.

System at a Glance #

Session worker · one root session treelocal daemon protocollocal daemon protocolmodel streamsmodel streamsInteractive TUIPrint · JSON · RPC clientsAgentConnectionclient-side executionboundaryDaemon supervisorrouting · attachments ·recoveryCatalog processsaved-session scansAgentSessionRuntimeRoot AgentSessionSchedulerRoot Python kernelRLM child runtimessession + optional kernelModel providersSession JSONL + artifacts
  • The client owns rendering, keyboard input, and local UI preferences; it does not own execution.
  • The supervisor owns discovery, routing, attachments, worker health, and cross-agent message delivery.
  • Each worker owns one root runtime, its scheduler, kernels, and all descendants below that root.
  • AgentSession owns provider calls, queues, tools, compaction, goals, child lifecycles, and transcript writes.
  • The Python REPL is the model-facing control environment. Typed host requests return authoritative operations to the TypeScript session.

Workers and kernels are separate processes for lifecycle and failure containment, not security sandboxes. They normally run with the same operating-system permissions as the client.

Prompt Execution Flow #

[Ordinary execution]alt[Typed host request]opt[Python tool call]prompt, steer, or follow-upversioned commandroute to active sessionenqueue promptstream model requesttext or Python tool callexecute Pythonrequest host operationhost resultresult, stdout, or errorappend transcript and artifactssession eventsgeneration-aware eventslive stream or recovery snapshotrender updated stateUser interfaceAgentConnectionSupervisorSession workerAgentSessionModel providerPython kernelSession storageUser interfaceAgentConnectionSupervisorSession workerAgentSessionModel providerPython kernelSession storage

From the session queue onward, the same execution and persistence path is used when a prompt comes from a heartbeat, cron schedule, goal continuation, autonomous mode, or another agent instead of an attached user.

Detailed Architecture #