Our Sales Agent Gave a Different Pipeline Total Every Day. Here's How We Fixed It.
Our sales team has a colleague called Sally. She lives in Slack, and she knows our CRM. Ask her about a deal, a lead, last week’s meetings, or the pipeline for a market segment, and she answers. Every morning she posts a sales update. She keeps the CRM tidy, transcribes meeting recordings, and writes reports.
Sally is an AI agent. This autumn, we rebuilt her from scratch on Agent Barn, and the reason we did is a little embarrassing.
Before the rebuild, we went back through her real conversations with the sales team. The problems were hard to miss. Ask her for the total value of a pipeline on Monday, and then again on Tuesday, and the two numbers could differ by hundreds of thousands of euros. Ask her for everything about a market segment, and she’d quietly miss whole groups of deals. Reports took ages. And once, asked to clean something up, she started deleting contacts instead of closing deals.
None of this was because the model was bad. It was because we’d asked the model to do jobs it isn’t built for. Here’s what we changed, and what we’d tell anyone building an agent that works with real business data.
Lesson 1: Let scripts count. Let the model write.
The shifting pipeline total had a simple cause. To answer the question, the old Sally paged through the CRM’s records herself and added up the values as she went. Some days she paged a little differently. Some days a list command quietly stopped at 50 records and she didn’t notice. Every day she did the arithmetic in her head.
Language models are very good at understanding a question and writing a clear answer. They’re not good at walking through thousands of records the same way every time and adding up the numbers. We were asking a writer to be an accountant.
So we split the job. In the new Sally, every count, total, filter, and download happens in a script, which is ordinary code that does the same thing every time. The model’s job is to pick the right command, read what it prints, and write the answer for the person who asked. Numbers never come from the model’s own arithmetic.
That one decision fixed most of the “different answer every day” problems. It also matches what model makers recommend. Anthropic’s guide to building tools for agents describes them as a contract between deterministic systems and non-deterministic agents. The deterministic side should do the deterministic work.
Lesson 2: Speed is about steps, not tokens
The old Sally handled one record per model turn. A report could take hundreds of turns. It’s tempting to think a faster model would fix that. It wouldn’t.
When we measured, we found that an agent’s speed is dominated by how many steps it takes, not by how fast the model writes. Every step, where the model decides what to do, calls a tool, and reads the result, costs several seconds. A report built from many small steps is slow no matter how fast each one is.
So we gave each common request a single command that does everything: refresh the data, work out what’s in scope, gather the material, and print exactly what the model needs. Small results are printed in full, so the model doesn’t have to go and open files. We also gave Sally a local copy of the CRM that refreshes only what has changed, so most questions are answered in seconds from a consistent snapshot instead of hundreds of live API calls.
The effect was dramatic. A report on one market segment went from 17 model steps and 167 seconds to 4 steps.
Anthropic gives similar advice: tools that consolidate several discrete operations into one tend to serve agents better than many small tools that mirror an API. We also found a useful warning sign. When the agent starts reading a script’s source code or raw data files, that request is missing a one-command path. We relearned that rule more than once.
Lesson 3: Be complete by default, and say what you covered
The missing deals had a quieter cause. In our CRM, a market segment lives in three places: deal labels, the company’s industry field, and a campaign field. The old Sally searched by keyword, which saw none of them reliably. So when someone asked about a segment, she found some deals and confidently reported on those.
Real data is full of traps like this. In testing the new version, a product name got searched as a company name and returned 46 leads and no deals, because the product mostly lives as a deal label. Leads turned out to use different labels from deals. “Since January” and “created this year” sound similar but mean different things. And asking which deals had a meeting couldn’t be answered from the deal stage alone, because the team often logs meetings as activities and notes without moving the stage.
We fixed each case in the scripts, and adopted two rules. First, “everything about X” means everything: every status, every pipeline, archived records included. Second, every answer opens by stating its scope, for example “Found N deals and M leads in…”, so a missing piece is visible immediately. The scripts also flag labels and values that look related but fall outside the definition, so Sally asks about them instead of guessing.
One more thing we learned the hard way. Some knowledge belongs to the team, not the agent: which labels make up a segment, who is who in Slack. We first hard-coded our segments into Sally’s skill, and the first new segment simply failed. Now the team teaches Sally these definitions through small commands, and they’re saved where they survive restarts and updates.
Lesson 4: Every “can’t” needs a proper way
This was the most surprising lesson. When Sally’s skill had no proper way to do something, she rarely said “I can’t”. She found an improper way instead.
Asked for a PDF before she had a PDF tool, she wrote raw PDF commands by hand, and every Lithuanian letter came out as a question mark. Asked for a large report, she wrote her own little programs to produce it, which pasted the first sentence of each email in as a “summary”. Asked to find contact emails, she ran web searches and typed the addresses she found into a spreadsheet.
Each time, the model was trying to be helpful. Each time, the result looked plausible and was wrong in ways that took effort to spot.
Our conclusion: an honest “can’t” in the instructions doesn’t hold once the model finds a workaround. Telling an agent what not to do is weaker than giving it the right way to do it. So Sally now has a proper PDF tool, a contacts command that uses a real data provider, and a report process in which she reads each company’s material and writes the analysis in her own words, while a script assembles the final file. Where we can’t offer a proper way yet, the instructions name the specific workaround to avoid, rather than just saying no.
Lesson 5: Put the guardrails in code, not in the instructions
Remember the deleted contacts? The old Sally guessed at CRM changes, and nothing stopped a guess from becoming a deletion. You can write instructions telling an agent to be careful, and they’ll be followed most of the time. Most of the time isn’t good enough when the action is deleting customer records.
So the new Sally’s guardrails live in code:
- Every CRM change starts as a plan. Sally shows the before and after values, and the change is applied only after an explicit yes from the person who asked.
- There is no delete. “Remove” or “clean up” means marking deals as lost and archiving leads, which keeps the history. The delete path simply doesn’t exist, so no instruction can be misread into using it.
- Paid lookups are capped. Each contact lookup costs a credit, so the script skips people who already have an email, caches every result so nobody is paid for twice, refuses more than ten paid lookups without a confirmed count, and allows only one run at a time.
- Sally never sees API keys. Integrations go through the platform’s connections, which add the credentials on the way out. If someone pastes a key into the chat, her instructions tell her not to handle it.
The principle we kept coming back to: an instruction like “ask before spending” is followed most of the time. A script that refuses is followed every time.
This is also the security community’s advice. OWASP’s guidance on agents with too much power recommends enforcing authorization in downstream systems rather than relying on the model to decide whether an action is allowed, and requiring a human to approve high-impact actions. Sally’s plan-then-approve flow and missing delete button are that advice, applied to a sales CRM.
What we’d tell anyone building an agent
None of these lessons is about finding a smarter model. We did benchmark 18 models before choosing Sally’s, and model choice matters at the margins. But the changes that made Sally trustworthy were all about the work around the model:
- Let scripts do the counting, and the model do the writing.
- Give each common request one command, because speed is about steps.
- Be complete by default, and open every answer with its scope.
- Give every “can’t” a proper way, or the model will invent an improper one.
- Put guardrails in code, where they hold every time.
Today Sally runs on Agent Barn, our own platform, built from a template that defines who she is and a skill that holds the scripts that do the work. Every lesson above is now part of how we build agents for customers too.
If you’re planning an agent that needs to work with real business data and get the numbers right, tell us about one workflow worth automating.