Hmbown/CodeWhale · error · anyhow::Error

metric(s) regressed past the % threshold

Error message

{} metric(s) regressed past the {:.1}% threshold

What it means

The offline score/regression command compares a run's token/cache/cost metrics against a committed baseline and bails when one or more metrics regressed by more than the user-supplied threshold percentage. The message reports the count of regressed metrics and the threshold used.

Solutions

  1. Read the printed regression list to see which metrics and by how much they moved
  2. If the change is intentional, regenerate/commit a new baseline file
  3. Loosen --threshold if ordinary run-to-run variance is being flagged
  4. Fix the prompt/context change that caused the regression

Example fix

// before
// codewhale score --baseline baseline.json --threshold 1.0  // fails
// after: allow realistic variance or refresh the baseline
// codewhale score --baseline baseline.json --threshold 5.0
// or re-record an intentional baseline
Defensive patterns

Strategy: validation

Validate before calling

let regressions = compare_to_baseline(&metrics, &baseline, threshold);
if !regressions.is_empty() {
    eprintln!("regressed: {regressions:?}");
    std::process::exit(1);
}

Prevention

When it happens

Trigger: Running the score command where regressions is non-empty: at least one metric (tokens, cache hit rate, cost) got worse by more than args.threshold percent versus the baseline JSON.

Common situations: A prompt or context change inflated token usage; cache behavior regressed after a prompt-prefix change; a too-tight --threshold value flags ordinary variance in CI.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/43f08ae26af880d8. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/lib.rs:3185

            "per_turn": card.per_turn,
            "metrics": card.metrics,
            "regressions": regressions,
        });
        println!("{}", serde_json::to_string_pretty(&out)?);
    } else {
        print!("{}", card.to_summary());
        for r in &regressions {
            println!(
                "REGRESSION {}: baseline {:.4} -> current {:.4} (+{:.1}%)",
                r.metric, r.baseline, r.current, r.pct_increase
            );
        }
    }

    if regressions.is_empty() {
        Ok(())
    } else {
        bail!(
            "{} metric(s) regressed past the {:.1}% threshold",
            regressions.len(),
            args.threshold
        )
    }
}

async fn run_fleet_command(workspace: &Path, config: &Config, args: FleetArgs) -> Result<()> {
    use crate::fleet::alerts::{
        FleetAlertAdapterConfig, FleetAlertConfig, FleetAlertDispatcher, FleetAlertEvent,
        FleetEnvSecretResolver,
    };
    use crate::fleet::control as fleet_control;
    use crate::fleet::executor::FleetExecutor;
    use crate::fleet::manager::{FleetManager, FleetStatusSnapshot, FleetWorkerInspection};
    use codewhale_lane::{ControlOperation, ControlSurface};
    use codewhale_protocol::fleet::{FleetAlertEventClass, FleetArtifactKind, FleetRunId};

View on GitHub (pinned to 73e0f67d83)