/ Blog
Blog Contact Buddy Ads Builder Audit Engine GitHub

Tutorial 5: Building Your First AI Agent — From Script to Autonomous System

John Williams · Senior Paid Media Specialist · $48M+ Managed · Feb 2026

How do I get started with tutorial 5: building your first ai agent?
This covers everything you need to know about tutorial 5: building your first ai agent.

What you’ll learn: What makes an AI agent different from a script or chatbot. How to build a simple advertising agent using Claude’s tool-use capability. Architecture patterns for multi-agent systems.

The What: Agents Think, Scripts Execute

A script follows instructions: “pull data, check threshold, send alert.” An agent reasons: “pull data, analyze what’s happening, decide what to investigate next, take action, evaluate the result.” The difference is autonomous decision-making. Gartner projects 40% of enterprise applications will embed AI agents by end of 2026. The agentic AI market is projected to grow from $7.8 billion to $52 billion by 2030.

But industry analysts estimate only about 130 of thousands of claimed AI agent vendors are building genuinely agentic systems. The rest are doing what researchers call agent washing—rebranding automation as agents. Understanding the real architecture helps you tell the difference.

The How: Build a Search Query Agent with Claude Tool Use

Claude’s tool-use (function calling) capability lets you build an agent that can autonomously decide which tools to use based on what it discovers. Here is a working example of a search query analysis agent:

import anthropic
import json

client = anthropic.Anthropic()

# Define the tools the agent can use
tools = [
{
'name': 'get_search_queries',
'description': 'Pull search query report for a campaign',
'input_schema': {
'type': 'object',
'properties': {
'campaign_name': {'type':'string'},
'days': {'type':'integer','description':'Lookback days'}
},
'required': ['campaign_name']
}
},
{
'name': 'add_negative_keyword',
'description': 'Add a negative keyword to a campaign',
'input_schema': {
'type': 'object',
'properties': {
'campaign_name': {'type':'string'},
'keyword': {'type':'string'},
'match_type': {'type':'string','enum':['EXACT','PHRASE','BROAD']}
},
'required': ['campaign_name','keyword','match_type']
}
},
{
'name': 'send_alert',
'description': 'Send an alert to the account manager',
'input_schema': {
'type': 'object',
'properties': {
'message': {'type':'string'},
'priority': {'type':'string','enum':['low','medium','high']}
},
'required': ['message','priority']
}
}
]

# The agent loop
messages = [{
'role': 'user',
'content': '''Review search queries for the Brand campaign.
If you find irrelevant queries costing more than $5 with zero
conversions, add them as negatives. Alert me about anything
that needs strategic review.'''
}]

# Agent runs until it decides it's done
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':
for block in response.content:
if block.type == 'tool_use':
print(f'Agent calling: {block.name}({block.input})')
# Execute the tool and return result
result = execute_tool(block.name, block.input)
messages.append({'role':'assistant','content':response.content})
messages.append({
'role': 'user',
'content': [{'type':'tool_result',
'tool_use_id':block.id,
'content':json.dumps(result)}]
})
else:
# Agent is done
print('Agent summary:', response.content[0].text)
break

KEY INSIGHT: Notice the agent decides which tools to call and in what order. It might pull search queries, find waste, add negatives, then send you a summary—all autonomously. This is the exact pattern GoogleAdsAgent.ai uses, expanded to 28 tools across 6 sub-agents.

The So What: GoogleAdsAgent.ai’s Multi-Agent Architecture

The So What: GoogleAdsAgent.ai’s Multi-Agent Architecture

GoogleAdsAgent.ai extends this pattern to a multi-agent system where 6 specialized sub-agents—Campaign Intelligence, Creative Analysis, Competitive Monitoring, Budget Orchestration, Search Query Optimization, and Performance Reporting—each have their own tool sets and can coordinate with each other. The Search Query agent might discover a new competitor keyword pattern and alert the Competitive Monitoring agent, which then triggers a deeper competitive analysis. This kind of cross-agent coordination is what separates genuine agentic systems from rebranded automation.

📦 GitHub: https://github.com/itallstartedwithaidea/google-ads-api-agent — The production multi-agent system with full tool definitions, error handling, and audit logging

🔗 Resources

Website: https://googleadsagent.ai | GitHub: https://github.com/itallstartedwithaidea | Tools: https://googleadsagent.ai/tools

About the Author

John Williams is a Senior Paid Media Specialist at Seer Interactive with 15+ years managing $48M+ in digital ad spend across Google, Microsoft, Meta, and Amazon. Founder of It All Started With A Idea and creator of GoogleAdsAgent.ai. Speaker at Hero Conf on AI in advertising. Former WSU football player and current assistant football coach at Casteel High School, AZ.

© 2026 It All Started With A Idea. All rights reserved.

Ready to Put This Into Practice?

Get a free 30-day audit of your advertising accounts. John will personally review your setup and provide actionable recommendations.

No credit card · No contract · John will personally reach out within 24 hours

Thank You!

John will review your account and reach out within 24 hours.