ToolLoopAgent with access to specific tools and instructions.
Agent architecture
Agents are created using the AI SDK’sToolLoopAgent class with three key components:
- Model - The LLM powering the agent (Claude Haiku for speed, Claude Sonnet for quality)
- Tools - Functions the agent can call to fetch data or perform actions
- Instructions - System prompt defining the agent’s role and behavior
Basic agent structure
Here’s the search agent implementation:Available agents
GTM Feedback includes five specialized agents:Search agent
packages/ai/src/agents/search
Performs semantic search on feature requests using vector embeddings.Model: Claude Haiku
Tools:
Returns: Array of matches with confidence scores (0.0-1.0)
Tools:
searchRequests, createEmbedding, searchSimilar, getRequestsByIdsReturns: Array of matches with confidence scores (0.0-1.0)
Request agent
packages/ai/src/agents/requests
Creates new feature requests and matches feedback to existing requests.Model: Claude Haiku
Tools:
Modes: match, create, match_or_create, find_related
Tools:
getCandidateRequests, getProductAreas, getRequestByIdModes: match, create, match_or_create, find_related
Slack agent
packages/ai/src/agents/slack
Extracts feedback from Slack messages and generates Slack notifications.Model: Claude Haiku
Tools:
Modes: extract, chat, compose
Tools:
fetchThreadMessages, getUserInfoModes: extract, chat, compose
Analytics agent
packages/ai/src/agents/analytics
Generates structured insights reports for product areas.Model: Claude Sonnet (higher quality for analysis)
Tools:
Returns: Structured report with up to 4 sections
Tools:
analyzeDealbreakers, analyzeSegments, analyzeThemes, getExecutionStatusReturns: Structured report with up to 4 sections
Identity agent
packages/ai/src/agents/identity
Resolves user identities from email addresses.Model: Claude Haiku
Tools:
Returns: userId with confidence score
Tools:
searchUsersByEmail, getUserByIdReturns: userId with confidence score
Agent tools
Agents use tools to interact with data sources. Tools are defined using the AI SDK’stool function:
Tool context
Tools receive context viaexperimental_context, allowing you to inject dependencies:
Agent output
Agents return structured output using Zod schemas:Creating custom agents
To create a new agent:-
Create agent directory in
packages/ai/src/agents/your-agent/ -
Define tools in
tools.ts:
- Write instructions in
prompts.ts:
- Create agent in
index.ts:
- Export from main agent file:
Next steps
Semantic matching
Learn how semantic search and embeddings work
Workflows
See how agents are used in workflows
AI SDK docs
Read the Vercel AI SDK documentation
Architecture
Review the overall system architecture