TokenCast: Forecasting Token Consumption During LLM Agent Execution

Chaoqian Ouyang, Ling Yue, Libin Zheng, Huanghui Guo, Shengxiang Xu, YiShu Wang, Ran Li, Jian Yin and 2 others

Sun Yat-Sen University · Rensselaer Polytechnic Institute · Southeast University · Hong Kong University of Science and Technology

Published September 28, 2026 · on the feed September 29, 2026 · ▲ 4 · arXiv 2609.35760

AgentsTabular & time series Empty repo arXiv ↗Hugging Face ↗

The abstract

When a large language model (LLM) agent executes the same task, token consumption can vary by over an order of magnitude across runs. The agent chooses its next steps based on tool feedback and intermediate results, while the growing context steadily inflates the input size of every subsequent call. The total consumption of a task is therefore hard to predict before execution and the prediction must be revised as the run unfolds. In this paper, we propose TokenCast, which learns a composable cost representation for each execution segment, recording its own consumption and the context growth it introduces. Composing adjacent segments yields a cumulative estimate that captures the extra input cost incurred when context from earlier segments is re-read by every later call. As execution unfolds, newly observed evidence refreshes the forecast, requiring no additional LLM calls and incurring a mean cumulative prediction time of 32.8 ms per run on SWE-bench Verified. Across 4 task suites and 6 agent models, TokenCast's mean absolute error reduction against the strongest comparator averages 14.5% over 96 evaluated combinations. In offline budget-control replay, TokenCast uses 21.3% fewer tokens on average than a fixed-budget policy at matched trace completion. The code is available at https://github.com/DEFENSE-SEU/TokenCast.

The Brief

2:22

A short podcast summary of the paper. Written and voiced by AI.

Transcript

TokenCast. Forecasting Token Consumption During LLM Agent Execution. By Chaoqian Ouyang and nine others, from Sun Yat-Sen University, Rensselaer Polytechnic Institute, and two other institutions. Published on the twenty-eighth of September. Its code repository is a placeholder: a readme, and nothing to run yet.

Run a large language model agent on the same task twice, and the tokens it consumes can differ by more than an order of magnitude. The agent picks its next steps from tool feedback and intermediate results, so the path is not fixed in advance. Meanwhile the context keeps growing, which inflates the input of every call that follows. The total cost of a task is therefore hard to predict before execution starts, and any prediction has to be revised as the run unfolds.

TokenCast learns a composable cost representation for each segment of an execution. A segment's representation records two things: its own consumption, and the context growth it introduces.

That second quantity is what makes composition work. A segment that adds a lot to the context does not just cost what it costs. It raises the price of everything after it. When adjacent segments are combined, the cumulative estimate captures the extra input cost that arises because context from earlier segments is re-read by every later call. As the run proceeds and new evidence is observed, the forecast is refreshed, so the estimate made at the start is not the one the run is stuck with. Doing so requires no additional language model calls, which matters for a tool whose job is to keep costs down: a forecaster that spent tokens to predict tokens would be working against itself. On SWE-bench Verified, the mean cumulative prediction time is thirty-two point eight milliseconds per run.

Evaluation spans four task suites and six agent models, ninety-six combinations in all. Against the strongest comparator, TokenCast reduces mean absolute error by fourteen point five percent on average. A better forecast only matters if something acts on it, so the authors also put it to use. In an offline replay of budget control, TokenCast uses twenty-one point three percent fewer tokens on average than a fixed-budget policy, at matched trace completion.

Cost here is treated as something that compounds. A segment is expensive not only for what it spends but for what it leaves behind in the context, and a forecaster that accounts for that inheritance can keep its estimate current as an agent wanders, cheaply enough to run alongside it.

Paper Quest · 7 chapters · about 40 min

Play this paper

Learn it by doing: make the calls the authors made, guess the result before you see it, and defend it in a viva graded on your own words. Chapter 1 is right here.

Chapter 1 🧩 · The problem

An agent whose bill can swing wildly from run to run. That is the wall.

You run a language model agent on a coding task. Run it twice and the token bill can differ by more than an order of magnitude.

The road ahead

  1. 1 · The problem ~7 min An agent's token bill swings wildly between runs, because each step depends on feedback and every later call re-reads a growing context.
  2. 2 · What came before ~3 min
  3. 3 · The key idea ~8 min Describe each block of calls by its call count, context growth and own cost, combine blocks by an exact rule, and refresh the forecast as calls complete.
  4. 4 · Choose your own research ~3 min
  5. 5 · Build the method ~8 min Represent segments by calls, context growth and residual cost, compose them into a cumulative estimate, and refresh it as calls finish.
  6. 6 · The experiment ~6 min You’ll guess: In an offline replay of budget control, how many fewer tokens did TokenCast use than a fixed-budget policy, at matched trace completion?
  7. 7 · The viva ~5 min Three questions from the examiners, answered in your own words. Win it for the paper’s trophy.
Join free to play the whole quest ›

Free, with Google or an email address. Your stars and progress are kept.

KipQuest: the day’s AI research, as podcasts and quests. All papers Android app Privacy Contact Episodes are written and voiced by AI from each paper. Summaries can contain mistakes: the paper is the source.