Topic 2 of 5 · 4 min read
Feeding the agent real evidence
Goal: Choose which logs, traces and diffs to give an agent for a bug, and strip secrets and personal data before sharing them.
Give the agent the raw evidence, not your summary of it, and remove secrets and personal data first. A paraphrase such as "it crashes on login" throws away the line number, the error type and the value that caused it. The agent fills the gap with a guess.
Check yourself · 1 of 3
Which input gives an agent the best chance of finding a crash?
Why it matters
Models cannot see your server, your browser or your terminal. They only see what you paste or let them read. Real evidence narrows the search from the whole codebase to a few lines. A trimmed or reworded trace sends the agent to the wrong file, and it will still sound sure.
What to collect
- The full stack trace, from the first error to the last frame. The root cause is often the line at the bottom, under "Caused by".
- The exact input that triggers it: the request body, the file, the command with its flags.
- A log window around the failure: a few dozen lines before and after, with timestamps. Not the whole day.
- The environment: runtime and OS version, the lockfile or the key package versions, relevant config flags.
- What changed: the last deploy, the recent diff, or
git logfor the files in the trace. - What you already tried, and what happened. This stops the agent from repeating it.
Let the agent gather some of this itself. Ask it to run the failing command and read the output, rather than relaying it by hand.
Clean it first
Logs and traces carry tokens, cookies, API keys, emails and customer names. Replace each with a placeholder such as <TOKEN> or user-123 before pasting into any hosted tool. The OWASP logging guidance lists data that should never be logged at all. If it is in your log, treat it as unsafe to paste.
Before and after
Weak:
Checkout throws a 500 for some users. Can you look?
Better:
POST /api/checkout returns 500 since the 14:05 deploy. Trace below.
Request body (card and email redacted) below. Node 22, prisma 6.
Last change to the file in the trace: commit a41c9e2.
Tried: restarting the worker, no change.
What goes wrong
- Pasting only the last line of a trace, so the cause is cut off.
- Pasting a day of logs, so the useful lines drown.
- Pasting secrets into a hosted chat, where they may be stored or reused.
- Describing the error from memory, which moves one word and changes the meaning.
Examples
The cut-off trace
TypeError: Cannot read properties of undefined (reading 'id')
at mapOrder (src/orders/map.ts:41:22)
at async checkout (src/api/checkout.ts:88:5)
Caused by: PrismaClientKnownRequestError: P2002 Unique constraint failed
If you paste only the first line, the agent looks at mapOrder. The last line shows a database constraint failed first, and the undefined is only the aftermath.
Redacting a log line
Before: POST /login email=ana.lopez@example.com token=sk_live_9f2...
After: POST /login email=<EMAIL> token=<TOKEN>
The shape of the line is kept, so the agent can still read it, and nothing private leaves your machine.
Key points
- Paste raw traces and inputs, not a summary of them.
- Include the whole stack trace, since the root cause is often at the bottom.
- Give a short log window around the failure rather than a whole day.
- State the environment, the recent change and what you already tried.
- Redact tokens, keys and personal data before sharing anything with a hosted tool.
Common mistakes
- Summarising the error in your own words.
- Pasting unredacted production logs into a chat tool.
- Sending the whole log file when only one request matters.
- Leaving out the version or the recent deploy that changed behaviour.
Check yourself · 2 of 3
You are about to paste a production log into a hosted AI chat. What do you do first?
Check yourself · 3 of 3
Why include 'what I already tried' in a bug prompt?
Practice items, not counted towards your mastery.
Start here
- Git Tools: Debugging with Git (Pro Git) (opens in a new tab)BookFree
File annotation and binary search with git bisect, explained step by step.
- git-bisect documentation (opens in a new tab)DocsFree
The full reference for bisect run, exit codes, skip and reset.
- Common workflows (Claude Code docs) (opens in a new tab)DocsFree
Shows how to hand an agent an error and ask for a fix with a verified result.
More for this topic
- Logging Cheat Sheet (OWASP) (opens in a new tab)ArticleFree
Which data must never reach a log: passwords, tokens and personal data.
- What went wrong? Troubleshooting JavaScript (MDN) (opens in a new tab)ArticleFree
How to read error messages and locate the failing line.