How it's built

A small, honest version of an enterprise AI platform: the same controls a regulated payments company needs, at a size one person can run on a single server. The status below comes from the running app.

Architecture

Agents never call each other. They read and write the shared case record; the routing engine chooses who goes next.

Requests enter through triage, the routing engine dispatches agents that read and write a shared case record, model calls pass through the LLM gateway, and the Control Tower reads the logs. Intake and triage Value gate, workflow choice,low confidence to a person Routing engine Next agent = first whose preconditionsare met; retries, kill switches,every hop logged with its reason Shared case record Versioned keys, writer on every valuePer-agent read/write contractsRe-runs keep full historySQLite here; Postgres in production Agents (19) Classify & extract (worker)Quote grounding (code)Records lookup (tool) Checks, specialists (code)Policy rules (code)Drafter (worker) Independent reviewer(supervisor, other model)Approval gate (code) LLM gateway Card-number maskingInjection screenResponse cacheDaily cap, fallbackCost and promptversion logging ModelsWorker: Sonnet 5.5Supervisor: Haiku 5.5 Rule packs and records Versioned, cited rulesSynthetic systems of record PeopleApprove, override with a reason Control Tower, evaluation harness, audit chain

Carried over from earlier prototypes

  • Worker and supervisor built separately, on different models; the Admin screen refuses to make them the same.
  • The supervisor can only lower confidence or flag. It cannot approve or rewrite.
  • AI classifies and drafts; versioned rules decide; numbers and dates are computed in code.
  • Every extracted fact carries a quote, and code checks the quote exists in the source.
  • Human approval with a required reason for any change.
  • Hash-chained audit, cost per task, daily cap, offline fallback, evaluation-gated releases, AI risk card.
  • Public guest view for reviewers; settings behind an admin passcode.

New in this one

  • Shared case record with per-agent contracts, so agents are decoupled and auditable.
  • State-driven routing engine with conditional specialists and logged reasons for every hop.
  • One LLM gateway: masking, injection screen, cache with dollars saved, kill switches, fallback.
  • Pattern library: the second workflow reused 9 of its 10 blocks from the first.
  • Red-team cases in the evaluation set; one miss blocks a release.
  • Live production-readiness scorecard and a value ledger against the intake estimate.
  • Learning loop: human overrides become test-set candidates.
  • "Explain this screen" chat on every screen: it answers only from what's on the page, quotes are checked in code, a second model can withhold the answer, and off-page questions are refused.

What production at enterprise scale would change

HereAt enterprise scale
SQLite case recordPostgres or a document store, with an event bus (for example Kafka) so agents scale out as independent consumers
In-process routerDurable workflow engine (for example Temporal) with the same state-based routing and retry policy
Exact-match cacheShared cache plus semantic cache with per-tenant isolation and expiry tied to prompt and rule versions
Rules in codeRules as policy-as-code in a governed repository, with sign-off by risk and compliance before release
Admin passcodeSSO, role-based access, segregation of duties between builders, approvers and auditors
App logs and tablesOpenTelemetry traces per hop, central dashboards, alerting on drift, cost and override rate
Hash-chained tableWrite-once storage for the audit trail, retained under the records policy
Evaluation on demandEvaluations in CI on every prompt, rule or model change, plus scheduled drift runs on sampled production cases
Synthetic dataReal systems of record through governed APIs, card data tokenised before it reaches the platform

Stack

Python 3.13, FastAPI and SQLite on a single Lightsail server behind Caddy. Plain HTML, CSS and JavaScript with no build step. Anthropic models by default; an OpenAI model can be added as a cross-vendor supervisor when its key is set. 20 automated tests cover routing, contracts, masking, the cache, the release gate and the audit chain.