Skip to content

Latest commit

 

History

History
184 lines (132 loc) · 7.43 KB

DIY.md

File metadata and controls

184 lines (132 loc) · 7.43 KB

Try It Yourself — Patient Risk Calculator

This guide walks you through the IDD demo hands-on. You will run Phase A (baseline, clarification-heavy) and Phase B (IDD pipeline), then compare the results.


What You're Exploring

The same prompt — Build me a patient risk calculator. — drives both phases. The only difference is what context the engine has when it receives it.

  • Phase A: no engineering context. The engine must ask clarifying questions to resolve intent.
  • Phase B: skills/idd-pipeline/ loaded. The engine extracts structured intent and generates architecture, code, and a measurement report in one pass.

The ICR (Intent Compression Ratio) and token amplification numbers make the gap measurable.


Prerequisites

  • This repository cloned locally
  • One AI engine available: Codex, Claude Code, Cortex Code, or Opencode
  • For local simulation: uv sync and task api (starts the ICR lab API on localhost:8080)
  • For browser simulation: https://icr-lab.streamlit.app (no setup needed)

Step 1: See Phase A — Clarification Heavy

Phase A evidence is deterministic — you do not run the vague prompt through a live agent. Instead you call the ICR lab simulation, which returns the canonical token counts, interaction rounds, and requirements coverage for Clarification Heavy mode.

Option A: Use the live ICR Lab app (no local setup needed)

  1. Open https://icr-lab.streamlit.app
  2. In the Task field enter:
    Build me a patient risk calculator.
    
    (The trailing period is required for catalog lookup.)
  3. Select Clarification Heavy, Assumption Led, and Intent Optimized modes.
  4. Set Assumption Accuracy to 0.85 (strong model, industry standard).
  5. Click Run Simulation.
  6. Note the token counts, interaction rounds, ICR, wrong assumptions, and requirements coverage.

Option B: Run the local simulation API

task api          # starts ICR lab on localhost:8080

Then send the canonical request:

curl -s -X POST http://localhost:8080/simulate \
  -H "Content-Type: application/json" \
  -d @demo-workflows/phase-a-request.json | jq .

Save the response — you will use it as the Phase A baseline in Step 3:

mkdir -p generated/reports
curl -s -X POST http://localhost:8080/simulate \
  -H "Content-Type: application/json" \
  -d @demo-workflows/phase-a-request.json \
  > generated/reports/phase-a-simulation.json

Key numbers to note from token_metrics["Clarification Heavy"]:

Metric Meaning
total_tokens Tokens consumed across all clarification rounds
interaction_rounds How many back-and-forth exchanges were needed
icr Intent Compression Ratio — 0.0 means zero operations achieved
token_amplification Overhead multiplier vs Intent Optimized baseline

Step 2: Run Phase B — IDD Pipeline

2a. Open your engine

Start Codex, Claude Code, Cortex Code, or Opencode in the repository root.

2b. Load the IDD skill

Load the skill context for your engine:

Engine Context to load
Cortex Code $idd-pipeline or load skills/idd-pipeline/SKILL.md
Claude Code Load skills/idd-pipeline/idd-foundation.md → skills/idd-pipeline/SKILL.md → skills/idd-pipeline/adapters/claude/adapter.md
Codex Load skills/idd-pipeline/idd-foundation.md → skills/idd-pipeline/SKILL.md → skills/idd-pipeline/adapters/codex/adapter.md

2c. Send the same vague prompt

Build me a patient risk calculator.

With the IDD skill loaded, the engine will:

  1. Extract structured intent — resolves the four requirements from the vague prompt
  2. Synthesize architecture — produces a component diagram in generated/architecture/
  3. Generate code — writes the Streamlit app to generated/code/
  4. Run ICR analysis — compares Phase A baseline against the optimized prompt tokens
  5. Compute token economics — saves savings hypothesis to generated/reports/

You should see all four requirements met in a single interaction round.


Step 3: Compare the Results

After Phase B completes, compare all three simulation modes:

Metric Clarification Heavy Assumption Led (0.85) Intent Optimized
Interaction rounds 6 3 1
Requirements met 0 / 4 4 / 4 4 / 4
Total tokens 5,246 4,273 2,090
ICR 0.0 0.489 1.0 (best)
Token amplification 2.51× 2.04× 1.0× (baseline)
Est. cost $0.156 $0.127 $0.060
Wrong assumptions 0 1 0

Key insight: Assumption Led at 85% accuracy still costs 2× more than Intent Optimized and required 2 extra correction rounds. Even a strong model pays a penalty for guessing.

What the requirements look like when met

The IDD pipeline extracts and delivers all four requirements from the vague prompt:

  1. Input form: age, prior admissions count, department (select), primary diagnosis code
  2. Weighted risk score: (prior_admissions × 0.4) + (age_factor × 0.3) + (diagnosis_factor × 0.3)
  3. Color-coded badge: HIGH (score ≥ 0.7), MEDIUM (0.4–0.69), LOW (< 0.4)
  4. Per-factor formula breakdown below the badge — each factor labeled with its weight

The vague prompt carries none of these in its ~7 tokens. The compressed intent carries all four in ~60 tokens. ICR = (operations_achieved / total_tokens) × 1000 — the pipeline closes that gap.


Simulation Modes Reference

The ICR lab simulation covers six modes:

Mode Description Interaction rounds Natural completion
Verbose Prompting Lengthy, redundant context; over-specified 2 100%
Clarification Heavy Vague prompt, no skill — stalls before execution 5–8 0%
Context Aware Structured context, minimal redundancy 3 100%
Intent Optimized Compressed, precise intent + skill 1 100%
Over Compressed Too terse; model misinterprets, retries needed 5 50%
Assumption Led Model proceeds on guesses, corrects wrong ones 1–4 100%

assumption_accuracy (float 0.0–1.0, default 1.0) controls Assumption Led only. At 1.0 all assumptions are correct (1 round). Below 1.0 the engine adds correction rounds and degrades requirements coverage deterministically — lower accuracy models produce more rounds and higher cost. The demo uses 0.85 (strong model, industry standard) to show that even accurate models pay a correction-round penalty — Assumption Led becomes 3 rounds, $0.127 vs $0.060 for Intent Optimized (2.12× the cost), with 1 wrong assumption requiring correction before the right answer is reached.

This demo contrasts Clarification Heavy (Phase A) with Intent Optimized (Phase B). Assumption Led at 0.85 sits in between — it gets the right answer but only after wasting tokens on wrong-assumption correction.


See Also