Skip to content

Agents Don't Fail at the Model Layer

#ai-agents #mcp #agent-memory #llm-tool-calling #ai-adoption #context-management

A tool call can resolve, return a result, write a completed span to your trace, and pass the test suite while having done nothing at all. The MCP spec allows a perfectly well-formed result to carry isError: true. Your promise wrapper resolves because it has no reason not to. Your assertion checks that nothing threw. Green across the board.

That gap is where agents actually break in production. Not in the reasoning, in the plumbing around it.

Three failure modes keep showing up: what the agent remembers between turns, what a tool result actually means, and whether anyone else on the team can pick the workflow up after the person who built it goes on holiday. Each one is cheap to fix once you stop treating it as a model problem.

A resolved promise is not a completed action ​

MCP separates protocol-level errors from errors reported inside a tool result. A valid result can carry isError: true plus a human-readable explanation of why the tool declined. The transport is fine. The operation did not happen.

There are three separate questions hiding inside the word "success", and they need three separate answers.

QuestionEvidenceWhat it does not establish
Did the call return?Promise resolution or protocol responseThat the tool accepted the operation
Did the tool report failure?isError on the MCP resultThe final state of an external system
Did the intended effect occur?Independently observed state or receiptThat every earlier execution step was correct

A fourth case showed up in the discussion threads and it's worth adding to your fixtures: the call returns, isError is false, and the content is empty. A web fetch against a JavaScript shell pages returns a clean 200 with nothing in the body. That isn't a failure and it isn't a success. Retrying it is pure waste. The right move is a different tool.

Here's the trap in concrete form. Two contracts against the same trace file:

js
const completionOnly = evaluateTraceContractRead(trace, defineTraceContract({
  run: { requireCompleted: true },
}));

const withOutcomes = evaluateTraceContractRead(trace, defineTraceContract({
  run: { requireCompleted: true },
  observations: { failOn: ["failed"] },
}));

The first returns pass. The second returns fail. Same run, same evidence, two different questions. If your whole test suite looks like the first one, you have no idea whether your agent booked anything.

The full decision tree looks like this:

Instrumentation records evidence. It doesn't pick the recovery policy. That part stays in your application, where you know whether the side effect is a bank transfer or a log line.

Stop turning tool errors into retries ​

isError is not a retryability classification. A malformed argument, a denied permission, a missing resource, and a transient dependency failure all produce unsuccessful tool results. Retrying the first three adds work and burns tokens. Retrying a write after an ambiguous response duplicates the effect, which is how you charge someone twice.

I've watched this go wrong in the least dramatic way possible. An agent's create-ticket call timed out. The wrapper threw. The retry logic caught it and fired again. Two tickets. The trace showed two completed spans, both correct, and nobody noticed until the on-call queue doubled.

The rule I've settled on: if a write result isn't clearly an error, treat it as unknown. Read the object back before acting on it. Never retry a write without an idempotency key until that read shows it didn't land.

Reading back is cheap for updates. It falls apart for creates, because a create has no id to read by. Then "read it back" turns into listing recent objects and matching on content and timestamp, which is a guess wearing a read-back costume. When that happens, don't retry. Hand it to a person. The actual fix belongs on the server: a create that would otherwise make a second object should accept a caller-supplied idempotency key.

A survey of 100 popular packaged MCP servers, read from source, shows how far away that is. 44 return a machine-readable success or failure. 7 return a machine-readable unknown. 15 accept an idempotency key on create, and only 2 of those 15 can also say "unknown". Developer tools are the biggest category at 28 servers, and exactly 1 of them takes a key. The most likely reason is that most of those wrap someone else's API, and if the underlying API takes no key there's nothing to pass through.

If you're stuck with a prose-only server today, don't parse the error text into a policy decision. The word "timeout" in a message tells you nothing about whether the write landed. Preserve the uncertainty and act on it.

Memory is not retrieval ​

The test that separates these two jobs is three sentences long. A user says "I'm in New York." Later they say "I moved to San Francisco." Then they ask "Where do I live now?"

OptionWhat the model getsTradeoff
Flat promptingFull chat historyTrivial to build, tokens grow every turn
Vector RAGEvery matching chunk, old and newSaves tokens, retrieval has no idea which fact is current
Knowledge graphThe current factTracks change, you build the extraction, schema and update logic
Managed memory layerThe current factExtracts, dedupes and updates in the background, less control

A vector store returns both chunks. The ranker has no concept of which one stopped being true. RAG is still the right tool for searching a knowledge base. Keeping facts about a user current is a different job.

Quick Take: Your agent doesn't have a memory problem, it has a recency problem, and a vector index can't solve it because similarity ranking has no opinion about time.

The three-sentence test only checks one thing: that the newest value wins. Two more lines catch the stores that pass it for the wrong reason. Ask "Where did I live before San Francisco?" A store that overwrote the fact has nothing to say. One that kept both facts, with the date the first stopped being true, answers New York. Then say "I'm moving to Seattle in March" and ask where they live now. An updater that treats the latest statement as the current fact answers Seattle, three months early.

That second line is the one most memory systems fail. Stated-at and true-at are different timestamps, and a system that conflates them will confidently report a future address as the present one.

The token math of remembering everything ​

Scribant is a voice-to-action agent built in TypeScript with Google's ADK. It gets new transcript text every two seconds, so resending the full conversation compounds quickly. Three fixes were applied at three time scales: a 40-word rolling window for the intent classifier (this turn), a running summary (this session), and an extracted-facts store (across sessions).

The 40-word classifier window measured about 86% fewer tokens than streaming the whole speech input. The rolling summary came out at 92 tokens. The extracted-fact store held roughly 24 tokens, against about 1,400 to ingest the whole conversation.

That last comparison is the one that changes your bill. Resending 1,400 tokens of transcript on every turn of a 20-turn session is 28,000 input tokens. The memory layer ships 24. The ratio is the whole argument for separating facts from conversation.

One caution on the 40-word window: the number that matters isn't how many tokens you saved, it's how many intents you now misclassify because the user's intent started earlier in the sentence than the window. Log every low-confidence call next to the full transcript and tune the window on real misses, not on a guess. Same for the summary: summaries quietly drop corrections. "Actually I moved" is exactly the sentence that disappears when you compress. Check whether your summary and your fact store ever disagree about the current value.

The small decisions don't need a paragraph ​

Look at what an agent loop actually asks a model between planning steps. Which skill should handle this? Is this command safe? Is that tool result relevant? Is the agent done? Every one of those is a bounded judgment from a fixed menu, and the standard answer was to call a frontier model and parse whatever came back.

TypeSafe's Jev, released in September 2026, takes typed questions and returns only values from the options you declared. No free text, so no malformed responses. It can still be wrong. Every launch since then made a different bet on how to get there.

JevClef / Clef-flashOpenAI DecisionsGemini Decision 1Microsoft Decision-1
Price per 1M input tokens$0.042$0.24 / $0.09$0.10$0.10$0.042
Reported latency70-500 ms38.8 ms median (flash)~150-180 ms150-250 ms85 ms median
Open weightsNoApache 2.0NoNoNo
Inputstext, JSON, imagestext, imagestext, images, JSONtext, audio, video, PDFtext, JSON

Key numbers

  • $0.042 per million input tokens: the cheapest typed-decision APIs at launch, from Jev and Microsoft Decision-1. At roughly 200 tokens per call, a million routing decisions is about $8.40.
  • 92 ms vs 211 ms: per-task latency for Jev and Gemini Decision 1 in the Artificial Analysis run, where both scored 66 on its Decision Index.
  • 86%: fewer classifier tokens from a 40-word rolling window.
  • 24 vs ~1,400: tokens of stored facts against tokens to ingest the whole conversation.
  • 44 of 100: packaged MCP servers returning a machine-readable success or failure.
  • 15 of 100: packaged MCP servers accepting an idempotency key on create.

The vendor numbers deserve scrutiny. The headline "193.6x faster, 444.6x cheaper" comes from four workflows TypeSafe built itself. Independent tracking is tighter, and one viral demo didn't survive being measured. Read the multipliers as a hypothesis about your workload, not a result.

Where the category is genuinely interesting is latency at volume. If your harness makes twelve bounded decisions per turn, a 120 ms difference per call is 1.4 seconds of latency you didn't have before. That's the difference between an agent that feels responsive and one that feels like it's thinking hard about whether to check the weather.

Adoption is a factory problem ​

Getting one person productive with AI is trivial now. Getting a whole team to use it every day is a different problem, and the model is rarely what's in the way.

The analogy that stuck with me: a humanoid robot isn't the best robot for any single job. A purpose-built arm welds better and a robot vacuum cleans better. It wins because the world is built for humans. Your team's working world is chat channels, threads and docs. Tools that ask everyone to move into one more window lose to tools that show up where the work already lives.

Three things separate a team that adopts from a team with two power users and a lot of unused seats.

The first is visibility. Work that happens in private terminals and personal chats teaches nobody anything. Work that happens in a shared thread shows the prompt, the result, and the correction. People copy what they can see a teammate doing, faster than any documentation.

The second is security that isn't homework. The default rollout asks less technical colleagues to manage their own secrets. API keys pasted into .env files on every laptop. MCP servers running on localhost, one setup per person. Auth that breaks quietly and needs an engineer to fix it. None of that scales past five people. Secrets entered once through a secure form, credentials used at runtime without the agent ever seeing the values, integrations connected centrally with nothing running on anyone's laptop. That's the version that survives contact with a 40-person team.

The third is the move from experiment to rule. When something works, make it deterministic: a script, a check, a scheduled job. An experiment that stays a prompt is also a control nobody can audit. Once it's a scheduled job you can ask when it last ran and get an answer.

Common Pitfalls ​

Asserting on resolution instead of effect. If your agent test only checks that a promise resolved, add one fixture where the tool explicitly refuses the request. If the run still looks successful, your missing assertion was never about the final sentence. Check captured calls against an independently counted server handler too.

Treating isError as a retry signal. A denied permission and a transient failure produce the same boolean. Retry the wrong one and you add load to a service that's already telling you no.

Parsing error prose into policy. The word "timeout" appearing in a result tells you nothing about whether the write landed. If your server doesn't expose reviewed structured error categories, preserve the uncertainty instead of guessing.

Putting a vector store where a memory layer belongs. Retrieval gives you the old fact and the new one with equal confidence. If a user corrects themselves, similarity ranking has no mechanism to prefer the correction.

Wrapping a prompt in a cron job without pinning the model. A script around an LLM is only as deterministic as the model version behind it. The day the provider ships a new default, your "resilient" job changes behavior and nobody owns the regression. Pin the model and add a golden-set check that fails loudly.

What the Community Is Saying ​

When I ran the read-back rule against a handful of prose-only MCP servers, it settled the question more often than I expected. Not always. A create that takes nothing searchable from the caller (a comment with no title, an event stamped by the server, an upload that gets a server-generated name) leaves you matching on content and timestamp, and that's a guess. We stopped retrying those and routed them to a human queue. Slower, and nobody has been double-charged since.

The shared-channel advice has a cost nobody mentions in the original post. Within two weeks, our team channel had a prompt monoculture. The one prompt that worked once got copy-pasted by everyone, including a correction that happened to be wrong. Visibility spreads mistakes at the same speed as wins. What needs to be visible is the evaluation, the thing the output was checked against, not just the prompt and the result.

The compliance version of this is harder. If you handle payments data, the prompts with real leverage are the ones containing a customer record or a transaction, and those cannot go in a shared channel. The version that survived our review was the prompt with the data removed, plus the tool that fetches the data at runtime. People learn the shape without the payload moving. It's more work than pasting a thread and it's the only version that holds up.

One Thing to Remember ​

Every green result should name the boundary it actually exercised. A passing test that means "the promise resolved" is not the same artifact as a passing test that means "the record exists in the booking system", and the first one will lie to you at exactly the moment you can least afford it.

The Bottom Line ​

If your agent takes real-world actions, add an outcome assertion before you add another tool. One fixture where the server refuses the request, one contract that fails on a captured failed observation, and a read-back step for any write that isn't clearly an error. That's an afternoon of work against a class of bug that otherwise surfaces as a duplicate charge three weeks later.

If your prompts carry user facts across sessions, drop the vector store for that job and use something that tracks which fact is current. RAG stays for knowledge bases. For a user's city, plan or preference, a store that keeps the old value with an end date beats an index that returns both and hopes. If you can't build that, use a managed memory layer and check whether it handles the future-dated case.

If you're rolling agents out to a team of more than five, spend your effort on central credentials and shared threads, not on benchmark scores. A frontier model behind a per-person .env file gets abandoned in a month. A slightly worse model behind a centrally connected workspace gets used daily by people who never touch an API key. Watch the decision-model space, though. At $0.042 per million input tokens and sub-100 ms latency, moving the bounded judgments out of the frontier model is starting to be an easy call.