# sapientinc/praxist architecture

> Architecture diagram of the GitHub repository sapientinc/praxist, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sapientinc/praxist
- Repository: https://github.com/sapientinc/praxist

## Overview

#### Purpose and entry points
Praxist is a Python 3.11+ autonomous R&D orchestrator for already-runnable, measurable task projects. It manages parallel agents, task-defined evaluation, evidence, scheduling, and multi-generation synthesis; the task project remains authoritative for domain code and validity.

Primary CLI dispatch is `praxist/__main__.py`, with run invocation in `praxist/run.py` and operational commands in `praxist/cli/start.py`, `praxist/cli/resume.py`, and `praxist/cli/monitor.py`. Codex/Claude-facing skills provide the common takeover/onboarding interface under `skills/`.

#### Project and configuration boundary
A task project supplies `task.yaml`, prompts, roles, evaluator definitions, assets, and audit rules. Core task loading and compatibility are in `praxist/core/task_project.py` and `praxist/task_spec.py`; run settings, credential handling, and persisted state are separated in `praxist/core/run_config.py`, `praxist/core/credentials.py`, and `praxist/core/storage.py`.

Templates establish this contract, e.g. `templates/tasks/template/task.yaml`, `templates/tasks/template/evaluations/pareto_tiered/evaluation.yaml`, and `templates/tasks/template/roles/chair/role.yaml`. This isolates Praxist’s generic orchestration from scientific assumptions and executable evaluation owned by a task.

#### Plugin registry and runtime integrations
The registry resolves extensible implementations for agent runtimes, model providers, tools, roles, budgets, panel topologies, evaluations, and workflow stages: `praxist/core/registry.py`, `praxist/core/runtimes.py`, and `praxist/core/tool_servers.py`.

Built-in runtime adapters target Claude SDK and Codex SDK at `praxist/plugins/agent_runtimes/claude_sdk/adapter.py` and `praxist/plugins/agent_runtimes/codex_sdk/adapter.py`. Model-provider adapters include Anthropic, OpenAI-compatible APIs, OpenRouter, and DeepSeek aliases under `praxist/plugins/model_providers/`. Tool plugins expose MCP/stdio-backed capabilities such as browser, Brave Search, arXiv, literature lookup, and local system tools.

#### Research-loop orchestration
The central workflow stage is `praxist/plugins/workflow_stages/research_loop/stage.py`, with lifecycle wiring in `praxist/plugins/workflow_stages/research_loop/lifecycle.py` and run coordination in `backend/orchestrator_runtime.py`. It creates generations, prepares prompts and runtime environments, dispatches peer work, waits for events, handles stop/resume, and produces run summaries/reports.

The principal control flow is: task contract + resolved plugins/config → run lifecycle → peer/panel generation work → candidate experiments → normalized findings/evidence → selection and next-generation agenda → final report or resumable state.

#### Agents, panels, and generation planning
Peers operate through agent abstractions and generation loops in `backend/agent.py`, `backend/generation_loop.py`, and `backend/pi_agent.py`. Multi-PI panel execution, agenda validation, cross-review, and chair arbitration are isolated in `backend/multi_pi/panel_runner.py`, `backend/multi_pi/agenda_validator_v2.py`, and `backend/multi_pi/chair_arbiter.py`.

Optional exploration controls include QD/DIG cohort allocation, validation, selection, and write gates in `backend/dig/cohort_allocator.py`, `backend/dig/selection.py`, and `backend/dig/write_gate.py`. These form a decision boundary before generated plans become durable research actions.

#### Evaluation, evidence, and durable memory
Task evaluators execute candidates; their results become structured findings and retention lanes. Relevant boundaries are `backend/experiment_exec.py`, `backend/findings_collection.py`, and `backend/frontier.py`. Baseline provenance/caching and effective configuration are maintained in `backend/baseline_cache.py` and `backend/effective_config.py`.

Research memory converts validated outputs into cards, evidence packs, and specialized ledgers rather than relying on prompt history: `backend/research_memory/card_builder.py`, `backend/research_memory/evidence_pack_builder.py`, and `backend/research_memory/ledgers/claim_ledger.py`. This evidence feeds synthesis and supports replay/provenance.

#### Resources, infrastructure, and telemetry
A central scheduler admits and monitors experiments based on resource pressure: `backend/resource_scheduler.py`, `backend/experiment_scheduler.py`, and `backend/gpu_governor.py`. RunPod and S3 integration are available through `praxist/infrastructure/runpod.py` and `praxist/infrastructure/s3_utils.py`; S3 sync is a research-loop hook.

Optional product-usage telemetry is a separate client/collector service, not task data collection: `praxist/product_usage/client.py`, `praxist/product_usage/collector.py`, and `services/product_usage/deploy/compose.yml`. It uses PostgreSQL migrations and a containerized deployment surface.

Main entry points: [`praxist/plugins/workflow_stages/research_loop/stage.py`](https://github.com/sapientinc/praxist/blob/main/praxist/plugins/workflow_stages/research_loop/stage.py) (Research-loop stage), [`praxist/run.py`](https://github.com/sapientinc/praxist/blob/main/praxist/run.py) (Run invocation), [`praxist/core/registry.py`](https://github.com/sapientinc/praxist/blob/main/praxist/core/registry.py) (Plugin registry), [`praxist/core/task_project.py`](https://github.com/sapientinc/praxist/blob/main/praxist/core/task_project.py) (Task loading)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_task["Task Project"]
  node_task_contract["Task contract<br/>task project<br/>[task.yaml]"]
end

subgraph group_core["Praxist Core"]
  node_cli["CLI dispatch<br/>Python CLI<br/>[__main__.py]"]
  node_run["Run invocation<br/>run API<br/>[run.py]"]
  node_task_loader["Task loading<br/>task compatibility<br/>[task_project.py]"]
  node_run_state[("Run settings &amp; state<br/>configuration storage<br/>[run_config.py]")]
  node_plugin_registry["Plugin registry<br/>extension registry<br/>[registry.py]"]
  node_agent_runtimes["Agent runtime adapters<br/>Claude/Codex adapters<br/>[adapter.py]"]
end

subgraph group_workflow["Research Workflow"]
  node_research_stage["Research-loop stage<br/>workflow stage<br/>[stage.py]"]
  node_orchestrator["Run coordinator<br/>orchestrator runtime"]
  node_generation_loop["Peer generation loop<br/>agent execution"]
  node_panel["Multi-PI panel<br/>panel arbitration"]
  node_dig_gate{{"DIG decision gate<br/>cohort selection"}}
end

subgraph group_evidence["Evaluation &amp; Memory"]
  node_experiments["Candidate experiments<br/>task evaluation"]
  node_findings[("Normalized findings<br/>evidence collection")]
  node_frontier["Research frontier<br/>selection state"]
  node_research_memory[("Research memory<br/>cards and evidence packs")]
end

subgraph group_infra["Infrastructure"]
  node_scheduler["Experiment scheduler<br/>resource admission"]
  node_cloud_storage["RunPod &amp; S3<br/>cloud integration<br/>[runpod.py]"]
  node_usage_telemetry["Product usage telemetry<br/>separate collector service<br/>[client.py]"]
end

node_cli -->|"invokes"| node_run
node_run -->|"loads task"| node_task_loader
node_task_contract -->|"defines contract"| node_task_loader
node_run -->|"reads and persists"| node_run_state
node_run -->|"resolves extensions"| node_plugin_registry
node_task_loader -->|"task definition"| node_research_stage
node_run_state -->|"settings and resume state"| node_research_stage
node_plugin_registry -->|"selects runtime"| node_agent_runtimes
node_plugin_registry -->|"selects stage"| node_research_stage
node_research_stage -->|"coordinates run"| node_orchestrator
node_orchestrator -->|"creates generations"| node_generation_loop
node_agent_runtimes -->|"executes peers"| node_generation_loop
node_generation_loop -->|"submits plans and reviews"| node_panel
node_panel -.->|"optional exploration control"| node_dig_gate
node_panel -->|"approved work"| node_scheduler
node_dig_gate -->|"durable action approval"| node_scheduler
node_scheduler -->|"admits and monitors"| node_experiments
node_task_contract -->|"task evaluator"| node_experiments
node_experiments -->|"evaluation results"| node_findings
node_findings -->|"retained candidates"| node_frontier
node_findings -->|"validated evidence"| node_research_memory
node_research_memory -->|"evidence for synthesis"| node_generation_loop
node_frontier -->|"next-generation agenda"| node_generation_loop
node_research_stage -.->|"S3 sync hook"| node_cloud_storage
node_usage_telemetry -.->|"optional usage events"| node_research_stage

click node_cli "https://github.com/sapientinc/praxist/blob/main/praxist/__main__.py"
click node_run "https://github.com/sapientinc/praxist/blob/main/praxist/run.py"
click node_task_contract "https://github.com/sapientinc/praxist/blob/main/templates/tasks/template/task.yaml"
click node_task_loader "https://github.com/sapientinc/praxist/blob/main/praxist/core/task_project.py"
click node_run_state "https://github.com/sapientinc/praxist/blob/main/praxist/core/run_config.py"
click node_plugin_registry "https://github.com/sapientinc/praxist/blob/main/praxist/core/registry.py"
click node_agent_runtimes "https://github.com/sapientinc/praxist/blob/main/praxist/plugins/agent_runtimes/claude_sdk/adapter.py"
click node_research_stage "https://github.com/sapientinc/praxist/blob/main/praxist/plugins/workflow_stages/research_loop/stage.py"
click node_cloud_storage "https://github.com/sapientinc/praxist/blob/main/praxist/infrastructure/runpod.py"
click node_usage_telemetry "https://github.com/sapientinc/praxist/blob/main/praxist/product_usage/client.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_task_contract toneBlue
class node_cli,node_run,node_task_loader,node_run_state,node_plugin_registry,node_agent_runtimes toneAmber
class node_research_stage,node_orchestrator,node_generation_loop,node_panel,node_dig_gate toneMint
class node_experiments,node_findings,node_frontier,node_research_memory toneRose
class node_scheduler,node_cloud_storage,node_usage_telemetry toneIndigo
```

## Components

### Task Project

Domain contract and executable evaluation remain task-owned.

- [Task contract](https://github.com/sapientinc/praxist/blob/main/templates/tasks/template/task.yaml): task project · Supplies prompts, roles, evaluators, assets, and audit rules. · `templates/tasks/template/task.yaml`

### Praxist Core

- [CLI dispatch](https://github.com/sapientinc/praxist/blob/main/praxist/__main__.py): Python CLI · `praxist/__main__.py`
- [Run invocation](https://github.com/sapientinc/praxist/blob/main/praxist/run.py): run API · `praxist/run.py`
- [Task loading](https://github.com/sapientinc/praxist/blob/main/praxist/core/task_project.py): task compatibility · `praxist/core/task_project.py`
- [Run settings & state](https://github.com/sapientinc/praxist/blob/main/praxist/core/run_config.py): configuration storage · Separates settings, credentials, and persisted resumable state. · `praxist/core/run_config.py`
- [Plugin registry](https://github.com/sapientinc/praxist/blob/main/praxist/core/registry.py): extension registry · Resolves runtimes, providers, tools, roles, budgets, panels, evaluations, and stages. · `praxist/core/registry.py`
- [Agent runtime adapters](https://github.com/sapientinc/praxist/blob/main/praxist/plugins/agent_runtimes/claude_sdk/adapter.py): Claude/Codex adapters · `praxist/plugins/agent_runtimes/claude_sdk/adapter.py`

### Research Workflow

- [Research-loop stage](https://github.com/sapientinc/praxist/blob/main/praxist/plugins/workflow_stages/research_loop/stage.py): workflow stage · Owns lifecycle wiring, stop/resume, summaries, and reports. · `praxist/plugins/workflow_stages/research_loop/stage.py`
- **Run coordinator**: orchestrator runtime
- **Peer generation loop**: agent execution · Prepares environments and dispatches parallel peer work.
- **Multi-PI panel**: panel arbitration · Validates agendas, cross-reviews work, and lets a chair arbitrate.
- **DIG decision gate**: cohort selection · Optional allocation, validation, selection, and write controls.

### Evaluation & Memory

- **Candidate experiments**: task evaluation · Executes task-defined candidates.
- **Normalized findings**: evidence collection · Structures evaluator results into retention lanes.
- **Research frontier**: selection state
- **Research memory**: cards and evidence packs · Maintains durable claims and provenance rather than prompt history.

### Infrastructure

- **Experiment scheduler**: resource admission · Schedules experiments under resource pressure and GPU governance.
- [RunPod & S3](https://github.com/sapientinc/praxist/blob/main/praxist/infrastructure/runpod.py): cloud integration · Provides remote execution support and research-loop S3 sync. · `praxist/infrastructure/runpod.py`
- [Product usage telemetry](https://github.com/sapientinc/praxist/blob/main/praxist/product_usage/client.py): separate collector service · Optional product-usage collection, separate from task data. · `praxist/product_usage/client.py`

## Connections

- CLI dispatch → Run invocation: invokes
- Run invocation → Task loading: loads task
- Task contract → Task loading: defines contract
- Run invocation → Run settings & state: reads and persists
- Run invocation → Plugin registry: resolves extensions
- Task loading → Research-loop stage: task definition
- Run settings & state → Research-loop stage: settings and resume state
- Plugin registry → Agent runtime adapters: selects runtime
- Plugin registry → Research-loop stage: selects stage
- Research-loop stage → Run coordinator: coordinates run
- Run coordinator → Peer generation loop: creates generations
- Agent runtime adapters → Peer generation loop: executes peers
- Peer generation loop → Multi-PI panel: submits plans and reviews
- Multi-PI panel → DIG decision gate: optional exploration control
- Multi-PI panel → Experiment scheduler: approved work
- DIG decision gate → Experiment scheduler: durable action approval
- Experiment scheduler → Candidate experiments: admits and monitors
- Task contract → Candidate experiments: task evaluator
- Candidate experiments → Normalized findings: evaluation results
- Normalized findings → Research frontier: retained candidates
- Normalized findings → Research memory: validated evidence
- Research memory → Peer generation loop: evidence for synthesis
- Research frontier → Peer generation loop: next-generation agenda
- Research-loop stage → RunPod & S3: S3 sync hook
- Product usage telemetry → Research-loop stage: optional usage events
