Why this matters on the job
Picture a sprint review at a product company in Bengaluru or a client delivery team in Pune. The engineering manager says: "Our competitors are using AI agents to write and fix tests. Can we cut our regression automation backlog in half this quarter?" Half the team has only used AI chat to paste a stack trace and ask what went wrong. The other half has tried an agent that clicked around the app, wrote a test, ran it and fixed its own mistakes - and they are either excited or worried.
In 2026 the conversation has moved from "AI suggests a line of code" to "AI agents explore the app, write tests, run them and repair them". Testers who understand how an agent works - the model, the tools it can call, and the loop it runs - are the people who can make it useful and safe. Testers who do not understand it either avoid agents completely or trust them blindly. Both are career risks. This lesson gives you the mental model you will use for the rest of the course.
Concepts
Three generations of AI help for testers
It helps to separate the hype into three clear generations. Most teams in India and abroad now use all three side by side.
| Generation | What the AI does | Typical example | Tester's role |
|---|---|---|---|
| 1. Autocomplete | Predicts the next lines while you type | Inline code suggestions in the IDE | Write the test, accept or reject suggestions |
| 2. Chat assistant | Answers a question or writes a block of code from a prompt | "Write a Playwright test for the login page" in a chat window | Copy, paste, run, debug the code yourself |
| 3. Agent | Plans steps, calls tools (browser, terminal, files, APIs), observes results and repeats until the goal is met | An agent that opens the app through Playwright MCP, writes a spec file, runs npx playwright test and fixes failures | Define the goal and boundaries, review every change, own the quality decision |
The jump from generation 2 to 3 is not about a smarter model. It is about giving the model hands (tools) and time (a loop). That is why the same model can feel like a toy in a chat window and like a junior automation engineer inside an agent.
Anatomy of an agent: LLM + tools + loop
- LLM (the brain) - reads the goal, the conversation so far and the tool results, then decides the next action. It does not "see" your app directly; it only sees what tools return.
- Tools (the hands) - functions the model is allowed to call: navigate a browser, take an accessibility snapshot, click, read a file, run a shell command, call an API. Each tool has a name, a description and an input schema.
- Loop (the persistence) - the host program sends the model's tool request to the tool, captures the result and sends it back to the model. This repeats until the model says it is done, a step limit is reached, or a human stops it.
- Context (the memory) - everything the model can see in one turn: instructions, files you attach, previous tool outputs. Context is limited, so good agents summarise and good testers keep prompts focused.
- Guardrails - permissions, approvals, allowed websites, step limits and human review. Without guardrails, an agent is just an automated way to make mistakes faster.
The following pseudo-code is not a real product, but it shows the loop every agent host runs, whether it is VS Code, Claude Code or a CI bot:
# Simplified agent loop - for understanding only
def run_agent(goal, tools, llm, max_steps=25):
messages = [{"role": "system", "content": "You are a test automation agent."},
{"role": "user", "content": goal}]
for step in range(max_steps):
reply = llm.chat(messages, tools=[t.schema for t in tools])
if reply.tool_call is None: # model says it is finished
return reply.text
tool = next(t for t in tools if t.name == reply.tool_call.name)
if tool.needs_approval and not human_approves(reply.tool_call):
messages.append({"role": "tool", "content": "User denied this action."})
continue
result = tool.run(**reply.tool_call.arguments) # e.g. click, run tests
messages.append({"role": "tool", "content": result})
return "Stopped: step limit reached - ask a human to review."Notice three tester-relevant details: the max_steps limit (agents can loop forever), the approval check (some tools are risky), and that every tool result goes back into the context (so a malicious web page can talk to the model - we will cover that prompt-injection risk in lesson 9).
Model Context Protocol (MCP) basics
Before MCP, every AI tool vendor wrote its own plugin format. The Model Context Protocol is an open standard that defines how an AI application discovers and calls external tools and data. Write a tool server once and many clients can use it - VS Code with GitHub Copilot, Claude Code, Cursor and others.
| MCP term | Meaning | Testing example |
|---|---|---|
| Host | The AI application the user works in | VS Code, Claude Code, Claude Desktop |
| Client | The connector inside the host that talks to one server | The VS Code connection to the Playwright server |
| Server | A program exposing capabilities over MCP | @playwright/mcp exposing browser tools |
| Tools | Actions the model can invoke | browser_navigate, browser_snapshot, browser_click |
| Resources | Read-only data the host can attach as context | A test plan file, an OpenAPI spec |
| Prompts | Reusable prompt templates offered by a server | "Generate a regression plan for this page" |
Servers can run locally as a child process (communicating over standard input/output) or remotely over HTTP. Most testing servers you will use start with an npx command. A typical client configuration looks like this (the exact file name and top-level key differ per client - VS Code uses .vscode/mcp.json with a servers key, many other clients use mcpServers):
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": ["@playwright/mcp@latest"]
}
}
}This is the configuration documented on the Playwright MCP getting started page. Important point for testers: an MCP server is code that runs on your machine with your permissions. Treat adding one like installing a dependency - only from trusted publishers, pinned and reviewed.
Where agents fit in the STLC
Agents are not equally useful in every phase. Use this map when your manager asks "where should we start?"
| STLC phase | Agent can help with | Human must own | Fit today |
|---|---|---|---|
| Requirement analysis | Summarise user stories, list ambiguities, suggest acceptance criteria | Confirming business intent with the product owner | Medium |
| Test planning | Explore the app and draft a Markdown test plan | Scope, risk priority, what not to automate | High |
| Test design | Generate scenarios, boundary values, negative cases, synthetic data | Domain rules (GST, UPI limits, KYC rules) | High |
| Test implementation | Write Playwright/API tests, refactor to Page Object Model | Code review, locator quality, assertions that prove something | High |
| Execution | Run suites, re-run failures, collect traces | Environment and data readiness | High (mostly via CI, not the LLM) |
| Defect reporting / triage | Cluster failures, summarise traces, draft bug reports | Severity, deciding bug vs test issue | Medium-High |
| Test closure | Draft summary reports and metrics narrative | Sign-off and release recommendation | Medium |
Limits you must explain to stakeholders
- Non-determinism - the same prompt can produce different tests on different runs. Commit the generated code, not the prompt, as the source of truth.
- Confident but wrong - agents can write assertions that always pass (for example checking that a page has a title) and report success.
- Cost and speed - every tool call is a model call. Running the LLM inside every CI test run is slow and expensive; use agents to create and maintain tests, and plain Playwright to run them.
- Data privacy - anything the agent reads may be sent to the model provider. Never point agents at production data or paste client PII; use synthetic data and practice sites. In India the Digital Personal Data Protection (DPDP) Act 2023 applies to personal data, and EU clients will expect GDPR discipline.
Hands-on Lab: Watch an MCP server without any AI
Target: the Playwright MCP server and saucedemo.com. Setup: Node.js 22.19 or newer (needed by the MCP Inspector), a terminal and a browser. No AI account is required - you will act as the "LLM" yourself, which is the fastest way to understand what an agent actually sees.
- Check your Node version with
node -v. Upgrade to a current LTS if it is older than 22.19. - Start the official MCP Inspector with the Playwright server as its target:
npx -y @modelcontextprotocol/inspector npx @playwright/mcp@latest - The Inspector opens in your browser. Connect, then open the Tools list. Note down at least eight tool names and read their descriptions and input schemas - this is exactly what the model reads when deciding what to do.
- Call
browser_navigatewith{"url": "https://www.saucedemo.com"}. A real browser window opens. - Call
browser_snapshot. Study the output: roles (textbox, button), names and element references such asref=e5. The model uses these references, not pixels, to choose what to click. - Using the refs from the snapshot, call
browser_typeto enter the public demo userstandard_userand passwordsecret_sauce, thenbrowser_clickon the Login button. Take another snapshot and confirm you are on the Products page. - Optional: list tools from the command line, which is useful in CI scripts:
npx @modelcontextprotocol/inspector --cli npx @playwright/mcp@latest --method tools/list - Write a one-page note: which tools would you allow an agent to use freely, which need approval, and which would you disable on a client project? Keep it - you will reuse it in lesson 9.
Common mistakes
- Thinking the agent "sees" the screen like a human - with Playwright MCP it mostly reads an accessibility snapshot, so poor accessibility in the app means poor agent results.
- Running agents with no step limit or approval rules and then being surprised by 200 tool calls and a large bill.
- Adding random MCP servers found on the internet without checking the publisher, the code and the permissions they need.
- Using the LLM inside every CI run instead of generating stable Playwright code once and running it deterministically.
- Pasting real customer names, Aadhaar-like IDs, card numbers or client URLs into an agent prompt - use synthetic data and practice targets.
Real-world assignment
Prepare a two-page "Agentic testing opportunity map" for a realistic product (for example a UPI payments app or an e-commerce site like saucedemo.com). For each STLC phase, list one task an agent could do, the MCP tools it would need, what a human must review, the risk level and how you would measure success. Add a diagram of the agent loop in your own words. Publish it in your portfolio repository as a Markdown file - interviewers increasingly ask candidates how they would introduce AI agents safely.
Key takeaways
- An agent is an LLM plus tools plus a loop, wrapped in guardrails - the tools and loop are what make it useful.
- MCP is the open standard that lets one tool server (like Playwright MCP) work with many AI hosts.
- Agents fit best in planning, design, implementation and triage; humans own scope, risk and sign-off.
- Use agents to create and maintain tests; run the resulting code deterministically in CI.
- Every tool result enters the model's context, which is both a superpower and a security risk.