When the Tool Result Does Not Come Back

You will understand why a successful tool call does not guarantee the model ever saw its result, where results get lost inside an agent loop, and how to make the loop fail loudly instead of answering confidently from a hole in its context.

Why This Matters

Imagine you are on-call for EngineerPrep's order agent. A loyalty customer was quoted the wrong price, and the agent was sure of it — it gave a confident, specific number with no hedging. You pull the trace. The lookupLoyaltyPrice tool call is right there. Status: success. The tool returned { "tier": "GOLD", "unitPrice": 49.00 } at 09:14:03. The customer was quoted $79.00 — the standard price, not the loyalty price. Your first instinct is reasonable: the tool returned the right answer, so the agent must have used it. That instinct is exactly what this lesson exists to correct. The tool result was lost somewhere between the tool returning it and the model's next turn. The model answered from what remained in context — and a context with a hole in it looks complete from the inside.…

The Simple Idea

An agent loop is just a cycle: the model thinks, decides to call a tool, the tool runs, the result comes back, and the model thinks again. Repeat until it has an answer. Think of it like a chef calling out to a prep cook. The chef says "what's the price for a gold-tier customer?" The prep cook looks it up and shouts back the answer. The chef then plates the dish. Now imagine the prep cook shouts the answer — but the kitchen is loud, and the chef never hears it. The chef doesn't know they missed anything. They just plate the dish from memory. That is the situation this lesson is about. There are two very different failure modes here, and mixing them up is the root of the confusion: Mode 1 — The tool failed. The tool threw an exception, timed out, or returned an error code. The loop can see this . There is something in the response to act on. Mode 2…

See It in Action

Picture the agent loop as a conveyor belt with four stations. Station 1 — The model turn. The model receives a context window (think of it as a tray holding all the messages so far). It decides to call lookupLoyaltyPrice . A tool-call message is placed on the tray. Station 2 — The tool runs. Somewhere outside the model — in your Spring service — the tool executes. It queries the database, finds GOLD tier, and produces a result: { "tier": "GOLD", "unitPrice": 49.00 } . The tool is done. Its job is finished. Status: success. Station 3 — Message assembly. Before the model can think again, someone has to build the next tray. This means taking every message from the previous tray, adding the tool result as a new message, and handing it to the model. This step is where things go wrong. There are several ways the result never makes it onto the tray: - The message assembler has a size budget .…