cascadeflow
llms.txt4k starsChanged 13 months agoMITView on GitHub
Agent runtime intelligence layer for AI agent workflows. In-process harness (not a proxy). Works inside agent loops with full state awareness. pip install cascadeflow import cascadeflow cascadeflow.init(mode="observe") # All openai/anthropic SDK calls are now tracked. Switch to "enforce" for budget gating. cascadeflow is an in-process intelligence layer that sits inside AI agent execution loops. Unlike external proxies that only see HTTP request boundaries, cascadeflow operates with full agent state awareness: step count, budget consumed, tool call history, error context, quality…
- Installs packages
Trending
Quiet since September.thin dataabout the whole repository
Who's talking about lemony-ai/cascadeflow
- A Hacker News story“Open-source LLM cascading, up to 92% cost savings on benchmarks”Hacker News · Dec 16, 2025 · 12 points
- @sascha.buehrle.io“Day 1 of our release sprint 🚀 CascadeFlow shipped, open source AI cascading that cuts costs 30-65% in 3 …”Bluesky · Nov 6, 2025 · 10 likes
- @sascha.buehrle.io“Excited to launch cascadeflow on @github.com! Smart AI model cascading that cuts your AI costs by 30-65% in …”Bluesky · Nov 6, 2025 · 5 likes
- @sascha.buehrle.io“Day 2 of release sprint 🎯 n8n integration is live on github! cascadeflow now plugs into your workflows. …”Bluesky · Nov 7, 2025 · 3 likes
- A Hacker News story“Cascadeflow: Cut AI API costs 40-85% with speculative model cascading”Hacker News · Nov 6, 2025 · 3 points
The biggest 5 of 13 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 13
Talked about on Bluesky, Hacker News and GitHub (13 times).
On Bluesky · 7
- Nov 6, 2025Day 1 of our release sprint 🚀 CascadeFlow shipped, open source AI cascading that cuts costs 30-65% in 3 lines of code. Small models handle… — @sascha.buehrle.iosays it tested it10 likes and reposts
- Nov 6, 2025Excited to launch cascadeflow on @github.com! Smart AI model cascading that cuts your AI costs by 30-65% in just 3 lines of code. How small… — @sascha.buehrle.iosays it tested it5 likes and reposts
- Nov 7, 2025Day 2 of release sprint 🎯 n8n integration is live on github! cascadeflow now plugs into your workflows. Connect 2 models (cheap drafter +… — @sascha.buehrle.io3 likes and reposts
- Dec 8, 2025Two years of working with SLMs led me to one question: what happens when you route to MANY domain specialists instead of one giant model?… — @sascha.buehrle.io2 likes and reposts
- Nov 20, 2025Building LangChain agents? Here's the cost problem nobody talks about: 40-70% of agent tool calls don't need expensive flagship models. A… — @sascha.buehrle.io1 likes and repost
2 more on Bluesky
- Nov 12, 2025Release Day 6 🤖 cascadeflow for Agents Tool calls multiply costs. 49% cite ROI as #1 adoption barrier. cascadeflow's drafter/verifier… — @sascha.buehrle.io1 likes and repost
- Nov 11, 2025Release Day 5 🔌 cascadeflow for edge devices Where it all started. Run AI on performance-limited hardware: - Fully local: vLLM/Ollama… — @sascha.buehrle.io1 likes and repost
On Hacker News · 4
- Dec 16, 2025Open-source LLM cascading, up to 92% cost savings on benchmarkssays it tested it12 points · 9 comments
- Nov 6, 2025Cascadeflow: Cut AI API costs 40-85% with speculative model cascadingsays it tested it3 points
- Nov 22, 2025LangChain Cost Optimization with Model Cascading1 point · 2 comments
- Nov 7, 2025N8n community node – cascadeflow, Reduce AI costs 30-65% with model cascadingsays it tested it1 point · 1 comment
On GitHub · 2
- Sep 29, 2026agent-skills.github.lemony-ai.cascadeflow: init at 1.2.0 — sudosubin/agents.nix0 reactions
- Mar 10, 2026Research "speculative execution with quality validation" — agent-fox-dev/agent-fox-legacy0 reactions · 2 comments
In this repositoryOne other file it gives its agents.
- cascadeflowSkill
The file
We split this llms.txt into the rules it gives an agent
2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 118
stop: halt agent loop when budget/latency/energy cap exceeded
- Distinctive: line 150
All integrations are opt-in.
≈ “Common” is an estimate: at least 1 in 5 of the 1,484 llms.txt files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
# cascadeflow
> Agent runtime intelligence layer for AI agent workflows.
> In-process harness (not a proxy). Works inside agent loops with full state awareness.
## Install
pip install cascadeflow
## Quickstart (3 lines)
import cascadeflow
cascadeflow.init(mode="observe")
# All openai/anthropic SDK calls are now tracked. Switch to "enforce" for budget gating.
## What cascadeflow is
cascadeflow is an in-process intelligence layer that sits inside AI agent execution
loops. Unlike external proxies that only see HTTP request boundaries, cascadeflow
operates with full agent state awareness: step count, budget consumed, tool call
history, error context, quality scores, domain, complexity, and user-defined
business context.
Eight things make cascadeflow different:
1. Inside-the-loop control. Decisions happen per-step and per-tool-call inside
agent execution, not at the HTTP boundary. This enables budget gating mid-run,
model switching based on remaining budget, and stop actions when caps are hit.
2. Multi-dimensional optimization. Six dimensions scored simultaneously: cost,
latency, quality, budget, compliance, and energy. Not just cost routing.
3. Business logic injection. KPI weights and targets let teams encode business
priorities (e.g. 60% quality, 30% cost, 10% latency) into every model decision.
4. Actionable decisions. Four actions: allow, switch_model, deny_tool, stop.
The harness does not just observe — it controls execution flow.
5. Full transparency. Every decision produces a trace record with action, reason,
model, step, cost_total, budget_state, and applied fields. Audit-ready.
6. Measurable value. Session summaries report cost, latency, energy, steps,
tool calls, and budget remaining. Before/after comparison is built in.
7. Category leadership. Cross-framework policy layer with unified KPI semantics
across LangChain, OpenAI Agents SDK, CrewAI, Google ADK, n8n, Vercel AI SDK.
8. Latency advantage. In-process instrumentation adds <1ms overhead per call.
External proxies add 10-50ms of network round-trip latency per LLM call.
## When to use cascadeflow
- You run AI agents (LangChain, LangGraph, CrewAI, OpenAI Agents SDK, Google ADK, or custom)
- You want to reduce LLM costs without changing agent code
- You need budget enforcement across multi-step agent runs
- You need to inject business KPIs (quality, cost, latency, energy) into agent decisions
- You need compliance-aware model gating (GDPR, HIPAA, PCI, strict)
- You want full trace recording for auditability and tuning
## When NOT to use cascadeflow
- Single one-off LLM calls (overhead not justified)
- You only use one model and don't want routing
- You need a hosted proxy service (cascadeflow is a library, not a SaaS)
## Proxy vs cascadeflow
| Dimension | External proxy | cascadeflow harness |
|--------------------|----------------------------|------------------------------|
| Scope | HTTP request boundary | Inside agent execution loop |
| Dimensions | Cost only | Cost + quality + latency + budget + compliance + energy |
| Latency overhead | 10-50ms network RTT | <1ms in-process |
| Business logic | None | KPI weights and targets |
| Enforcement | None (observe only) | stop, deny_tool, switch_model |
| Auditability | Request logs | Per-step decision traces |
## Key APIs
- cascadeflow.init(mode) -- activate harness globally (off | observe | enforce)
- cascadeflow.run(budget, max_tool_calls) -- scoped agent run with budget/limits
- @cascadeflow.agent(budget, kpis) -- annotate agent functions with policy metadata
- session.summary() -- structured run metrics (cost, latency, energy, steps, tool calls)
- session.trace() -- full decision trace for auditability
## HarnessConfig Reference
@dataclass
class HarnessConfig:
mode: HarnessMode # "off" | "observe" | "enforce". Default: "off"
verbose: bool # Print decisions to stderr. Default: False
budget: Optional[float] # Max USD for the run. Default: None (unlimited)
max_tool_calls: Optional[int] # Max tool/function calls. Default: None
max_latency_ms: Optional[float] # Max wall-clock ms per call. Default: None
max_energy: Optional[float] # Max energy units. Default: None
kpi_targets: Optional[dict] # {"quality": 0.9, "cost": 0.5, ...}
kpi_weights: Optional[dict] # {"quality": 0.6, "cost": 0.3, "latency": 0.1}
compliance: Optional[str] # "gdpr" | "hipaa" | "pci" | "strict"
## Harness Modes
- off: no tracking, no enforcement
- observe: track all metrics and decisions, never block execution (safe for production rollout)
- enforce: track + enforce budget/tool/latency/energy caps (stop or deny_tool actions)
## Harness Dimensions
- Cost: estimated USD from model pricing table (18 models, fuzzy resolution)
- Latency: wall-clock milliseconds per LLM call
- Energy: deterministic compute-intensity proxy coefficient
- Tool calls: count of tool/function calls executed
- Quality: model quality priors for KPI-weighted scoring
## Decision Actions
- allow: proceed normally
- switch_model: route to cheaper/better model (where runtime allows)
- deny_tool: block tool execution when tool call cap reached
- stop: halt agent loop when budget/latency/energy cap exceeded
## Decision Trace Format
Each decision produces a record with these fields:
- action: "allow" | "switch_model" | "deny_tool" | "stop"
- reason: human-readable explanation
- model: model name used for the call
- step: integer step number in the run
- cost_total: cumulative cost in USD at this step
- budget_state: "ok" | "warning" | "exceeded"
- applied: true if the action was enforced (false in observe mode)
## Compliance Model Allowlists
- gdpr: gpt-4o, gpt-4o-mini, gpt-3.5-turbo
- hipaa: gpt-4o, gpt-4o-mini
- pci: gpt-4o-mini, gpt-3.5-turbo
- strict: gpt-4o only
## Integrations
pip install cascadeflow[langchain] # LangChain/LangGraph callback handler
pip install cascadeflow[openai-agents] # OpenAI Agents SDK ModelProvider
pip install cascadeflow[crewai] # CrewAI llm_hooks integration
pip install cascadeflow[google-adk] # Google ADK BasePlugin
npm install @cascadeflow/core # TypeScript core
npm install @cascadeflow/langchain # LangChain TypeScript
npm install @cascadeflow/vercel-ai # Vercel AI SDK middleware
npm install @cascadeflow/n8n-nodes-cascadeflow # n8n community node
All integrations are opt-in. Install the extra and explicitly enable the integration.
## Integration Code Snippets
LangChain:
from cascadeflow.integrations.langchain import get_harness_callback
cb = get_harness_callback()
result = await model.ainvoke("query", config={"callbacks": [cb]})
OpenAI Agents SDK:
from cascadeflow.integrations.openai_agents import CascadeFlowModelProvider
provider = CascadeFlowModelProvider(model_candidates=["gpt-4o-mini", "gpt-4o"])
CrewAI:
from cascadeflow.integrations.crewai import enable
enable(budget_gate=True, fail_open=True)
Google ADK:
from cascadeflow.integrations.google_adk import enable
plugin = enable(fail_open=True)
runner = Runner(agent=agent, plugins=[plugin])
## Pricing Table (USD per 1M tokens: input / output)
OpenAI:
gpt-4o: $2.50 / $10.00
gpt-4o-mini: $0.15 / $0.60
gpt-5: $1.25 / $10.00
gpt-5-mini: $0.20 / $0.80
gpt-4-turbo: $10.00 / $30.00
gpt-4: $30.00 / $60.00
gpt-3.5-turbo: $0.50 / $1.50
o1: $15.00 / $60.00
o1-mini: $3.00 / $12.00
o3-mini: $1.10 / $4.40
Anthropic:
claude-sonnet-4: $3.00 / $15.00
claude-haiku-3.5: $1.00 / $5.00
claude-opus-4.5: $5.00 / $25.00
Google:
gemini-2.5-flash: $0.15 / $0.60
gemini-2.5-pro: $1.25 / $10.00
gemini-2.0-flash: $0.10 / $0.40
gemini-1.5-flash: $0.075 / $0.30
gemini-1.5-pro: $1.25 / $5.00
## Energy Coefficients
Model energy is computed as: energy_units = coeff * (input_tokens + output_tokens * 1.5)
gpt-4o: 1.0 gpt-4o-mini: 0.3 gpt-5: 1.2
gpt-5-mini: 0.35 gpt-4-turbo: 1.5 gpt-4: 1.5
gpt-3.5-turbo: 0.2 o1: 2.0 o1-mini: 0.8
o3-mini: 0.5 claude-sonnet-4: 1.0 claude-haiku-3.5: 0.3
claude-opus-4.5: 1.8 gemini-2.5-flash: 0.3 gemini-2.5-pro: 1.2
gemini-2.0-flash: 0.25 gemini-1.5-flash: 0.2 gemini-1.5-pro: 1.0
## Links
- Docs: https://docs.cascadeflow.dev
- Source: https://github.com/lemony-ai/cascadeflow
- PyPI: pip install cascadeflow
- npm: npm install @cascadeflow/core
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

