Skip to main content
cascadeflow ships two complementary engines that can be used independently or together.

Cascade Engine

The Cascade Engine optimizes model selection through speculative execution with quality validation:
  1. Speculatively executes small, fast models first — optimistic execution ($0.15-0.30/1M tokens)
  2. Validates quality of responses using configurable thresholds (completeness, confidence, correctness)
  3. Dynamically escalates to larger models only when quality validation fails ($1.25-3.00/1M tokens)
  4. Learns patterns to optimize future cascading decisions and domain-specific routing
In practice, 60-70% of queries are handled by small, efficient models without escalation. Result: 40-85% cost reduction, 2-10x faster responses, zero quality loss.

Harness Engine

The Harness Engine provides agent runtime intelligence — budget enforcement, compliance gating, KPI-weighted routing, energy tracking, and decision traces. Unlike the Cascade Engine which routes between models, the Harness Engine wraps existing agent execution and makes decisions at every step:

Decision Flow

For each LLM call or tool execution inside an agent loop, the harness:
  1. Records the model, step number, and cumulative metrics
  2. Evaluates all configured constraints (budget, compliance, tool calls, latency, energy)
  3. Scores the call against KPI weights if configured
  4. Decides an action: allow, switch_model, deny_tool, or stop
  5. Enforces the action if in enforce mode (logs only in observe mode)
  6. Appends a trace record for auditability

HarnessConfig

All harness behavior is configured through a single dataclass:

Combined Usage

When both engines are active, the Cascade Engine handles model selection while the Harness Engine enforces constraints:

Provider Abstraction

cascadeflow supports 17+ providers through a unified interface: