LLMs Track State Over 196 Tool Calls for MD5

Dheeraj Mohandas Pai, Lu Xian· September 2, 2026 View original

Key takeaways

  • LLMs can successfully track exact intermediate state across hundreds of dependent tool calls for long-horizon tasks.
  • Keeping the model's own reasoning in its context is critical for maintaining state over long sequences.
  • Voting mechanisms can effectively correct arithmetic and logical slips in sequential LLM operations.
  • Mixture-of-experts models show promise for tasks requiring high precision and extended state retention.

Who benefits

AI DevelopmentSoftware EngineeringCybersecurityAutomationRobotics

Summary

This paper investigates large language models' ability to maintain exact intermediate state across a deep sequence of dependent tool calls by having them compute an MD5 cryptographic hash. It demonstrates that a mixture-of-experts model can successfully carry state over 196 calls, highlighting the importance of keeping reasoning in context and using voting for arithmetic slips.

Evaluating large language models (LLMs) on long-horizon tasks is challenging because errors can cascade catastrophically when each step depends on the previous one. Existing benchmarks often conflate state-tracking difficulty with instruction interpretation and are susceptible to shortcuts, making it hard to pinpoint why a long task fails. This research specifically isolates and tests an LLM's capacity to carry exact intermediate state across numerous tool calls. The study uses the computation of an MD5 cryptographic hash as a clean test case. This involves a sequence of 196 dependent tool calls over 64 rounds, where the LLM must carry four 32-bit words (a,b,c,d) in its context from one call to the next. The task's interpretation is simplified, and the MD5 implementation from scratch allows for bit-level verification, ensuring any failure is purely due to state bookkeeping. A mixture-of-experts model, gpt-oss-120b, with approximately 5.5B active parameters per token, successfully carried the full state across all 196 calls and returned the correct digest on a majority of completed runs. Key to its success were two factors: consistently keeping the model's own reasoning in its context each turn, and employing voting over a "thinking-enabled" worker LLM to correct modular arithmetic errors. The research also localizes residual failures, distinguishing between state-carrying issues, arithmetic errors, and serving problems.

Why it matters

For developers building AI agents that perform multi-step, complex tasks, understanding how LLMs manage and propagate state is crucial. This research provides insights into improving the reliability of long-horizon AI workflows, especially where precision and sequential dependency are critical.

How to implement this in your domain

  1. 1Design agentic workflows to explicitly maintain and pass intermediate state within the LLM's context for long-horizon tasks.
  2. 2Implement mechanisms for self-correction or voting among multiple LLM calls to mitigate arithmetic or logical slips in sequential operations.
  3. 3Break down complex tasks into smaller, dependent tool calls, ensuring clear state transitions between steps.
  4. 4Evaluate your LLM agents on benchmarks that specifically test long-horizon state tracking, similar to the MD5 computation.
  5. 5Consider using mixture-of-experts models for tasks requiring high precision and extended state retention.

Original post by Dheeraj Mohandas Pai, Lu Xian

"arXiv:2609.00012v1 Announce Type: new Abstract: Long-horizon tasks remain uncommon in large language model (LLM) evaluation, and for a reason: when each step depends on the last, per-step accuracy that looks excellent in isolation decays catastrophically, as errors cascade and th…"

View on X

Originally posted by Dheeraj Mohandas Pai, Lu Xian on X · view source

Want to go deeper?

Turn these trends into skills with Learnijoy's hands-on AI & tech courses.

Explore courses