Skip to content
mentoor

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?

Choose one answer

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

  1. 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".
  2. The exact input that triggers it: the request body, the file, the command with its flags.
  3. A log window around the failure: a few dozen lines before and after, with timestamps. Not the whole day.
  4. The environment: runtime and OS version, the lockfile or the key package versions, relevant config flags.
  5. What changed: the last deploy, the recent diff, or git log for the files in the trace.
  6. 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?

Choose one answer

Check yourself · 3 of 3

Why include 'what I already tried' in a bug prompt?

Choose one answer

Practice items, not counted towards your mastery.

Start here

More for this topic