Build Your First AI Agent
Ross Sylvester, Co-Founder & CEO, Adrata | Feb 2025 | ~7 min read
You don't need a team of ML engineers to build an AI agent. You don't need months of development time. You need a clear problem, the right tools, and about 4 hours.
This guide will take you from "I've never built an agent" to "I have a working agent in production" by the end of the day. We'll build a real sales agent that actually does useful work.
What You'll Build: A Lead Research Agent that takes a company name, researches it across multiple sources, and produces a structured briefing for your sales team. Time savings: 15-20 minutes per lead.
Prerequisites
- Basic familiarity with APIs (you've made API calls before)
- An OpenAI, Anthropic, or similar API key
- A code editor and terminal
- 2-4 hours of focused time
The 5-Step Framework
Step 1: Define the Agent's Job
An agent is not a chatbot. An agent has a specific job with clear inputs, outputs, and success criteria.
Bad definition: "An AI that helps with sales"
Good definition: "An agent that takes a company name, researches their tech stack, recent news, and hiring patterns, then outputs a structured JSON briefing."
Write down:
- Input: What does the agent receive? (Company name, URL, etc.)
- Output: What does it produce? (JSON, email, report, etc.)
- Tools: What external resources can it access? (Web search, databases, APIs)
- Success: How do you know it worked? (Accuracy, completeness, speed)
Step 2: Choose Your Stack
For your first agent, keep it simple. You can get fancy later.
Recommended starter stack:
- LLM: Claude 3.5 Sonnet or GPT-4o (both excellent at tool use)
- Framework: None. Use the raw API. Frameworks add complexity you don't need yet.
- Language: Python or TypeScript (whichever you're faster in)
- Tools: Start with 2-3 tools maximum
# Don't do this yet:
pip install langchain langgraph autogen crewai
# Do this:
pip install anthropic requests
Step 3: Build the Tool Layer
Tools are functions your agent can call. Each tool does one thing well.
# Example: Web search tool
def search_web(query: str) -> str:
"""Search the web for information about a query."""
# Use a search API (Serper, SerpAPI, etc.)
response = requests.get(
"https://api.serper.dev/search",
headers={"X-API-Key": SERPER_API_KEY},
json={"q": query}
)
results = response.json()
return format_search_results(results)
# Example: Company data tool
def get_company_info(domain: str) -> dict:
"""Get structured company data from domain."""
# Use a data enrichment API
response = requests.get(
f"https://api.clearbit.com/v2/companies/find",
params={"domain": domain},
headers={"Authorization": f"Bearer {CLEARBIT_KEY}"}
)
return response.json()
Tool design principles:
- Clear, descriptive function names
- Docstrings that explain what the tool does
- Typed parameters and return values
- Error handling that returns useful messages
Step 4: Build the Agent Loop
An agent is just a loop: think, act, observe, repeat.
import anthropic
client = anthropic.Anthropic()
def run_agent(company_name: str) -> dict:
messages = [
{"role": "user", "content": f"Research {company_name} and create a sales briefing."}
]
tools = [
{"name": "search_web", "description": "...", "input_schema": {...}},
{"name": "get_company_info", "description": "...", "input_schema": {...}},
]
while True:
response = client.messages.create(
model="claude-sonnet-4-20250514",
max_tokens=4096,
tools=tools,
messages=messages
)
# Check if agent wants to use a tool
if response.stop_reason == "tool_use":
tool_calls = [b for b in response.content if b.type == "tool_use"]
# Execute each tool call
tool_results = []
for call in tool_calls:
result = execute_tool(call.name, call.input)
tool_results.append({
"type": "tool_result",
"tool_use_id": call.id,
"content": result
})
# Add assistant response and tool results to conversation
messages.append({"role": "assistant", "content": response.content})
messages.append({"role": "user", "content": tool_results})
else:
# Agent is done, return final response
return extract_briefing(response.content)
Step 5: Write the System Prompt
The system prompt defines your agent's behavior. Be specific and structured.
You are a Lead Research Agent for a B2B sales team.
Your job: Research a company and produce a structured sales briefing.
## Research Process
1. Search for the company's website and basic info
2. Look up their tech stack and recent news
3. Find hiring patterns that indicate growth areas
4. Identify potential pain points and opportunities
## Output Format
Return a JSON object with:
{
"company_name": "...",
"industry": "...",
"employee_count": "...",
"tech_stack": ["...", "..."],
"recent_news": ["...", "..."],
"hiring_signals": ["...", "..."],
"pain_points": ["...", "..."],
"talking_points": ["...", "..."],
"recommended_approach": "..."
}
## Guidelines
- Be thorough but efficient (use tools strategically)
- If you can't find information, note it as "Unknown"
- Focus on actionable insights for sales conversations
- Prioritize recent information (last 6 months)
Testing Your Agent
Before you ship it, test with real inputs:
- Happy path: Test with well-known companies (Salesforce, HubSpot)
- Edge cases: Test with small/unknown companies
- Failure modes: Test with invalid inputs, API failures
- Speed: How long does it take? (Target: under 60 seconds)
Common First-Time Mistakes:
- Too many tools: Start with 2-3. Add more only when needed.
- Vague prompts: Be extremely specific about what you want.
- No error handling: APIs fail. Handle it gracefully.
- Infinite loops: Set a maximum number of iterations.
Deploying to Production
For your first agent, keep deployment simple:
- Wrap it in an API: Use FastAPI or Express to create an endpoint
- Add authentication: API key or OAuth
- Add logging: Log every agent run for debugging
- Set timeouts: Maximum 2 minutes per run
- Deploy: Railway, Render, or AWS Lambda
What's Next?
Once your first agent is working, you can:
- Add more tools (CRM lookup, email drafting, calendar scheduling)
- Build a second agent that works with the first
- Add memory so the agent learns from past research
- Create a dashboard to monitor agent performance
"The best way to learn about agents is to build one. Not read about them. Not watch videos. Build one."
You now have everything you need to build your first AI agent. The whole process should take 2-4 hours. By tomorrow, you could have an agent saving your team 15+ minutes per lead.
Start simple. Ship fast. Iterate from there.
