---
title: Why AI Agents Call the Same MCP Tool Twice, and the Fix
description: Codex repeated an MCP call in 13 of 40 live runs, Claude Code in 0 of 40. Results were cut off, so it fetched them again. Causes and fixes.
canonical: https://spiritroom.app/blog/duplicate-tool-calls/
published: 2026-10-21
updated: 2026-10-21
---

> Markdown version of https://spiritroom.app/blog/duplicate-tool-calls/ for agents. Index: /llms.txt

[Blog](/blog/) / [Tool results and errors](/guides/tool-results-and-errors-for-agents/)

# Why agents call the same tool twice (13 of 40 runs) and how to stop it

Your logs show the agent calling the same tool with the same arguments twice in one task. It looks like a bug in the agent. In our runs it was mostly a reaction to the result: too big to read in one go, so the app cut it, and the model went back for it. Here's the evidence and how to make the first call enough.

Leonid Bugaev · Published 21 Oct 2026

**TL;DR**

- **Codex repeated a call in 13 of 40 live runs** (20–48%); Claude Code in 0 of 40 (0–9%), on the same 99-tool server and jobs.
- **Mostly the big list tool,** called again with the same or first-page arguments.
- **Cause we could trace:** a 67,251-token print was cut off, so Codex called the feed again to filter it, in 5 of 5 runs of one job.
- **Small results, no repeats:** on a mock with small results, 0 of 90 runs repeated a call (0–4%).
- **Fix:** small default results, the answer summary first, filters for common questions, and a cursor.
[What we saw](#what)[Why it happens](#why)[Small results: no repeats](#mock)[How to stop it](#fix)[How we measured](#how-we-measured)[FAQ](#faq)

## What we saw

Same 99-tool production MCP server, same 8 read-only jobs, 5 runs each:

Codex 0.161.0

*13/40 runs (20–48%)*

Claude Code 2.1.301

*0/40 runs (0–9%)*

Codex's 13 duplicates were spread over 5 of the 8 jobs. Most were the main list tool called again with the same arguments or from the first page, plus a groups list called twice. Every answer in those runs was still correct; the cost was extra calls and bigger requests. Runs with duplicates had larger requests on average, about 52k vs 44k tokens.

## Why it happens: the result didn't fit

The list tool's results ran up to about 57,000 tokens. Codex in code mode calls tools from JavaScript and prints what it wants to read, and it cuts printed output to about 10,000 tokens, keeping the start and end. So the model often saw a slice, then went back.

call listprint 67,251 tokenscut to ~10kcall again + filteranswer

The clearest case was “what's new since yesterday?”. Codex called the activity feed with a limit of 200, printed it, and the print was cut (“original token count: 67,251”). It then called the feed again with the same arguments and filtered the events in code. That happened in **5 of 5** runs (57–100%). In a separate follow-up of 3 live runs with model traffic recorded, every whole list page was cut, and in 2 of 3 runs the recovery meant calling the server again.

Claude Code handles the same oversized result differently: it refuses results over 25,000 tokens and saves them to a file, and the model reads the file. That costs extra reads instead of repeated server calls. See [MCP output limits by agent](/blog/mcp-tool-output-limits-by-agent/).

**See where agents repeat calls on your server.**

We run your users' jobs through Claude Code, Codex and the other apps they use, flag every repeated call, and trace it to the result that caused it.

[Test your MCP →](/#contact)

## Small results: no repeats

We counted repeats in our mock experiments, where every result was small: a made-up task tracker whose biggest default result was about 12,000 tokens. Across 90 runs in Claude Code, Codex and a small free model, **0 of 90** repeated a call with the same arguments (0–4%). Another 40 runs comparing MCP and a CLI: 0 of 40.

Agents did call the same tool more than once with different arguments, which is normal paging or filtering. That dropped as the tools improved: Claude Code 8 of 10 runs with the original server, 4 of 10 after the fixes; Codex 2 of 10 to 0 of 10; the small model 4 of 10 to 1 of 10.

This isn't a controlled test of size alone: the live server and the mock differ in more than result size. But it fits the live evidence: repeats followed results the app had to cut.

**Go deeper:** [Reduce MCP tool response size](/blog/reduce-mcp-tool-response-size/), [How Codex finds MCP tools](/blog/how-codex-finds-mcp-tools/), [How much MCP output is waste](/blog/mcp-context-pollution/).

## How to stop it

1. **Make the default result small**, ideally under about 5,000 tokens so it fits every app's cap. See [how to reduce MCP tool response size](/blog/reduce-mcp-tool-response-size/).
2. **Put the answer summary first**: counts and what's next. Codex keeps the start of a cut print.
3. **Add filters for common questions** (by name, date, status), so the agent asks for the slice instead of fetching everything and filtering.
4. **Leave noise out by default**: in that feed, 56 of 106 events were the agent's own calls.
5. **Return a cursor**, so “more” is a new page, not the same call again.
6. **Count repeats in your tests**: same tool and arguments twice in one run, per app.

All the rules for results: [tool results and errors for AI agents](/guides/tool-results-and-errors-for-agents/).

## How we measured

- **Live:** a 99-tool production MCP server, read-only through an allowlist proxy, 16 Oct 2026. Codex CLI 0.161.0 and Claude Code 2.1.301, 8 jobs × 5 runs each. A duplicate is the same tool with the same or first-page arguments twice in one run.
- **Follow-up:** 3 Codex runs with model traffic recorded, 16 Oct 2026; the “what's new” job, 5 runs.
- **Mock:** 130 runs on a made-up task tracker (Claude Code 2.1.304, Codex 0.161.0, OpenCode 1.18.34 with a small free model), 21 Oct 2026. A duplicate is the same tool with identical arguments twice in one run.
- **Limits:** one live server; ranges are 95% Wilson intervals; Codex's cut sizes are its own estimates.

## FAQ

### Why does my agent call the same MCP tool twice?

In our runs the main cause was result size. When a result is bigger than the app will show, the app cuts it, and the model calls again to get the part it needs, often with a filter in code. Codex did this in 13 of 40 live runs on a server whose list results reached about 57,000 tokens.

### Is it the agent's fault or the server's?

Both play a part, but the server is what you control. The same Codex version made no exact repeats in 90 runs on a mock whose results were small.

### Does a duplicate call double the cost?

Not always. In Codex code mode many repeats happen inside one code block, so the data enters the context once; they cost server time more than tokens. But in our runs, requests in runs with duplicates were larger on average (52k vs 44k tokens).

### How do I stop duplicate tool calls?

Make the first result enough: a small default, a summary line with counts and what's next, filters for the questions users ask, and a cursor for more. Keep results under the smallest output cap of the apps your users run.

**See where agents repeat calls on your server.**

We run your users' jobs through Claude Code, Codex and the other apps they use, flag every repeated call, and trace it to the result that caused it.

[Test your MCP →](/#contact)

## Keep reading

- Up[Tool results and errors for AI agents (guide)](/guides/tool-results-and-errors-for-agents/)
- Related[MCP output limits by agent: Claude Code, Codex, OpenCode and Grok Build compared](/blog/mcp-tool-output-limits-by-agent/)
- Related[How to reduce MCP tool response size: measured before and after](/blog/reduce-mcp-tool-response-size/)
- Related[How Codex finds MCP tools: code mode and ALL\_TOOLS](/blog/how-codex-finds-mcp-tools/)
