Skip to content
Drew Bredvick

Building the future of GTM with AI

← Back to posts

Agent best practice: let your agent flag bad context

By ··1 min read

Everyone knows that context is key to getting good output from agents. A few wrong pieces of information in your prompt and your agent will overly focus on it and maybe even spiral on it a bit.

Over the last two months, we've flagged over 500 bad context issues and triaged them to help improve our GTM agents.

All of this happens by adding a simple tool call to all of our agents + creating a Slack channel to keep things organized.

Build a Context Factory

Endless tasks are daunting for humans, but agents will persist and push that boulder up the hill so let's let them.

Your agents read every trace already and they're quite smart. They know when something smells off.

For minimal extra cost, flag your data issues to a Slack channel to root cause:

import { generateText, hasToolCall, stepCountIs, tool } from 'ai'
import { z } from 'zod'

const flagBadData = tool({
  description:
    'Call this if the data for this task is wrong',
  inputSchema: z.object({
    issue: z.string().describe('What is wrong'),
    evidence: z.string().describe('The records or values that show it'),
    suggestedFix: z.string().describe('What a human should change'),
  }),
  execute: async (flag) => postToSlack('#bad-data', flag),
})

const result = await generateText({
  model: 'anthropic/claude-opus-5.5',
  tools: { ...tools, flagBadData },
  stopWhen: [stepCountIs(20), hasToolCall('flagBadData')],
  prompt,
})

const flagged = result.toolCalls.some((call) => call.toolName === 'flagBadData')
if (!flagged) await postToSlack('#account-team', result.text)

When the agent calls flagBadData, the run stops and the summary never posts. The flag lands in #bad-data, where a person checks the evidence and fixes the source record (this is the part we'll turn into a full factory soon).

Continue reading

A few useful places to go next.

Drew Bredvick

The newsletter

Don’t miss the next one.

Field notes on GTM engineering and the craft of shipping software in the AI era — straight to your inbox.

No spam. Unsubscribe anytime.