Manuscript Offprint

arXiv:2610.19292

Whose turn is it? Context-guided model routing for stateful agents

Anikesh Parashar, Avik Dutta, Vashu Chauhan, Sumit Gulwani, Priyanshu Gupta, Hosein Hasanbeig, Vu Le, Ashish Tiwari, Jack Williams

ABSTRACT

Model routing can reduce the cost of LLM applications by assigning simpler requests to cheaper models without sacrificing the quality of the response. However, most routers treat requests as independent. Stateful agents do not operate under this assumption: a user turn may require multiple model and tool calls, its difficulty depends on the state produced by earlier turns, and changing models can sacrifice reuse of the conversational prompt cache. We study zero-shot, cost-aware routing at the user-turn boundary, systematically varying the routing rule, access to session history, candidate models that differ in size, reasoning effort, or model provider, and prompt-cache behavior. We evaluate on multi-turn versions of SheetCopilot and SpreadsheetBench 2, where persistent workbooks and cross-turn dependencies make isolated routing decisions especially brittle. At a matched offloading rate, giving the router session history improves task pass rate over the same router without history, with gains for every model pair; history-aware routing remains within one point of always using the expensive model. We also found that cost depends on execution dynamics rather than token prices alone: the cheaper model's per-task cost advantage narrows from 6.8×6.8 \times to 3.2×3.2 \times on longer sessions. A closed-form cache analysis further shows that downward switches (expensive to cheap) recover their cache cost within two LLM calls, whereas upward switches do not break even under the evaluated conditions. Together, these results show that agent routing is a sequential decision problem: effective policies must account for what happened earlier in the session and for the asymmetric cost of switching models.

1 INTRODUCTION

LLM agents interleave model calls with tool execution to complete user tasks. Assigning every call to an expensive frontier model provides strong planning and error recovery, but the cost accrues on every call of every turn of every session. Stronger reasoning is also not uniformly beneficial: extended reasoning can overthink and abandon correct answers while consuming substantially more tokens (Zhou et al., 2026). Assigning every call to a cheap model reduces cost but fails when a turn requires planning, cross-artifact coordination, or recovery from an earlier error, as smaller models tend to favor quick, locally plausible responses over deliberate reasoning (Ranaldi & Freitas, 2024). Model routing exploits this gap by using the cheap model when it suffices and reserving the expensive model for the requests that need it. Throughout this paper, cost reduction is the objective and quality is a constraint: a routing policy is useful if it lowers cost without lowering task success.

Most routers treat requests as independent inputs (Chen et al., 2023; Ong et al., 2025; Hu et al., 2024). Deployed agents, however, operate over multi-turn sessions. We use turn for one user request together with the agent's response to it, which may involve many LLM calls and tool invocations; a turn is an interaction-level unit, not a single model call. Across turns, routing becomes a sequential problem for four reasons. First, difficulty varies within a session when working on spreadsheets: building a pivot table, changing one of its parameters, and repairing a broken chain of formulas require different capabilities. Second, the current request is often uninterpretable without the preceding trajectory. For instance, “Apply the same format to Q3” is simple only if the router knows which format and which sheet, and LLMs are known to lose track as user intent evolves over turns (Tack et al., 2026). Third, earlier decisions shape later turns: once an expensive model has built the structure of a solution, a cheap model can often extend it by following the traces in its context, so a turn that is hard in isolation can be easy in context. Fourth, switching is not free: providers cache prompt prefixes per model, so a switch forfeits the cached conversation and bills it again as uncached input.

We restrict attention to routing policies that can be deployed as-is, which imposes two constraints. First, routers must be zero-shot: their decisions come without routing labels, preference data, or fine-tuning. Candidate models are replaced every few months, and a learned router must be re-supervised for every new pair. In agentic sessions this supervision is especially expensive: labeling one turn requires executing its full tool loop under each candidate from the same state, and because the state at later turns depends on every earlier choice, a TT-turn session admits up to 2T2^T routed trajectories. Our analysis nonetheless applies to learned routers, which instantiate the same policy class with a trained decision function: the dimensions we study (i.e., what the router observes, when it decides, and in which direction it may switch) do not depend on how that function is obtained. Second, policies must be cost-aware. Methods designed to raise quality by spending additional compute, such as sampling several solutions and voting (Wang et al., 2023), multi-agent debate (Du et al., 2024), or verifier-guided best-of-N search (Snell et al., 2025), do not target cost reduction, and in agentic sessions, where every sample is a full tool loop, they multiply the cost of each turn. We therefore exclude them.

We study these questions on spreadsheet manipulation domain. Four properties make this domain specifically hard (if not harder than the software-engineering tasks on which agentic systems are most often evaluated (Jimenez et al., 2024)): (i) Two-dimensional, implicitly structured state. Tables, headers, merged cells, and formatting carry meaning that must be serialized into text, which strains context budgets (Dong et al., 2024), and LLMs see far less of this structure during pretraining than they see source code. (ii) Hidden dependencies. Formulas form a dataflow graph through cell references rather than through named, importable symbols, so a local edit can silently change values on other sheets. (iii) Weak verification. A repository ships with tests, compilers, and tracebacks that agents use to check their work; a workbook has no executable specification, and a formula over the wrong range returns a plausible number rather than an error. Such silent errors are pervasive even in spreadsheets built by people (Panko, 1998). (iv) End-user intent. Requests come from end users rather than developers and are short, underspecified, and grounded in the data rather than in a precise issue report. The empirical gap is large: frontier models that lead software-engineering benchmarks (e.g., Claude Opus 4.8 (Anthropic, 2025)) pass at most 31.2% of our multi-turn SheetCopilot tasks, and on SpreadsheetBench 2 the best of eight frontier models completes 34.9% of workflows, with debugging accuracy as low as 12% (Zhu et al., 2026). The same properties make spreadsheets a stringent test of routing: weak verification undermines cascades that decide after inspecting an output, and a persistent workbook makes the difficulty of each turn depend on what earlier turns produced.

We formalize routing at the user-turn boundary. This granularity lies between session-level commitment, which cannot adapt as difficulty changes, and per-call routing, which adds decisions inside the agent loop. We use it to answer four questions: (1) which decision rule to use (an LLM router that assigns whole turns, escalation, or de-escalation); (2) what the router should observe (the current request only, or the full session history); (3) how the answers depend on the candidate pair (differing in model size, reasoning effort, or model provider family); (4) and how switching interacts with prompt caching. We evaluate on multi-turn versions of SheetCopilot (Li et al., 2023) and SpreadsheetBench 2 (Zhu et al., 2026) and charge router calls and cache effects to every policy.

Our contributions are as follows:

• We formulate cost-aware model routing for agents in a multi-turn setting at user-turn granularity, separating what the router observes, how often it decides, and in which direction it may switch; routing without history and routing once per session are special cases.

• We build a zero-shot evaluation framework on two multi-turn spreadsheet benchmarks that charges router overhead and prompt-cache effects to each policy, and apply it to candidate pairs that differ in model size, reasoning effort, and model provider.

• We show that routing for agents is a sequential decision problem: gains come from conditioning each decision on the session history, and they depend on the direction of switching, on the candidate pair, on cache reuse and depth of a conversation.

no routing: one model for the whole session

Figure

(a) Per-turn routing and state handoff

(b) Decision rules over a session

Figure 1: Routing policies for multi-turn agents. (a) Before turn tt, a zero-shot LLM router π\pi reads the request utu_t and, when routing with history context, the serialized history hth_t (dashed). It assigns the whole turn to the cheap model mcm_c (simple) or the expensive model mem_e (complex, or on timeout, malformed output, or service failure); under escalation and de-escalation, every turn instead starts on mcm_c or mem_e, respectively. Routing without history drops the history input, and without routing, one model serves the whole session (dotted line). The selected model owns every LLM call and tool interaction of the turn, and the runtime appends the resulting messages, tool observations, errors, workbook state, and routing decision to form ht+1h_{t+1}; models exchange no hidden states or provider-side KV tensors. (b) Illustrative assignments over a four-turn session.

References (27)