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

推荐订阅源

cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
小众软件
小众软件
博客园_首页
博客园 - 聂微东
V
V2EX
WordPress大学
WordPress大学
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
罗磊的独立博客
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 司徒正美
博客园 - 三生石上(FineUI控件)
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
S
SegmentFault 最新的问题
J
Java Code Geeks
Last Week in AI
Last Week in AI
The Cloudflare Blog
月光博客
月光博客
雷峰网
雷峰网
宝玉的分享
宝玉的分享
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Hugging Face - Blog
Hugging Face - Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
有赞技术团队
有赞技术团队
人人都是产品经理
人人都是产品经理
博客园 - Franky
腾讯CDC
Jina AI
Jina AI
博客园 - 叶小钗
大猫的无限游戏
大猫的无限游戏
阮一峰的网络日志
阮一峰的网络日志
量子位
爱范儿
爱范儿
美团技术团队
T
Tailwind CSS Blog
博客园 - 【当耐特】
D
Docker
IT之家
IT之家
V
Visual Studio Blog
P
Proofpoint News Feed
L
LangChain Blog
Engineering at Meta
Engineering at Meta
C
Check Point Blog
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
云风的 BLOG
云风的 BLOG
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Microsoft Azure Blog
Microsoft Azure Blog
B
Blog RSS Feed
Recorded Future
Recorded Future

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 Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
BAGEN: LLM Agents Waste 44% of Tokens on Tasks They'll Fail
Jangwook Kim · 2026-06-05 · via DEV Community

You're paying for every token your agent burns. And according to new research from Northwestern, Stanford, Cornell, and All Hands AI, a large share of that spend goes directly to waste — on trajectories the agent was never going to complete successfully.

The paper is BAGEN: Are LLM Agents Budget-Aware? (arXiv:2606.00198, submitted May 29, 2026). Its core question is simple: can frontier LLM agents predict when they're about to run out of runway? The answer, across five frontier models and four environments, is a firm no.

This article covers what BAGEN found, how the concept of budget-aware interval estimation works, and includes an Effloow Lab PoC that reproduces the key dynamics using Python stdlib — no API keys, no GPU.

Why This Matters for Production Agent Systems

Token budgets are a real constraint in every deployed agent system. You set a max_tokens limit, you watch the cost dashboard, and you assume the agent will either finish the task or hit the hard wall. What BAGEN documents is a third case that developers rarely account for: the agent continues consuming tokens on a task it cannot complete, all the way to the limit.

The mechanism is predictable. Unsolvable tasks tend to produce backtracking behavior — more tool calls per step, increasing per-step token costs, no convergence signal. A budget-aware agent should detect that pattern early and stop (or alert a human). Frontier models, as BAGEN shows, don't.

The practical consequence:

  • Failed tasks consume the same (or more) tokens as successful ones
  • You pay for the full trajectory even when step 2 already signals doom
  • At scale, this becomes a significant line item in your inference budget

BAGEN's headline number: early stopping on failed trajectories saves 28–64% of tokens versus running to completion. That's not a micro-optimization. That's a structural cost reduction available to any developer who builds the right wrapper.

What Budget-Awareness Actually Means

BAGEN distinguishes two budget types that agents encounter in practice:

Internal budgets come from agent computation itself — how many tokens the agent is burning. The environments used here include:

  • Sokoban: A puzzle-solving benchmark where agents must push boxes onto targets. Token consumption per step signals whether the agent is making progress or backtracking.
  • Search-R1: A search-and-retrieval environment where steps involve tool calls against a retrieval index.
  • SWE-bench: Software engineering tasks requiring multi-file code modifications and test verification.

External budgets come from the downstream effects of agent actions:

  • Supply-chain environment (curated from real enterprise data): agents manage cost, time, and warehouse occupancy simultaneously. Overspending on warehouse space is the external budget; token consumption is the internal one.

This two-axis framing is useful because many developers think only about token cost (internal) and ignore external resource consumption (money spent via tool calls, API charges from agent actions, storage consumed). BAGEN shows agents are over-optimistic on both dimensions.

The Three Sub-Capabilities BAGEN Measures

Budget-awareness in BAGEN decomposes into three measurable abilities:

1. Feasibility Prediction

Can the agent correctly estimate whether a task is solvable before starting it? At step zero, before any action is taken, can the model predict whether the trajectory will succeed or fail within budget?

Current frontier models perform poorly here. They tend to rate most tasks as feasible, regardless of how complex or resource-intensive the prompt suggests the task will be.

2. Early Failure Detection

As the agent proceeds through a task, can it detect failure signals and trigger an alert or stop? This is where the 28–64% savings come from. An agent that detects a doomed trajectory at step 3 of a 15-step rollout recovers most of that budget.

The evaluation methodology BAGEN uses is a rollout-replay protocol: the paper first collects unconstrained rollouts (agents run to completion with no budget pressure), then re-queries each agent on every prefix of that rollout, asking for a budget estimate and feasibility prediction at each intermediate step. This separates the estimation capability from the actual task performance.

3. Interval Calibration

Rather than asking for a point estimate ("I need X more tokens"), BAGEN asks for an interval: a lower and upper bound. An agent that says "I'll need between 800 and 1,200 tokens to finish" is far more useful than one that guesses a single number.

Interval coverage — the fraction of cases where the true token count falls within the predicted interval — caps at 47% after SFT+RL fine-tuning on the best-performing setup. That's low. It means well over half the time, the predicted interval misses the actual consumption. The interval estimation problem is genuinely hard, even for fine-tuned models.

The Over-Optimism Problem: What BAGEN Found

The paper's most striking result is the low correlation between task performance and budget-awareness: r = 0.35 across the five frontier models. A model can score highly on the underlying task (SWE-bench resolution rate, puzzle solutions) while simultaneously being a poor predictor of its own resource usage.

Why? The paper attributes this to a training signal mismatch. LLMs are optimized to complete tasks — not to predict when they'll fail to complete tasks. Budget reasoning is a metacognitive skill that isn't directly rewarded in standard RLHF or instruction-following fine-tuning. Agents are implicitly trained to be optimistic because optimistic agents appear more capable on success-rate benchmarks.

The practical result is an agent that:

  1. Underestimates remaining steps on hard tasks
  2. Doesn't recalibrate its estimate as costs increase
  3. Never triggers an early stop or user alert
  4. Runs to the hard token limit, returns a failure, and leaves you with a full invoice

SFT+RL fine-tuning on BAGEN-specific trajectories does improve early stop and alert behavior. But the coverage cap suggests that the interval estimation problem may require architectural changes, not just fine-tuning.

Effloow Lab PoC: Simulating Interval Estimation

Effloow Lab reproduced the core BAGEN dynamics using a Python stdlib simulator. The goal was to demonstrate the estimator comparison without any LLM API calls or external packages.

Setup:

  • 20 simulated agent trajectories (10 solvable, 10 unsolvable)
  • Budget: 1,500 tokens
  • Solvable tasks: 6–12 steps, 80–200 tokens/step
  • Unsolvable tasks: 10–18 steps, 150–350 tokens/step (higher variance, backtracking pattern)

Two estimators were compared:

Over-optimistic estimator (baseline, mimicking frontier model behavior):

def over_optimistic_estimator(consumed_so_far, max_budget, step, total_steps_estimate):
    lower = max(0, consumed_so_far * 0.8)
    upper = consumed_so_far * 1.1  # Only 10% more than current — very optimistic
    feasible = upper <= max_budget
    return {"lower": lower, "upper": upper, "feasible": feasible, "alert": False}

Enter fullscreen mode Exit fullscreen mode

This estimator assumes consumption will flatten out. It fires zero alerts across all 20 trajectories — replicating the paper's finding about frontier model over-optimism.

BAGEN-style interval estimator (rolling cost + variance):

def bagen_estimator(consumed_so_far, max_budget, step, trajectory_so_far):
    step_costs = [t["cost"] for t in trajectory_so_far]
    avg_cost = sum(step_costs) / len(step_costs)
    variance = sum((c - avg_cost)**2 for c in step_costs) / len(step_costs)
    std = math.sqrt(variance)

    # Detect increasing cost trend (unsolvable signal)
    recent_avg = sum(step_costs[-3:]) / min(3, len(step_costs))
    est_remaining = 8 if recent_avg > avg_cost * 1.1 else max(2, 10 - step)

    lower = consumed_so_far + est_remaining * max(0, avg_cost - std)
    upper = consumed_so_far + est_remaining * (recent_avg + std)

    feasible = lower <= max_budget
    alert = upper > max_budget * 1.15
    return {"lower": lower, "upper": upper, "feasible": feasible, "alert": alert}

Enter fullscreen mode Exit fullscreen mode

Results from the PoC run:

Experiment: 20 trials, budget=1500 tokens
Solvable tasks (n=10):   1 exceeded budget
Unsolvable tasks (n=10): 10 exceeded budget

Estimator Comparison:
  Over-optimistic (frontier): 0 alerts fired
  BAGEN-style estimator:      72 alerts total, 56 on unsolvable tasks

Early Stopping Simulation:
  Average savings on failed tasks: 44.6%
  Range: 40.9% – 48.7%

Enter fullscreen mode Exit fullscreen mode

The step-by-step output on an unsolvable trajectory shows how quickly the rolling-cost estimator detects the pattern:

Step   Consumed      Lower      Upper   Alert?
--------------------------------------------------
   1        332        332       1500
   2        561       2393       3217  ⚠ ALERT
   3        813       2401       3019  ⚠ ALERT
   4       1134       2571       3002  ⚠ ALERT
   5       1450       2693       3139  ⚠ ALERT

Enter fullscreen mode Exit fullscreen mode

The alert fires at step 2, when the upper bound already projects 3,217 tokens needed against a 1,500-token budget. A production system could halt, escalate to a human, or switch to a cheaper fallback at this point.

Lab note: This is a simulated environment. The paper evaluates on actual LLM agentic runs with real tool calls. Our PoC validates the statistical pattern, not specific model rankings.

How to Build This Into Your Agent System

The BAGEN insight translates directly into a production wrapper pattern. The idea is to run a lightweight interval estimator alongside your main agent loop, and trigger actions when the upper bound crosses a threshold.

Minimal budget guard implementation:

from collections import deque
import math

class BudgetGuard:
    def __init__(self, max_budget: int, alert_threshold: float = 1.15):
        self.max_budget = max_budget
        self.alert_threshold = alert_threshold
        self.step_costs = deque(maxlen=10)  # Rolling window
        self.total_consumed = 0

    def record_step(self, tokens_used: int) -> dict:
        self.step_costs.append(tokens_used)
        self.total_consumed += tokens_used
        return self._estimate()

    def _estimate(self) -> dict:
        if len(self.step_costs) < 2:
            return {"feasible": True, "alert": False, "upper": self.max_budget}

        costs = list(self.step_costs)
        avg = sum(costs) / len(costs)
        variance = sum((c - avg) ** 2 for c in costs) / len(costs)
        std = math.sqrt(variance)

        recent_avg = sum(costs[-3:]) / min(3, len(costs))
        # Detect upward trend = backtracking/unsolvable signal
        est_remaining = 8 if recent_avg > avg * 1.1 else max(2, 12 - len(costs))

        lower = self.total_consumed + est_remaining * max(0, avg - std)
        upper = self.total_consumed + est_remaining * (recent_avg + std)

        return {
            "feasible": lower <= self.max_budget,
            "alert": upper > self.max_budget * self.alert_threshold,
            "lower_bound": int(lower),
            "upper_bound": int(upper),
            "consumed": self.total_consumed,
        }

# Usage in an agent loop:
guard = BudgetGuard(max_budget=8000)

for step in agent.run():
    tokens_this_step = count_tokens(step.messages)
    status = guard.record_step(tokens_this_step)

    if status["alert"]:
        # Upper bound exceeds budget — intervene
        agent.trigger_escalation(
            f"Budget alert: estimated {status['upper_bound']} tokens needed, "
            f"budget is {guard.max_budget}. Stopping early."
        )
        break

Enter fullscreen mode Exit fullscreen mode

This pattern requires no LLM calls, no fine-tuning, and no additional dependencies. The computational overhead is negligible — a few floating-point operations per step.

Common Mistakes Developers Make with Token Budgets

Treating the hard limit as the only control point. Most frameworks let you set max_tokens and call it done. But a hard limit generates a truncation error at the wall — it doesn't give you a graceful exit. The BAGEN pattern adds soft signals earlier in the trajectory.

Measuring only task success rate. BAGEN's main point is that success rate and budget-awareness are largely uncorrelated (r=0.35). If your eval only tracks task completion, you won't notice the over-optimism problem until your inference bill arrives.

Ignoring per-step cost trends. The early warning signal isn't total consumption — it's the derivative. A task that burns 200 tokens in step 1 and 350 in step 2 and 480 in step 3 is showing a diverging cost trajectory. That pattern, not the absolute number, is what BAGEN's estimator catches.

Applying a flat budget to all task types. Sokoban puzzles, code generation tasks, and supply-chain optimization have different intrinsic token distributions. A budget that's appropriate for one type will be wasteful for another. Consider per-task-class budgets tuned from past trajectories.

FAQ

Q: Does this problem affect all LLM agents equally?

The paper evaluates five frontier models and finds consistent over-optimism across all of them, with r=0.35 correlation between task performance and budget-awareness. Variation exists between models, but no current frontier model reliably predicts its own token consumption on hard tasks.

Q: Is the 28–64% token savings claim realistic in production?

The 28–64% range comes from the actual BAGEN benchmark runs on real LLM trajectories (Sokoban, Search-R1, SWE-bench, supply-chain). The Effloow Lab PoC confirmed a 44.6% average in simulation. The key constraint is that savings only apply to failed trajectories — tasks the agent was going to fail anyway. On successful tasks, early stopping would reduce quality. The budget guard should only trigger on trajectories that cross a high-confidence alert threshold.

Q: Can I fine-tune my model to be more budget-aware?

Yes — the paper demonstrates that SFT+RL fine-tuning on BAGEN-specific trajectories improves early stop and alert behavior. However, interval coverage still caps at 47% after fine-tuning, suggesting that perfect calibration remains an open problem. The wrapper pattern described above is a simpler, training-free alternative that works with any base model.

Q: What's the difference between this and just setting a lower token limit?

A hard lower limit truncates the agent arbitrarily. The BAGEN approach adds intelligence to the stopping decision: the estimator predicts that this specific trajectory is unlikely to succeed, so stopping now saves budget without affecting tasks that were going to succeed. Hard limits waste budget on easy tasks (by cutting them short) and fail on hard tasks (by stopping them at the wrong moment). Soft signals based on interval estimation are more precise.

Q: Where can I read the full paper?

The paper is available at arxiv.org/abs/2606.00198. The project website with benchmark environments and data is at ragen-ai.github.io/bagen.

Key Takeaways

  • BAGEN (arXiv:2606.00198) documents that frontier LLM agents have a correlation of only r=0.35 between task performance and budget-awareness — being a strong agent doesn't make you budget-aware.
  • Frontier models are consistently over-optimistic: they underestimate token consumption on hard tasks and never trigger early stops.
  • Early stopping on failed trajectories saves 28–64% of tokens in the paper's benchmark runs.
  • Budget-awareness breaks into three measurable skills: feasibility prediction, early failure detection, and interval calibration. Current models struggle with all three.
  • A practical solution is a wrapper-level interval estimator that monitors per-step cost trends and triggers soft alerts before the hard budget wall.
  • The Effloow Lab PoC confirmed 44.6% average savings in simulation using a rolling-cost estimator with variance — no LLM calls required.

Bottom Line

BAGEN turns a billing problem into a diagnostic one. If your agents are burning through budgets on failed tasks, the fix isn't raising the limit — it's adding interval estimation to your agent loop. The paper gives you the framework; the wrapper pattern above gives you the implementation. It takes under 30 lines of stdlib Python and works with any model.