cd /news/ai-agents/dont-trust-the-answer-trust-the-log-… · home › topics › ai-agents › article
[ARTICLE · art-151926] src=dev.to ↗ pub= topic=ai-agents verified=true sentiment=↑ positive

Don’t Trust the Answer, Trust the Log: Lessons from Building an AI Expense Auditor

An intern at Valentius Kryptix built ExpenseBot, a LangGraph-based AI expense auditing agent with policy search, currency conversion and a sandboxed calculator tool, and tested it against 12 pre-written claims with expected results. The agent scored 10 to 11 out of 12 across runs, and the failures traced to tool design rather than prompting: a keyword search scoring bug caused a taxi claim to be denied, and a smaller model produced correct totals without calling the calculator, which was counted as a failure. The developer recommends reading tool-call logs before rewriting prompts and treating model output as untrusted input.

by read3 min views1 publishedOct 17, 2026

canonical_url:https://valentiuskryptix.com/3-surprising-failures-from-testing-my-ai-auditing-agent/ A chatbot answers questions. An agent is different: it is given a goal and a toolbox, then decides for itself which tool to call, what to pass in, and when to stop. For my “Agentic AI Workflow” milestone during an internship at Valentius Kryptix, I built one, and I set myself a harder requirement than “it works.” I had to prove it.

The project

ExpenseBot reviews employee expense claims against an invented company policy. It is written in Python with LangGraph and has three tools: a policy search, a currency converter with fixed rates, and a calculator. The calculator parses expressions into a syntax tree and allows only numbers and basic operators, instead of using eval, because model output feeding into code should be treated as untrusted input.

A system prompt acts as the agent’s job description: look up the rule, convert foreign currency, do all arithmetic through the calculator, and if no policy matches, say so and refer the user to Finance instead of inventing a rule.

Take three hotel nights at 200 euros each. The agent finds the $250 international cap, converts to $216 per night, sees it is under the cap, calculates 648, and approves the claim. Every number comes from a tool call, so it can be traced in the log.

How I tested it

I wrote 12 test claims with expected results before running anything. A test passed only if the final answer was correct and the agent had used the tools that answer depends on.

Three lessons from failures

The bug was in the tools, not the prompt. A taxi claim was told no policy existed. My instinct was to rewrite the prompt, but the log showed my search scoring treated “domestic” as important as “taxi,” so three rules tied and the taxi rule lost. Fixing the search fixed the problem.

A right answer can hide a wrong process. A smaller model returned correct totals but did the multiplication itself instead of calling the calculator. I counted those as failures. A system that sometimes guesses right is not one that computes.

The plumbing matters too. Rate-limit errors were being recorded as test failures, so I made the script save progress and resume later. GitHub also blocked a push because of a real API key in a template file, a good reminder to rotate any exposed credential, not just hide it.

What the numbers say

The agent scored 10 to 11 out of 12 depending on the run. Those scores shift even at temperature zero, so I treat them as a rough range. Twelve cases are enough to find bugs, not to claim general reliability. The prototype also uses keyword search, invented policy data, and handles one claim at a time, so embedding-based search and multi-expense claims are my next steps.

Takeaway

Read the tool-call log before touching the prompt, test the process as well as the output, and report your results with the failures and limits included.

👉 **Read the full article:** [3 Surprising Failures from Testing My AI Auditing Agent](https://valentiuskryptix.com/3-surprising-failures-from-testing-my-ai-auditing-agent/)

Code and test cases: [https://github.com/Yogendra404/expense-agent](https://github.com/Yogendra404/expense-agent)
── more in #ai-agents 4 stories · sorted by recency
── more on @valentius kryptix 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/dont-trust-the-answe…] indexed:0 read:3min 2026-10-17 · —