LLM Inference Interview Questions #14 - The Context Poisoning Trap
Why leaving failed tool calls in your prompt silently builds a degenerate attractor, and how pruning the transcript saves your agent from endless failure loops.
You’re in a Senior AI Engineer interview at Anthropic and the interviewer asks:
“Your agent calls a broken file-editing tool 11 times in a row with the same malformed params. You add ‘if a tool fails, note it and try another approach.’ Failure detection improves. Task success doesn’t. Why?”
Don’t say: “The model needs better error handling in the prompt.” Too vague. That’s the thing you already tried.
Don’t say: “Retry with exponential backoff.” You’re retrying a malformed argument. Backoff doesn’t fix a schema mismatch, it just fails slower.
Here’s what’s actually happening.
Detection is classification. Recovery is planning. You solved the easy one and assumed the hard one came free.
Three failure modes underneath it:
Your error messages have no affordance.
Error: edit failedtells the model that it failed, not what to change. A good error is a repair instruction: which field, expected type, one valid example. Errors are context, not logs. Write them for the consumer, and your consumer is a token predictor.The context window is poisoning itself. Eleven identical failed calls aren’t eleven warnings. They’re eleven in-context examples of what to do next. Autoregressive models complete the dominant pattern. You built a degenerate attractor and then politely asked it to stop.
There’s no alternative in the action space. “Try another approach” is meaningless if no other approach exists. Awareness without a fallback policy is just a narrated failure.
The fix is harness-level, not prompt-level:
→ Circuit breaker: N identical failures forces a hard replan, not another attempt
→ Validate against schema before execution, return a repair hint
→ Prune failed attempts from context; keep the lesson, drop the transcript
→ Define explicit tool substitutions so “another approach” is a real edge in the graph
The answer that gets you hired: Models are good at noticing failure and bad at escaping it, recovery isn’t a reasoning capability you prompt for, it’s a control loop you build. If your only fallback is the model’s judgment, you don’t have a fallback.
#AIEngineering #LLM #AIAgents #MachineLearning #MLOps #SystemDesign #AIInterview



📚 Related Papers:
- Large Language Models Cannot Self-Correct Reasoning Yet. Available at: https://arxiv.org/abs/2310.01798
- Where LLM Agents Fail and How They can Learn From Failures. https://arxiv.org/abs/2509.25370
- SPECRA: Monitor Degenerative Repetition in LLM Agents Using Randomized FFT. Available at: https://openreview.net/forum?id=xVO4BqmzVD
- ToolFailBench: Diagnosing Tool-Use Failures in LLM Agents. Available at: https://arxiv.org/abs/2607.04686