Agentic Workflow

Throughput and business signals

Features per second per dollar. The north-star metric every routing decision is graded against.

Two coupled metrics drive the agentic pipeline:

Features per second per token

Definition

features_per_second_per_token = features_shipped / (elapsed_seconds × total_tokens_consumed)

Where:

The metric is deliberately tiny in absolute value (10⁻⁹ scale). What matters is the trajectory: are we trending toward more features per token over time? Are specific routing changes moving the number?

Where it's logged

Every PR that merges through the pipeline writes a row to .compound-state/agent-service.db (sqlite) on the Mac mini server:

CREATE TABLE pipeline_runs (
  id              INTEGER PRIMARY KEY,
  feature_slug    TEXT,
  spec_path       TEXT,
  pr_number       INTEGER,
  merged_at       TEXT,           -- ISO timestamp
  elapsed_seconds INTEGER,        -- stage 1 → stage 8
  tokens_total    INTEGER,
  cost_usd        REAL,
  features_per_second_per_token REAL,
  per_role_breakdown JSON         -- tokens + cost per role
);

Schema is illustrative — the actual table lives in be-agent-service and evolves with the pipeline.

Who reads it

The optimization mathematician agent (see agents-optimization.md) reads this table on a weekly cadence to propose model-routing rotations. Inputs to its proposal:

Output: a proposed adjustment to model-and-vendor-agnosticism.md's routing matrix, with a justification grounded in the data above. The CPO/CTO management agent ratifies or rejects.

Business signals

The pipeline is not allowed to optimise pure throughput in isolation — it must respect cash. Vision commitment (d): budgets and cash balance are system inputs.

Inputs

Signal Source Update cadence
Cash balance Finance system / bank API Daily
Monthly burn Derived from cash balance trajectory Weekly
Revenue Stripe / billing system Daily
Funnel metrics Product analytics (shuri-product-analyst agent) Daily
Pipeline cost .compound-state/agent-service.db rollup Real-time per PR

These feeds are read by the orchestrator before any expensive operation. The orchestrator can refuse to spawn an Architect call if the projected pipeline cost would exceed today's budget.

Constraints derived from signals

daily_pipeline_budget_usd = monthly_pipeline_budget × (cash_runway_factor × revenue_growth_factor)

per_feature_budget_usd    = daily_pipeline_budget_usd / expected_features_today

Order of operations:

  1. The CEO management agent sets monthly_pipeline_budget based on cash + revenue.
  2. The CPO/CTO management agent allocates that across pipeline cost, scale-or-kill ramps, and reserved capacity.
  3. The orchestrator queries the residual daily budget before each pipeline run.
  4. The mathematician's routing proposals are constrained: never propose a rotation that would push expected per-feature cost above the budget.

What "tied to business signals" means concretely

If revenue accelerates → cash runway extends → daily pipeline budget grows → mathematician can rotate to higher-quality (= more expensive) routes for Architect / Editor.

If revenue softens → cash runway tightens → daily pipeline budget shrinks → mathematician rotates toward cheaper routes; aggressive scaling pauses; non-essential pipeline branches (nightly research lab campaigns) are throttled.

The point of vision commitment (d) is that this happens without a human deciding "ok, tighten the belt". The signal is the input; the response is mechanical.

Pilot phase: budget enforcement is OFF by default

The runner gates cost-ceiling enforcement behind PIPELINE_BUDGET_ENFORCEMENT (default off). Code at be-agent-service/apps/server/src/pipeline/budget.ts.

Why off in pilot:

Flip on (PIPELINE_BUDGET_ENFORCEMENT=on, optional MAX_COST_PER_RUN_USD=...) when:

  1. Multiple humans (or agents) create PRDs concurrently.
  2. Real revenue / cash signals are wired into the orchestrator's pre-flight check.
  3. The mathematician has at least 4–6 weeks of throughput rows to base routing decisions on.

The runner logs budget enforcement ON / budget enforcement OFF (pilot mode) on every run kickoff so operators see the state at a glance.

What this rules out

What this allows

Cross-references