Module 4: Building SEO Agents
You’ve written scripts that call APIs and combine data. In this module, you’ll take the next step: automation that can decide what to do next based on what it finds. That’s what we mean by an agent – something that uses tools (APIs, search, code) and an LLM to work through a multi-step SEO task with less hand-holding.
You’re not building a general-purpose robot. You’re defining a goal, giving it clear tools and guardrails, and learning how to prompt and test so it stays on track.
Learning Objectives
By the end of this module, you will be able to:
- Describe the difference between a fixed script and an agent (goal + tools + decisions)
- Design a simple agent workflow: goal, steps, tools, and success criteria
- Prompt effectively for agent-style tasks (single run or with an agent framework)
- Spot when an agent is overkill and a script would do
Prerequisites
- Completion of Module 3: APIs & JSON Fundamentals
- Comfort with prompting for Python and API tasks (Module 2 and 3)
- A concrete SEO task in mind that has more than one “it depends” step
Why it matters
Scripts do what you told them. Agents decide what to do next. When the next step depends on the result of the last one – “if rankings dropped, check Core Web Vitals; if CWV is fine, check backlinks” – you either write a lot of branching logic or you give something an LLM and tools and let it choose. The latter is an agent.
That doesn’t mean every task needs one. Many SEO workflows are fixed: pull data, join, export. For those, your Module 3 approach is enough. Agents start to pay off when you have a goal and multiple valid paths, and you want one setup that can handle different sites or scenarios without you rewriting the script each time.
With this understanding, you can:
- Choose the right level of automation – script vs agent – for each task
- Specify agent behaviour so it stays on task and doesn’t hallucinate steps
- Use tools safely – APIs, search, file access – by defining what the agent is allowed to call
- Iterate and debug by checking the agent’s reasoning or step log
Example in action
Instead of writing a script that “does step 1, then step 2, then step 3” for a technical SEO check, you describe the goal: “Assess this site’s technical SEO and prioritise the top five issues with evidence.” The agent has access to crawl data (or an API), the ability to run checks, and an LLM to interpret. It might decide to look at indexability first, then speed, then internal linking – and it can adapt if it finds a critical issue early.
You still define the goal, the tools, and what “done” looks like. The agent fills in the order and the reasoning.
Common mistakes
- Using an agent when a script would do – If the steps are fixed and the same every time, a normal script is simpler and easier to debug. Reserve agents for “it depends” workflows.
- Vague goals – “Improve my SEO” gives the agent nothing to latch onto. “List the top five technical issues from this crawl export with severity and a one-line fix” is actionable.
- Giving too many tools or no boundaries – The more the agent can do, the more it can go off-piste. Start with the minimum set of tools (e.g. read this file, call this API) and add more only when needed.
- Skipping a step log or output – You need to see what it did and why. Ask for a summary of steps taken and conclusions so you can verify and improve the prompt.
- Ignoring cost and speed – Agent runs that call an LLM many times can get slow and expensive. Define a sensible max number of steps or tool calls so it doesn’t loop.
Agents vs scripts in plain English
A script runs a sequence you wrote: do A, then B, then C. Same every time. Great for “pull GSC + Ahrefs, join, export.”
An agent has a goal and a set of tools. It uses an LLM to decide what to do next. It might do B before A if the LLM thinks that’s better, or skip C if the goal is already met. Great for “audit this site and prioritise issues” or “answer this SEO question using these data sources.”
You can get agent-like behaviour today by prompting an LLM with clear instructions and a list of allowed actions (e.g. “you may only use the following: read file X, call API Y”). You don’t have to use a formal agent framework to benefit from the idea: goal + tools + decisions.
Prompting for agent-style tasks
Give a clear goal and success criteria
❌ BAD: "Analyse this site and suggest improvements"
✅ GOOD: "Using only the crawl export crawl_results.csv, identify the top five technical SEO issues. For each issue: name, severity (high/medium/low), evidence (URL or metric), one-sentence recommended fix. Output a markdown report. Do not use any data except the CSV."
Constrain the tools and steps
❌ BAD: "Use whatever you need to research our competitors"
✅ GOOD: "You have access to: (1) the file competitor_keywords.csv, (2) the Ahrefs API for domain overview (endpoint X). Do not search the web or read other files. Produce a table: competitor, domain rating, top 3 keyword themes. Maximum 3 API calls."
Ask for a step log or reasoning
✅ GOOD: "After completing the task, output a short 'Steps taken' section listing each action (e.g. 'Read crawl_results.csv', 'Filtered for status 4xx') and the conclusion. This helps me verify the result."
That way you can see if the agent stayed within bounds and how it reached its answer.
Try it yourself
These exercises focus on designing the goal, tools, and output so that an agent (or a single detailed prompt that mimics agent behaviour) stays useful and safe.
Exercise 1: Keyword research agent (single run)
Task: Design a prompt that acts like a small agent: given a topic and a keyword CSV, it “decides” which keywords to prioritise and why, and outputs a short prioritised list with reasoning.
LLM Prompt Type Needed: Goal + constraints + structured output prompt
A starter example:
"You are an SEO keyword analyst. You have one input: the file keywords.csv with columns keyword, volume, kd, cpc. Goal: pick the top 10 keywords we should target first for a new page about [TOPIC]. You must only use the data in the CSV. Output: (1) a table of the 10 keywords with volume, kd, cpc, (2) a short 'Reasoning' paragraph explaining why these 10, (3) what you did NOT do (e.g. no external data). Do not call any API or read any other file."
Common pitfalls to watch out for:
- Forgetting to say “only use this file” – the LLM might otherwise invent data or suggest “search for more”
- Not asking for reasoning – you lose the ability to check and improve the prompt
- Topic too vague – “[TOPIC]” should be something specific (e.g. “best running shoes for marathons”) so the prioritisation is testable
Exercise 2: Technical SEO checklist (agent-like steps)
Task: Write a prompt that walks through a small technical SEO checklist (e.g. indexability, basic speed, internal links) using only one or two allowed inputs (e.g. a crawl CSV and a page speed export). The output should be a short report plus a list of steps the “agent” took.
LLM Prompt Type Needed: Multi-step analysis with step log prompt
A starter example:
"You have two files: crawl_export.csv (columns url, status, title, links_internal) and pagespeed_export.csv (url, LCP, FID, CLS). Goal: produce a 1-page technical SEO report with (1) indexability summary (count of 2xx vs 4xx vs 5xx), (2) top 5 slowest URLs by LCP, (3) one paragraph on internal linking health. At the end, list 'Steps taken' (e.g. 'Read crawl_export, filtered for status codes'). Use only these two files."
Common pitfalls to watch out for:
- Assuming column names – if your real exports differ, specify them in the prompt or the agent will guess
- Not asking for “steps taken” – you need to verify it didn’t hallucinate data
- Giving it access to “the whole web” – keep inputs limited so the result is reproducible
Exercise 3: When not to use an agent
Task: Take a workflow you already do (or one from Module 2 or 3) and write down why it is or isn’t a good fit for an agent. Then write a one-sentence goal and a list of allowed tools that would make it agent-worthy, or a one-sentence explanation of why a script is better.
LLM Prompt Type Needed: N/A – reflection and design
Example: “Weekly GSC + Ahrefs export and join” – same steps every time, same columns. A script is better. “Assess this site’s technical health and prioritise fixes” – depends on what the crawl finds. An agent (or agent-like prompt) can decide what to check next.
Why this exercise: Choosing the right level of automation saves time and avoids over-engineering. Practice the decision.
Key topics covered (reference)
- Agent vs script: Goal + tools + decisions vs fixed sequence.
- Designing for agents: Clear goal, bounded tools, success criteria, step log.
- Prompting: Constrain inputs and tools; ask for reasoning or steps taken.
- When to use agents: “It depends” workflows; when to stick with scripts.
For more on tool use and frameworks (e.g. MCP), see the SEO Tools Integration Guide and course materials on agent platforms.
Resources
- LLM Prompting Guide – Prompting for multi-step and agent-style tasks
- SEO Tools Integration Guide – Tools and APIs agents can use
- Python Quick Reference Guide – Patterns for scripts that agents can call or replace
| Next: Module 5: Data Analysis and Insights | Supporting materials |
Ready to move from fixed scripts to goal-driven automation? This module gives you the mindset and prompts to design and control SEO agents that stay on task.