OpenEinstein is a local-first AI research platform for theoretical physics. The core platform is domain-agnostic; specialization belongs in Campaign Packs.
- Use logical model roles (
reasoning,generation,fast,embeddings), never hardcoded model IDs in feature logic. - Route all model selection through the model routing subsystem.
- Route all tool calls through ToolBus abstractions. Do not call MCP/CLI tools directly from domain logic.
- Keep core platform generic; put physics-subfield specifics in
campaign-packs/. - Prefer protocol/interface boundaries for subsystems (gateway, routing, tools, persistence, tracing).
- Python 3.12+
- Pydantic / PydanticAI / LiteLLM
- MCP SDK + CLI+JSON tool wrappers
- SQLite (default persistence)
- Typer (CLI)
- OpenTelemetry-compatible tracing
- Pytest for testing
src/openeinstein/core: core contracts and canonical personasrc/openeinstein/gateway: control plane, approvals, policy enforcementsrc/openeinstein/agents: orchestrator and specialized subagent definitionssrc/openeinstein/tools: ToolBus, MCP connection management, tool registrysrc/openeinstein/campaigns: campaign config, state machine, execution enginesrc/openeinstein/routing: role-based model routing and fallback policiessrc/openeinstein/persistence: SQLite tables, migrations, typed CRUD APIssrc/openeinstein/tracing: span instrumentation and exporterssrc/openeinstein/evals: eval suite schemas and runnerssrc/openeinstein/security: approvals, sandbox policy, invariantssrc/openeinstein/cli: CLI commands for run/control/reporting
- Keep imports stable and explicit; avoid circular imports.
- Prefer typed function signatures and Pydantic models at boundaries.
- Keep modules small and cohesion high by subsystem.
- Put experimental or domain-specific logic into campaign packs.
- Keep docs and integration contracts updated with structural changes.
- Hardcoded provider/model names in business logic
- Direct calls to provider SDKs from agent code
- Direct subprocess/MCP calls bypassing ToolBus
- Policy checks implemented only in prompt text (must be machine-enforced)
- Campaign-specific physics heuristics embedded into core platform modules
- Add or update unit tests for every new subsystem behavior.
- Add integration tests for cross-subsystem wiring (routing, tool bus, persistence, tracing).
- Add eval fixtures for persona, safety, and campaign regression when behavior changes.
- Run
pytestbefore merging.
- Canonical docs live in
docs/canonical/. - Architectural decisions live in
docs/decisions/as ADRs. - Build plans live in
docs/build-plans/. - Keep
AGENTS.mdsemantically aligned with this file.
READ BUILD-READY.md BEFORE BEGINNING ANY IMPLEMENTATION WORK.
It contains the frozen decisions for:
- Core vs. plugin scope (what must pass CI vs. what gets skip-marked)
- Build environment contract (available tools and dependencies)
- Credentials and secrets (
.envstructure and key requirements per phase) - Verification loop (exact commands to run after every task)
- Stop conditions (when to halt and ask for help)
- Agent kickoff instructions (execution order, commit discipline, architecture guards)
Test skip markers for optional dependencies live in tests/conftest.py.
- Missing machine-enforced safety checks.
Fix: Encode safety invariants in
configs/POLICY.jsonand enforce in gateway hooks. - Model/provider coupling introduced in feature code. Fix: Add/extend logical role routing config and resolve roles centrally.
- Cross-domain logic leaked into core. Fix: Move domain specifics into campaign packs and expose extension hooks.