---
title: "Never Ask Your Agent What It Did: Lessons From Debugging Our Sales Agent"
canonical: "https://agentbarn.dev/blog/never-ask-your-agent-what-it-did"
author: Gaurav
description: "Our sales agent's own explanations kept pointing us the wrong way. What we learned about debugging agents: read the record, not the agent."
categories: [Blog, AI agents, Debugging, Agent Barn, Sales]
---

# Never Ask Your Agent What It Did: Lessons From Debugging Our Sales Agent

More than once, someone on our sales team asked Sally, our sales agent in Slack, for a report. She replied that this session had no way to run the report. Another time she said she was blocked from running scripts.

That sounds like a permissions problem. It looks like a permissions problem. So the natural instinct is to go check permissions. But permissions weren't the problem.

What had actually happened was that Sally had run out of memory. Her runtime killed the run and then resumed the conversation in a recovery mode, with fewer tools and no ability to run commands at all. From inside that mode, "I'm blocked from running scripts" was a perfectly accurate description of her situation. It was a terrible description of the problem.

We rebuilt Sally on Agent Barn this autumn, and moments like that one taught us the most important habit in debugging agents. When something goes wrong, **don't ask the agent what happened. Check the record.** Here's why, and what else we learned along the way.

## Agents are unreliable narrators of themselves

The recovery-mode message wasn't a one-off. Again and again, the least reliable source of information about Sally was Sally.

Asked about her own configuration, she summarized it from memory, and got it wrong. Asked to change how her morning briefing worked, she edited her own copy of the script, said "done", and carried on. The change looked real. But her skill files are replaced from the published version every time she restarts, so the edit vanished on the next restart. It had never been tested or reviewed, either.

None of this was dishonesty in any human sense. The agent was describing what it believed, from inside a narrow view of its own situation. But the effect on anyone debugging it is the same: the agent's account can't be the evidence.

This isn't unique to us. In October, OpenAI reported that one of its own internal coding agents had removed a safety monitor while making a requested change, and [when an engineer asked directly whether it had removed the monitor, it said no](https://bleepingcomputer.com/news/security/openai-agents-disabled-safety-monitoring-one-lied-about-it). If the most capable labs can't take their agents' self-reports at face value, neither can the rest of us.

So our first rule became: **read the transcript, not the agent's account of it.** The record of each run, with its replies, tool calls, and run events, explains most misbehaving turns faster than any conversation with the agent. And when the question is about configuration, check the real configuration.

## The instructions she never read

The second lesson was stranger. After one of our changes, Sally started ignoring rules she had followed before, including her rules for CRM changes and her firmest red lines. She began improvising. Nothing in the logs said why.

The cause turned out to be length. Sally's core instructions live in a file the agent runtime loads with every message, and that runtime has a limit: about 20,000 characters. Above that, it keeps roughly the first 45% and the last 15% of the file, and only a digest of selected lines from the middle. Our platform also adds its own sections to the end, describing integrations, file sending, and scheduled runs. For Sally that added about 4,700 characters, and the block grows every time a new connection is added.

One change pushed the total over the line. The rules sitting in the middle of the file, which happened to be the most important ones, were reduced to fragments. Sally hadn't decided to ignore them. In a real sense, she never received them.

There's a well-known research finding that rhymes with this. Researchers at Stanford and elsewhere showed in 2023 that language models perform best when the information they need is [at the beginning or end of their input, and significantly worse when it's in the middle](https://arxiv.org/abs/2307.03172) of a long context. Our problem was a hard cutoff rather than a model weakness, but the lesson is the same: the middle of a long set of instructions is the most fragile place to put something important.

What we changed:

- **We budget the instructions at about 15,000 characters**, well below the limit, to leave room for what the platform adds.
- **We measure the rendered file on the running agent**, not the template we wrote, since that's what the model actually sees.
- **Sally's tests now fail** if her instructions grow past the budget.

Moving rules into separate files isn't free either. Every file the model has to open is an extra step of several seconds. So the core file keeps what applies to every message, plus a short routing table that tells Sally which command to run for each common request. Detailed, task-specific guidance lives in separate recipes, opened only when needed.

## The fixes that never arrived

The third category of problem was the most humbling, because it wasn't the agent's fault at all.

One test failed in a way that made no sense. We had published a fix, and Sally still behaved the old way. After some digging, we found the reason: she was still running a version of her skill from five days earlier. An agent keeps the versions it was started with. Publishing a new version changes nothing until the agent restarts.

Variations of this kept catching us:

- **Publishing isn't deploying.** After every change, restart the agent, then check which versions it's actually running.
- **Some files belong to the agent, not the template.** On our platform, one of the instruction files is treated as the agent's own and kept across restarts and template switches. Rules we put there never reached agents that already existed.
- **Old conversations carry old behavior.** A long Slack thread holds the history of what the agent did before, and the agent tends to repeat it. After any change, **test in a fresh thread**.
- **Rolling back means publishing forward.** Versions can't always be deleted, so the way to undo a change is to publish the old content as a new version.

It's easy to blame the model when an agent ignores a fix. More often than we expected, the model never saw the fix.

## What the symptom said, and what it meant

By the end of the rebuild, we had a list of symptoms that reliably pointed somewhere other than where they seemed to. It's the cheat sheet we wish we'd had on day one.

| What you see | What it usually means |
| --- | --- |
| "I'm blocked from running scripts" | The run was killed, often for lack of memory, and resumed in a recovery mode that can't run commands |
| "No reply was generated" in Slack | An edit that changed nothing ended the agent's turn silently |
| A command "hangs" and the agent gives up | Long commands move to the background after about ten seconds, and the agent didn't check back on it |
| The agent ignores a rule it followed before | The rule was cut from instructions that grew past the size limit |
| A published change isn't in effect | The agent wasn't restarted, or is pinned to an older version |
| The agent says it changed its own behavior | It edited a copy that will be lost on restart, and nobody tested it |
| A simple question takes over a minute | Too many steps; the agent is reading scripts or raw data instead of running one command |

Notice what almost every row has in common. The agent's own words point you in the wrong direction, and the real answer is in the record: the transcript, the run's events, the version it's running, the size of the file it actually loaded.

## Three habits worth keeping

If we had to compress everything Sally taught us about debugging agents into three habits, they'd be these:

1. **Read the record, not the agent's account.** The transcript of what the agent actually did beats anything it tells you about what it did.
2. **Check what the agent actually received.** The instructions it loaded, at the size it loaded them, from the version it's actually running.
3. **Test every change in a fresh start.** Restart after publishing, and test in a new thread, so old history doesn't mask new behavior.

These habits are also why we care so much about records in [Agent Barn](https://agentbarn.dev/), the platform Sally now runs on. Every conversation and tool call is recorded by the platform itself, each agent's template and skill versions are visible, and the whole thing is [open source](https://github.com/aai-labs/agent-barn), so you can see exactly what gets logged. When an agent tells you it's blocked, you shouldn't have to take its word for it.

If you're running agents and spending more time arguing with them than fixing them, [tell us about one workflow worth automating](https://agentbarn.dev/).

## Sources
- [BleepingComputer: OpenAI agents disabled safety monitoring, one lied about it](https://bleepingcomputer.com/news/security/openai-agents-disabled-safety-monitoring-one-lied-about-it)
- [Lost in the Middle: How Language Models Use Long Contexts (arXiv)](https://arxiv.org/abs/2307.03172)
