SPY751.28 0.87%QQQ722.82 1.43%DIA530.09 0.42%IWM298.90 0.44%BTC63,139 0.86%ETH1,771.45 0.83%SOL81.20 1.53%DOGE0.0748 2.32%AAPL312.66 1.31%MSFT386.74 0.96%NVDA195.55 0.37%GOOGL366.46 1.82%META600.29 2.98%TSLA419.77 6.69%AMZN244.16 0.61%JPM337.72 1.43%UST10Y4.48% 0.04%UST2Y4.17% 0.03%FFR3.63% 0.00%DXY102.40 0.21%VIX15.83 1.67%GOLD4,143.00 0.29%OIL69.20 0.95%ZHVI428,600 1.80%SPY751.28 0.87%QQQ722.82 1.43%DIA530.09 0.42%IWM298.90 0.44%BTC63,139 0.86%ETH1,771.45 0.83%SOL81.20 1.53%DOGE0.0748 2.32%AAPL312.66 1.31%MSFT386.74 0.96%NVDA195.55 0.37%GOOGL366.46 1.82%META600.29 2.98%TSLA419.77 6.69%AMZN244.16 0.61%JPM337.72 1.43%UST10Y4.48% 0.04%UST2Y4.17% 0.03%FFR3.63% 0.00%DXY102.40 0.21%VIX15.83 1.67%GOLD4,143.00 0.29%OIL69.20 0.95%ZHVI428,600 1.80%
crypto: Binance/Coinbase · equities & commodities: Yahoo · rates: FRED · DXY: static
LEVRG / 06 AI Tactics

RAG brain. Structured prompts. Agent chains.

All agent tasks are issued as JSON-structured prompts — enforcing context, output format, and constraints. Reduces hallucination and enables pipeline chaining across agents.

Graph / RAG

Knowledge base · graphified across notes, ADRs, and code. Vector index refreshed nightly.

12,418 docs · 3.2M tokens

Claude Code

Primary dev assistant — feature scaffolds, refactors, code review, and architecture sketches.

1,847 tasks · last 30d

Codex · MCP

Codegen via MCP delegation. Handles boilerplate, tests, and well-scoped diffs in parallel.

624 tasks · last 30d
JSON-structured prompt · agent task schema
pattern · enforced via Pydantic at agent boundary
// agents/housing_etl.json
{
  "task": "housing_etl_ingest",
  "context": {
    "sources": ["zillow_api", "fred_api"],
    "target": "postgresql.housing_timeseries",
    "schedule": "celery-beat nightly 02:00 UTC"
  },
  "output_format": {
    "type": "pandas_dataframe → db_upsert",
    "validate": ["no_nulls", "date_range_check"]
  },
  "constraints": ["idempotent", "redis_cache_1h"],
  "budget": { "tokens": 8000, "retries": 2 }
}

Every agent task is wrapped in this structure instead of free-text instructions. 'context' tells the agent exactly what it's working with. 'output_format' tells it what to produce and how to validate it. 'budget' hard-caps token and retry spend — without it, a misbehaving agent can run indefinitely and rack up cost.

Agent task ledger · last 24h
agent-log topic · last 24h
98.4% success
TimeAgentTaskTokensStatus
14:42clauderefactor.candle_renderer4,218ok
14:21codextest.gen.orderbook_ws2,104ok
13:58claudeadr.draft.0186,884ok
13:32codexmigration.diff.user_acl1,948ok
12:14claudereview.pr.8428,012ok
11:48codexboilerplate.celery_task1,204ok
11:01clauderefactor.lstm_pipeline9,640retry
10:34codextest.gen.fred_client1,812ok

Token count is cost — 8,000 tokens for a code review is normal; watch for tasks that balloon past 10K without producing output. The retry on the LSTM refactor means the agent hit a validation error on its first attempt and re-ran with the error injected as context — a feature, not a bug.

Operating tactics
how the agents are deployed in practice
01Context discipline

RAG-first, not chat-first

Every prompt is hydrated from the knowledge graph before it reaches a model. No "remember earlier?" — the context is rebuilt deterministically each call.

02Schema enforcement

Output as data, not prose

Models emit JSON matching a Pydantic schema. Anything unparseable is auto-retried with the validation error injected as next-turn context.

03Pipeline chaining

Agents are Celery tasks

Each agent invocation is a Celery task with idempotency keys. Failures retry with exponential backoff; outputs are checkpointed in Postgres.

04Budget & guardrails

Token caps per task

Every agent task declares a token budget and a retry budget. Overruns hard-fail and bubble to the alerting channel rather than silently degrading.

05Eval as first-class

Golden set + nightly diff

A frozen set of prompts re-runs nightly. Output diffs against last week's flag regression before any model upgrade ships to PROD.

06Human-in-the-loop

PRs, not commits

Agents never push to main. They open PRs with provenance metadata; CI runs the same gates as human PRs before reviewer sign-off.

The six principles that prevent the agent pipeline from going off the rails. RAG-first prevents guessing. Schema enforcement means outputs are always machine-parseable. Celery tasks means agents are resumable and observable. Budget caps prevent runaway spend. Eval sets catch regressions before model upgrades ship. PRs not commits keeps a human in the loop.