Skip to content

[Phase 5] Engine Performance Tracking and Comparison #419

Description

@frankbria

Summary

Track per-engine success rates, token usage, duration, and gate pass rates so users can make informed decisions about which execution engine works best for their project. A lightweight version of Gastown's agent CV system — no permanent identity, no skill routing, just metrics.

Motivation

With #408 (Agent Adapter Architecture), CodeFrame will support multiple engines (Claude Code, Codex, OpenCode, built-in, etc.). The natural question becomes: "Which engine works best for my Python project?" or "Is Claude Code worth the cost vs the built-in agent?"

Gastown tracks full agent CVs with work history, skill demonstration, and quality metrics. That's overkill for CodeFrame's single-developer audience. But basic performance tracking per engine is genuinely useful and trivially implementable since CodeFrame already tracks run outcomes.

Design (single session)

Data to track (per engine, per workspace)

Metric Source Description
tasks_attempted runtime Total tasks started with this engine
tasks_completed runtime Tasks that reached DONE
tasks_failed runtime Tasks that reached FAILED
gate_pass_rate gates % of runs where gates passed on first try
self_correction_rate verification loop % of runs needing self-correction retries
avg_duration_ms runtime Average execution time per task
total_tokens adapter result Total token usage
avg_tokens_per_task computed Tokens / completed tasks

Storage

Add an engine_stats table to the existing SQLite database:

CREATE TABLE engine_stats (
    workspace_id TEXT,
    engine TEXT,
    metric TEXT,
    value REAL,
    updated_at TEXT,
    PRIMARY KEY (workspace_id, engine, metric)
);

Plus a run_engine_log table for per-run detail:

CREATE TABLE run_engine_log (
    run_id TEXT PRIMARY KEY,
    engine TEXT,
    task_id TEXT,
    status TEXT,       -- COMPLETED, FAILED, BLOCKED
    duration_ms INT,
    tokens_used INT,
    gates_passed BOOLEAN,
    self_corrections INT,
    created_at TEXT
);

New CLI commands

cf engines stats                    # Show engine performance comparison
cf engines stats --engine claude-code  # Stats for one engine
cf engines compare                  # Side-by-side comparison table

Example output:

Engine Performance (my-project)
┌──────────────┬──────────┬──────────┬───────────┬──────────────┬─────────────┐
│ Engine       │ Tasks    │ Success  │ Gate Pass │ Avg Duration │ Avg Tokens  │
├──────────────┼──────────┼──────────┼───────────┼──────────────┼─────────────┤
│ claude-code  │ 12       │ 92%      │ 75%       │ 45s          │ 8,200       │
│ built-in     │ 8        │ 75%      │ 50%       │ 120s         │ 15,400      │
│ opencode     │ 3        │ 100%     │ 67%       │ 60s          │ 10,100      │
└──────────────┴──────────┴──────────┴───────────┴──────────────┴─────────────┘

Integration points

Acceptance Criteria

  • Run outcomes recorded with engine name in SQLite
  • cf engines stats shows per-engine performance summary
  • cf engines compare shows side-by-side table
  • Token usage tracked (when adapter reports it)
  • Gate pass rate tracked
  • Self-correction count tracked
  • Stats accumulate across sessions (persistent)
  • Works with all registered engines

Dependencies

Complexity Note

This is deliberately simpler than Gastown's agent CV system:

  • No permanent agent identity (engines don't have names like "Toast")
  • No skill routing (we don't auto-select engines based on history)
  • No cross-project tracking (stats are per-workspace)
  • No audit trails or compliance features
  • Just: "which engine works best here?"

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestphase-5Phase 5: Advanced Features & Polishphase-5.1Phase 5.1: Foundation & Observability (token tracking, engine perf, task gen)quality

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions