惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

爱范儿
爱范儿
WordPress大学
WordPress大学
C
Check Point Blog
GbyAI
GbyAI
U
Unit 42
Google DeepMind News
Google DeepMind News
B
Blog RSS Feed
Blog — PlanetScale
Blog — PlanetScale
J
Java Code Geeks
I
InfoQ
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Hugging Face - Blog
Hugging Face - Blog
Vercel News
Vercel News
博客园 - 【当耐特】
美团技术团队
小众软件
小众软件
S
SegmentFault 最新的问题
Jina AI
Jina AI
阮一峰的网络日志
阮一峰的网络日志
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
The Cloudflare Blog
Last Week in AI
Last Week in AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
Visual Studio Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
How I cut my multi-turn LLM API costs by 90% (O(N ) O(N))
Rudekwydra · 2026-05-05 · via DEV Community

Rudekwydra

How I cut my multi-turn LLM API costs by 90% (O(N²) → O(N))

If you build multi-turn AI agents, you know the pain: API costs don't grow linearly, they grow quadratically.

Every turn in a standard agent loop replays the full conversation history. Token cost on turn N is proportional to N, so total cost across N turns is Θ(N²). I hit a wall where a single heavy day of coding consumed 97% of my weekly Anthropic quota.

So I built Burnless — an open protocol and orchestration layer that flips the cost curve from O(N²) to O(N).

The result: It cut my real-world API consumption by ~16x, and benchmarks at 90.3% cheaper against naive Claude Opus.

GitHub logo Rudekwydra / burnless

Multi-turn agent loops cost O(N²). Burnless makes them O(N). 88% cheaper at turn 10. MIT, provider-agnostic.

Burnless

Intent-compressed intelligence orchestration.

A maestro that orchestrates any LLM from any vendor. Multi-turn agent loops cost O(N²) — Burnless makes them O(N).

Burnless is a vendor-agnostic orchestration layer for multi-agent workflows. You pick the model that conducts the orchestra (Maestro / Brain) — Claude, GPT, Gemini, Mistral, a local Llama, anything — and the models that execute each task (Workers). Tiers are quality/cost bands, not vendors: gold/silver/bronze map to whatever CLI you put in config.yaml. Mix providers freely. Run encoder and decoder on a local Ollama model for zero marginal cost on the cheap stages.

On top of that independence, Burnless flips the cost curve. Every turn in a standalone agent loop replays the full conversation as input — token cost on turn N is proportional to N, so total cost across N turns is Θ(N²). Burnless keeps only short capsules in…

How it works

The math relies on two specific mechanisms working together:

  1. Shared Prefix Cache: The persistent system prompt (which can be 20k+ tokens) is cached using Anthropic's prompt caching (ttl: 1h). Switching models from the same provider mid-session does not invalidate this cache if the prefix is byte-identical.
  2. Capsule History: Instead of keeping raw transcripts in the agent's memory, the "Maestro" model only holds ~80-character compressed "capsules" of prior turns.

The result is that your quadratic history term collapses into a tiny linear one, while the massive system prompt is billed at cache-read prices (which is roughly 10x cheaper than fresh input on Anthropic).

The Benchmark (No Mocks)

If you want the formal derivation, I published a reproducible benchmark that uses the Anthropic SDK directly and reads raw response.usage.

Against Claude 3 Opus on a 10-turn session:

  • Standalone (no cache): $4.66
  • Standalone (+ cache): $0.65
  • Burnless Maestro: $0.45 (-90.3%)

And this math applies to any provider that exposes prompt caching and charges per input token.

Vendor Agnostic Orchestration

Burnless isn't a wrapper for a single API. Tiers are quality/cost bands, not vendors. You can mix and match any CLI you already have installed:

agents:
  gold:    { command: "claude --model claude-sonnet-4-6 -p" } # The Brain
  silver:  { command: "codex exec --sandbox workspace-write" } # Execution
  bronze:  { command: "ollama run qwen2.5-coder" } # Local, zero marginal cost

Enter fullscreen mode Exit fullscreen mode

The CLI works today. If you're building agents and burning through tokens, give it a try:

pip install burnless
burnless setup

Enter fullscreen mode Exit fullscreen mode

Would love to hear your thoughts on the architecture, especially if you're working on local encoding/decoding for privacy!