Search papers, labs, and topics across Lattice.
To tackle the order-of-magnitude variance in agent inference costs driven by dynamic tool feedback and compounding context re-reads, the authors introduce TokenCast, an online cost forecaster for LLM agent workflows. The framework learns composable segment representations that decouple local token usage from context growth, algebraically aggregating downstream inflation effects without requiring auxiliary model calls. Across four agent benchmarks and six foundation models, TokenCast achieves a 14.5% average MAE reduction over top baselines and slashes token consumption by 21.3% in budget-constrained execution at a negligible 32.8 ms overhead per SWE-bench run.
LLM agent token consumption swings by over an order of magnitude on identical tasks, but dynamically tracking context inflation across execution segments slashes budget waste by 21.3% without making a single extra LLM call.
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.