# Where Should the Code Go? Locating Foundation-Model Errors in Bitemporal Inventory Simulation

Exact code placed around a weak model removes different errors

Durga Sandeep Saluru, Lanchen Song, Aditya Kumaran · arXiv · 2026-11-10

- **Problem** Models that rebuild inventory state from late, revised reports often pick the wrong reports. Asking them to reason harder does not reliably fix this, and it can backfire under forced tool calls.
- **Method** The authors place exact code before the model, after it, or inside the call. Canonical input has code pick the right report versions and order them by event time before the model sees them.
- **Results** Canonical input raised future-joint accuracy by 29.7 points for GPT-5.4 mini. A hosted code tool inside the call raised GPT-5.4 mini's raw-input accuracy by 54.2 points.

![Figure 2: Historical and future-stage errors under the three representations in the original grid. Snapshot historical answers are supplied by code; their accu…](https://refivu.com/papers/96d82fc1-9d6c-4886-bf1e-31776898be26/figures/figure-28e1b47acd6a37b4e32a394107bd0f24.png?thumb=512)

**Figure 2** : Historical and future-stage errors under the three representations in the original grid. Snapshot historical answers are supplied by code; their accuracy measures faithful copying. Future- stage errors remain the substantive endpoint for that representation.

[Original paper](https://arxiv.org/abs/2611.14671v1) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Durga Sandeep Saluru, Lanchen Song, Aditya Kumaran · Where Should the Code Go? Locating Foundation-Model Errors in Bitemporal Inventory Simulation · Original paper figure · Extracted the figure area from page 15 of the original PDF.

## Why rebuilding the state goes wrong

The state a model must rebuild is the state visible at a knowledge cutoff, which is not the physical state. Each report carries an event identifier, a revision, an event time and a received time, so a later report can revise an earlier one. Rebuilding the visible state needs an arrival-time cutoff, then revision resolution, then replay in event-time order.

The environment keeps reports received by K, retains the highest visible revision per event, and replays in (event time, identifier) order from the initial stock.

Agentic pipelines often keep this operational state in the model's context, and the model's stated beliefs can diverge from its actions. Exact code solves the same task, so the design question becomes where that code should sit relative to the model. Existing inventory benchmarks evaluate ordering policy rather than ledger replay, so they don't isolate state reconstruction.

Per-stage error attribution is missing from comparisons of code placement, and the paper's three-way comparison fills that gap.

The paper compares three full-output arms that move executable work before the model. The snapshot arm also supplies the exactly replayed historical state, leaving only the rollout to the model. The state-only arms move the schedule step after the model, so code applies the future schedule to the emitted stock.

## Where the code can sit

Each arm answers one question: which exact code runs before the model, which runs after it, and which runs inside the call. The canonical arm has code select the correct version-resolved events and order them by event time before the model sees them. The snapshot arm hands the model exact historical state from replay, so the model only has to roll the future forward.

Canonical input raises future-joint accuracy over raw input by mini +29.7 \[+20.8, +38.5\] and Haiku +33.3 \[+24.0, +43.2\]. Even with exact state, every weak model stays below 100% on snapshot input, because the 12-event rollout is still the model's job.

Two state-only arms move the executable work after the model, which returns only the stock at T and the historical loss. Because units are conserved, continuation from the emitted stock is correct only when that stock is correct. The authors verified this identity on every hybrid answer. On canonical input the hybrid's gain over the model's own rollout is mini +8.3 \[+3.6, +13.5\], and GLM +22.9 \[+15.1, +30.7\].

Two code-inside arms give the two OpenAI configurations a hosted code tool, and the model decides whether to run it. With raw input, mini's future-joint accuracy rises by +54.2 \[+45.3, +62.5\] points on synthetic histories. Measured against the automatic-choice baseline, the tool's own contribution is +34.9 \[+26.0, +43.8\] points on raw input.

## Scoring each answer against the replay

A full answer is five integers, and the replay defines each one for a given target time T and cutoff K. A request first keeps only the reports received by the cutoff K. Of those, it retains the highest visible revision per event. Events with event time at most T are kept, then replayed in (event time, identifier) order from the initial stock.

A receipt of q adds q to the stock, while a demand of q sets the stock to max(0, x−q) and loses max(0, q−x).

The supplied schedule runs through horizon H and is then applied with the same rule. The first future time is −1 when no future loss occurs.

All-five exactness requires all five integers to be correct. Future-joint exactness requires all three scenario outputs to be correct. Invalid, missing, refused or truncated outputs count as failures, and no model output is retried. Each configuration, arm and history cell has two requests. Paired differences average repetitions within history before 10,000 history-bootstrap draws give descriptive 95% intervals.

Replay gives a check that the model's output can be scored against exactly. Table 1 reports future-joint accuracy, so the three future outputs are what it scores. The main results therefore measure whether the model's five fields match the exact replay.

## Placement results for weak models

Six of the twelve configurations score below 90% on raw reports, so placement matters mostly for the weaker components. Canonical input, where code selects and orders the eligible events, lifts future-joint accuracy by mini +29.7 \[+20.8, +38.5\] and Haiku +33.3 \[+24.0, +43.2\]. Among the weak models, canonical input also lifts gpt-oss-20b +27.1 \[+19.8, +34.4\] and gpt-oss-120b +24.0 \[+16.1, +31.8\].

So moving selection into code recovers most of the gap for these models, which is the selection error the section heading names.

![Table 1: Future-joint accuracy (%, all three scenario outputs exact) by input and code placement, every configuration under automatic tool choice at its lowest…](https://refivu.com/papers/96d82fc1-9d6c-4886-bf1e-31776898be26/figures/figure-e4da1d071c87934fc45461abfc41f333.png?thumb=512)

**Table 1** : Future-joint accuracy (%, all three scenario outputs exact) by input and code placement, every configuration under automatic tool choice at its lowest requested effort (OpenAI and open-weight models: requested effort low; Anthropic models: no or 4,096-token thinking); 192 synthetic and 96 profile calls per cell; invalid and missing answers fail.raw: model selects, replays and rolls out; canonical: code selects and orders eligible events;hybrid: model returns the two historical fields from canonical input and code applies the schedule (equals reconstruction accuracy by conservation); snapshot: exact state supplied, model rolls out. †Open-weight models through OpenRouter, each pinned to one upstream provider (Appendix F). Forced-call cells and all-five accuracy: Appendix B.

[Original paper](https://arxiv.org/abs/2611.14671v1) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)

Exact state doesn't make the weak models exact. So the model can still fail on the rollout even when it receives the correct historical state.

The models differ in which stage fails most. For GLM-5.3 Flash, canonical input adds 8.3 points \[+0.0, +16.7\], and exact state adds -5.2 points \[-14.6, +4.7\] on top of that. Code applied after the model to the same canonical answers adds 22.9 points \[+15.1, +30.7\]. The authors read this model's error as almost entirely rollout, since exact state adds nothing once canonical input is in place.

gpt-oss-20b fails at both stages. Canonical input adds 27.1 points \[+19.8, +34.4\], and exact state adds a further 31.8 points \[+21.4, +42.2\]. Run prospectively, the hybrid's gain over the model's own rollout on canonical input is 8.3 points \[+3.6, +13.5\] for GPT-5.4 mini.

## What hosted code adds

Letting GPT-5.4 mini call code inside its answer lifts raw-input accuracy far more than any outside placement did for this model. With a hosted code-execution tool available, mini's raw-input future-joint accuracy rises by 54.2 points \[+45.3, +62.5\] on synthetic histories. On the retail profiles the same change gives 77.1 points \[+68.8, +84.4\], and GPT-5.4 reaches 100% on raw input in both cohorts.

The tool is available only to the OpenAI configurations, so this comparison covers those models alone.

Mini chose to run code in 469 of 576 calls, and its code-running answers were exact in 453 of them. Of the 107 calls it answered without code, 93 were correct, so code use and correctness moved together. The paper does not claim that code use caused the correct answers, since the choice to run code was the model's own.

The fair baseline is automatic tool choice under the same interface, not the forced-call arm. Against that baseline, the tool's own contribution on synthetic histories is 34.9 points \[+26.0, +43.8\] on raw input. On canonical input the contribution shrinks to 11.5 points \[+6.2, +17.7\].

The code-inside arm is a placement that puts exact execution inside the call, rather than before or after the model. Its gains come with a dependence on the interface, which the next section examines through the forced answer call.

## Reasoning effort and the tool interface

Asking for more reasoning does not help uniformly here, and the answer depends on whether the tool-calling interface is forced. Under a forced answer call, DeepSeek V4 Flash on its provider effectively turned reasoning off. Its forced canonical calls averaged 32 reasoning tokens, compared with 1695 under automatic choice. Its accuracy was 2.1 against 99.0%, and effort changed nothing under either interface.

![Table 2: Requested reasoning effort × tool-choice interface, synthetic cohort, canonical input, future- joint accuracy (%; 192 calls per cell). high−low: paire…](https://refivu.com/papers/96d82fc1-9d6c-4886-bf1e-31776898be26/figures/figure-f1e2954d6aa0e0e9a6eaaccaef5ed499.png?thumb=512)

**Table 2** : Requested reasoning effort × tool-choice interface, synthetic cohort, canonical input, future- joint accuracy (%; 192 calls per cell). high−low: paired effort effect within an interface. Interaction: automatic-choice effort effect minus forced-call effort effect, paired by history, with a descriptive 95% history-bootstrap interval (10,000 draws); a positive interaction means the forced call turns extra effort into a liability. Requested effort is a family-specific provider setting, not a compute match (observed reasoning tokens: Appendix F).

[Original paper](https://arxiv.org/abs/2611.14671v1) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)

GPT-5.4 mini shows the sharpest interaction between effort and interface. Under automatic choice the same effect is +6.8 \[+0.5, +13.5\]. The interaction is +47.9 \[+35.9, +59.9\], a positive value, so the forced call turns extra effort into a liability for this model. DeepSeek V4 Pro fell from 98.4 to 82.3% under the forced call at high effort, with 32 of 192 calls giving no answer.

It stayed at 97.4% under automatic choice.

GPT-5.4 shows a smaller interaction of the same sign, at +5.2 \[+1.0, +9.4\]. For gpt-oss-20b, gpt-oss-120b, Qwen3.8-27B and GLM-5.3 Flash, the interaction interval covers zero. Gpt-oss-20b hit the same limit in 97 of 192 automatic raw calls, and each such call is a missing answer.

So these cells measure willingness to answer as much as ability, since gpt-oss-20b also refused the fictional task in 88 of 192 low-effort raw calls.

## Limitations of the placement and interface findings

The coverage is narrow, and the authors name the limits themselves. The study uses synthetic histories with artificial corrections, two repetitions per cell, one retail source and 96 histories. Differences under nine points are not resolved, and that includes GLM's canonical gain and Haiku's hybrid gain. Snapshot input isn't a pure rollout probe for every model.

So the state's presentation may itself change behaviour, and the snapshot arm can't be read as rollout alone.

Against that contemporaneous baseline, the automatic-minus-forced difference is -6.8 and -15.1 points. The diagnostic supports a narrower claim than its title suggests. For strong components, the authors say the placement is moot.

No time-series foundation model is evaluated, because forecasting was removed to measure state error exactly. The authors argue that normalizing the reports in code first would remove selection and replay errors before a forecaster sees them. They did not test that claim. Sampling and uncertainty intervals describe variation within this constructed sample, not population guarantees.

## Paper info

- **Authors**: Durga Sandeep Saluru, Lanchen Song, Aditya Kumaran
- **Venue**: arXiv · Preprint
- **First published**: 2026-11-10
- **Added**: 2026-11-13
- **Updated**: 2026-11-10
- **Version**: v1
- **arXiv**: 2611.14671
- **Category**: cs.SE · cs.AI · cs.LG
- **Original paper terms**: [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)
- **What we show**: Paper info, commentary and permitted figures from the original paper

[Original paper ↗](https://arxiv.org/abs/2611.14671v1) · [PDF ↗](https://arxiv.org/pdf/2611.14671v1)

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

## Abstract

Operational reports carry two clocks: when an event happened and when its report arrived; later reports can revise earlier ones. A foundation-model component that maintains the state supported by the reports visible at a cutoff, then rolls a supplied scenario forward, can be helped by exact code before it, after it or inside the call, or asked to reason harder. We ask which remedy removes which error, for which models, on an exactly solvable lost-sales inventory environment: 36,672 independently rescored requests over twelve configurations of closed and open-weight models, with a forced-answer-call interface as a control and protocols frozen before the calls. Weak models fail in separable ways. Canonical input removes report-selection error, exact continuation removes rollout error, neither repairs the other, and which error dominates differs by model; strong models are at ceiling on raw reports. Asking for more reasoning is no substitute and can depend on the interface: under a forced answer call high effort collapses GPT-5.4 mini and DeepSeek V4 Pro, which gain or hold under automatic choice; on its provider the forced call disables reasoning for DeepSeek V4 Flash; and at high effort gpt-oss exhausts its output budget. The contribution is a controlled component diagnostic, released with every request, and evidence that for some model and provider pairs the tool-calling interface confounds reasoning evaluation.

## Quote from the paper

Durga Sandeep Saluru, Lanchen Song, Aditya Kumaran (2026). Where Should the Code Go? Locating Foundation-Model Errors in Bitemporal Inventory Simulation. arXiv:2611.14671v1. https://arxiv.org/abs/2611.14671v1

**BibTeX**

```
@misc{saluru2026where,
  title = {{Where Should the Code Go? Locating Foundation-Model Errors in Bitemporal Inventory Simulation}},
  author = {Durga Sandeep Saluru and Lanchen Song and Aditya Kumaran},
  year = {2026},
  eprint = {2611.14671},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.14671v1}
}
```

## Other paper commentary

- [The Malicious Use of Artificial Intelligence: Forecasting, Prevention, and Mitigation](https://refivu.com/en/papers/0218f522-1eb2-40e8-92ea-845dd07e76f6-the-malicious-use-of-artificial-intelligence-forecasting.md)
- [Differentially Private Federated Learning: A Client Level Perspective](https://refivu.com/en/papers/8eaa4c01-7257-42c2-9d51-9996980ee41d-differentially-private-federated-learning-a-client-level.md)
- [Metrics for Multi-Class Classification: an Overview](https://refivu.com/en/papers/78ca6b47-f74d-4a51-a805-f5f83bb18a77-metrics-for-multi-class-classification-an-overview.md)
- [Exploiting Unintended Feature Leakage in Collaborative Learning](https://refivu.com/en/papers/422f8c4a-b03f-4b77-a90a-48be0d614527-exploiting-unintended-feature-leakage-in-collaborative.md)
- [Continual Learning Through Synaptic Intelligence](https://refivu.com/en/papers/443ed68e-4775-416a-b80f-35ef15c63f40-continual-learning-through-synaptic-intelligence.md)
- [Detecting Spacecraft Anomalies Using LSTMs and Nonparametric Dynamic Thresholding](https://refivu.com/en/papers/64c18ffc-78a1-4f78-8aae-69d2bac47633-detecting-spacecraft-anomalies-using-lstms-and-nonparametric.md)
- [Beyond Row-Level Prediction: Evaluating and Learning Composition for Reusable Table Representations](https://refivu.com/en/papers/926dfbaf-d1c1-445c-ae12-e45ec6ed1816-beyond-row-level-prediction-evaluating-and-learning.md)
- [Calibrate, Don't Retrain: Decomposing the Value of Annotator Disagreement in Cyberbullying Severity](https://refivu.com/en/papers/8c08c18f-ffcd-4d8e-9fef-9ac1fa6a8a00-calibrate-don-t-retrain-decomposing-the-value-of.md)
- [Testing Conversation Preservation Across LLM APIs: A Rule-Based Oracle for Detecting Silent Information Loss](https://refivu.com/en/papers/a42f6e56-458a-4ddc-9fa1-957b8bee3917-testing-conversation-preservation-across-llm-apis-a-rule.md)
- [Termination Lag: Coding Agents Solve Early but Stop Late](https://refivu.com/en/papers/520a3a4d-fc06-4832-b3c1-a97eb683de41-termination-lag-coding-agents-solve-early-but-stop.md)
- [Do Large Language Models Show Racial and Sex Bias in Pain Management? A Counterfactual Audit of GPT, Claude, Gemini, Llama, DeepSeek and Qwen](https://refivu.com/en/papers/35f582d1-90ca-40c6-a272-2cfa4575fafe-do-large-language-models-show-racial-and-sex.md)
- [Stress-Testing Sandbagging Detection Under Adaptive Attack](https://refivu.com/en/papers/d5f9221a-801e-4cf1-834b-f0b16f71c771-stress-testing-sandbagging-detection-under-adaptive-attack.md)

## Terms in this paper

- [reasoning](https://refivu.com/en/terms/148ee0b509df-reasoning)
- [GLM-5.3 Flash](https://refivu.com/en/terms/82b21eec8052-glm-5-3-flash)

---

AI-written text can contain mistakes. [Refivu](https://refivu.com/en/papers/96d82fc1-9d6c-4886-bf1e-31776898be26-where-should-the-code-go-locating-foundation-model)
