Courses  /  AI Agents

Local-First AI Agents, Ready for the Cloud — Full Workshop

A full workshop in plain, simple English. A demo agent is easy. A production agent is a different problem. Build one local agent, then take the same code to the cloud, add secure MCP tools, and finish with a team of agents that work together.

Time: go at your own pace, one section at a time. Level: beginner to intermediate. Code: Python 3.10 or newer.

Your progress: 0 / 18

Tick “Done” on each section. Your ticks are saved in this browser.

How to use this workshop

1. Read one section at a time, in order. Each section has the same shape, so you always know what comes next.

2. Read “What it is”, then “Why it matters”.

3. Copy the Python code, save it, and run it. Change one small thing and run it again. That is how you learn.

4. Do the “Try it yourself” task. It is small on purpose.

5. Answer the “Check” questions. Click a question to see the answer. If you got it wrong, read the section again.

6. Tick “Done” when you finish a section. Your progress is saved in this browser.

Work in order: Part 1 explains the idea. Part 2 teaches the nine skills, one at a time. Part 3 is the four hands-on labs. Part 4 checks who it is for and what you leave with. The capstone at the end puts it all together.

Local vs cloud: every example in this workshop runs on your own computer, with no cloud account and no API key. Where a real deployment would need a cloud account, the page says so clearly in a blue box. The code for those parts is shown in full, and it runs offline here with a stand-in, so you can learn it first and pay for the cloud only when you are ready.

Setup — Python, LMStudio, and running code

What you need

Python 3.10 or newer. That is all you need to follow this workshop. No extra packages, no internet, no API key, no cloud account.

Check your Python

Open a terminal and run:

Terminal
python3 --version

You should see Python 3.10 or newer, for example Python 3.12.

How to run the code

  1. Copy the code from a section.
  2. Save it in a file, for example agent.py, in a folder for this workshop.
  3. In the terminal, go to that folder and run: python3 agent.py
  4. Read the output. Change one line, run it again, and see what changes.

No API key needed — the fake model

Every Python example uses a small function called fake_llm. It is not a real model. It reads keywords and returns a fixed answer. That is enough to learn the agent loop, tools, memory, MCP, A2A, discovery, and guardrails, and it works offline.

How to swap the fake model for LMStudio / LiteLLM — the short change. Only do this if you want to, after the workshop works with the fake model. Do not do it to follow the workshop.

Python — the swap (optional, needs LMStudio running locally)
# 1. Install LMStudio, download Gemma, start its local server.
# 2. Install once: pip install litellm
# 3. Replace fake_llm with this real function:
from litellm import completion
def fake_llm(prompt):
    response = completion(
        model="openai/gemma-3-4b-it",
        messages=[{"role": "user", "content": prompt}],
        base_url="http://localhost:1234/v1",
        api_key="lm-studio",
    )
    return response.choices[0].message.content
# For a real cloud model, change only the model name and base_url.
# Keep the same function name, fake_llm, so all the other code keeps working.

For ADK, the real import is from google.adk.agents import Agent after pip install google-adk. The examples in this workshop use a small stand-in Agent class with the same shape, so they run offline with no download. The real import lines are shown in the notes of the lessons that use them.

What needs a cloud account in real life: a cloud model, a serverless platform, and managed MCP tools. What does NOT need one: everything in Labs 1 and 3, and all the code in this workshop as written here. Lab 2 and Lab 4 show the cloud code in full, and mark the cloud-only steps clearly.

Try the multi-agent system here

Type a task, for example research apples and write a short report, check stock of apples, or write a report about bread. The simulated system below shows the Orchestrator, Worker, and Reviewer steps, the tool used, and the final answer. No server, no key, no Python needed for this box.

Press “Run the multi-agent system” to see the team work.

Try these: “research apples and write a short report”, “check stock of apples”, “write a report about bread”, “hello”.

Part 1 — The Core Idea

A demo agent is easy. A production agent is a different problem. This part explains the idea behind the whole workshop.

3 sections in this part.

Workshop: The Core Idea: Demo Agent vs Production Agent

What it is

Building an AI agent that works in a demo is easy. Building one that survives production is a different problem. A demo agent answers one question, once, in front of you. A production agent must keep working when the model changes, when a tool fails, when costs grow, and when a security rule says no. Most agent tutorials lock you into one vendor and one hosted model from the first line of code. That works until you need to switch providers, control costs, satisfy a security requirement, or run the same logic in your own environment. This workshop takes the opposite approach: start local, with open models and no cloud, then move the same architecture to the cloud.

Why it matters

If you only learn the demo, you will have to rebuild everything when you deploy. If you learn the production way from the start, the same code works in both places.

Note: Swap note: to use LMStudio, LiteLLM, or a real cloud model, replace fake_llm with the real call shown in Setup. No key or cloud account is needed to follow this workshop.

Python — copy and run
# A small simulated model. It does NOT call the internet.
# It reads keywords and returns a fixed, clear answer.
# Every example in this workshop runs offline, with no API key.
def fake_llm(prompt):
    text = prompt.lower()
    if "stock" in text and "apple" in text:
        return "ACTION: check_stock | ITEM: apples"
    if "stock" in text:
        return "ACTION: check_stock | ITEM: apples"
    if "add" in text or "restock" in text:
        return "ACTION: add_stock | ITEM: apples | AMOUNT: 10"
    if "low" in text:
        return "ACTION: list_low_stock"
    if "research" in text:
        return "PLAN: search, then write, then review"
    if "hello" in text or "hi" in text:
        return "Hello! I am your agent. How can I help?"
    return "I will check that for you step by step."

# Core idea: a demo agent and a production agent look the same at first.
# The difference is what happens when things go wrong, cost money, or move.
# Demo: one prompt, one answer. Production: loop, tools, memory, limits.

def demo_agent(question):
    return fake_llm(question)

def production_agent(question):
    steps = []
    for step in range(1, 4):
        answer = fake_llm(question)
        steps.append(answer)
        if "ACTION" in answer:
            steps.append("Tool result: apples = 12 in stock.")
            break
    return steps

print("Demo:", demo_agent("check stock of apples"))
print("Production:", production_agent("check stock of apples"))

Try it yourself

Change the question in the code from apples to bread and run it again.

Check

What is the difference between a demo agent and a production agent?

A demo agent works once, in front of you. A production agent must keep working when things change, fail, or cost money.

What is vendor lock-in, in plain words?

Your code only works with one company's model or service, so switching is hard and expensive.

Back to contents

Workshop: Why Attend? The Gap Between Prototype and Deployable System

What it is

If you are building with agents today, you have probably noticed that the gap between a working prototype and something you would actually deploy is large. This workshop closes that gap. You will learn to write vendor-neutral agent logic that runs locally or in the cloud without a rewrite, start with open models on your own machine and move to cloud only when you need it, connect agents to enterprise context and APIs using MCP, manage service accounts, IAM, and secure tool execution, coordinate multiple agents that delegate and route work to each other, deploy to a serverless platform, and add observability, cost tracking, and guardrails so it stays reliable. The focus is not just how agents work. It is how to build agents you can actually run, secure, and operate.

Why it matters

Knowing the gap is what makes you a builder, not just a demo maker. Every lesson after this one closes one part of the gap.

Note: Swap note: to use LMStudio, LiteLLM, or a real cloud model, replace fake_llm with the real call shown in Setup. No key or cloud account is needed to follow this workshop.

Python — copy and run
# A small simulated model. It does NOT call the internet.
# It reads keywords and returns a fixed, clear answer.
# Every example in this workshop runs offline, with no API key.
def fake_llm(prompt):
    text = prompt.lower()
    if "stock" in text and "apple" in text:
        return "ACTION: check_stock | ITEM: apples"
    if "stock" in text:
        return "ACTION: check_stock | ITEM: apples"
    if "add" in text or "restock" in text:
        return "ACTION: add_stock | ITEM: apples | AMOUNT: 10"
    if "low" in text:
        return "ACTION: list_low_stock"
    if "research" in text:
        return "PLAN: search, then write, then review"
    if "hello" in text or "hi" in text:
        return "Hello! I am your agent. How can I help?"
    return "I will check that for you step by step."

# The gap: a prototype works once. A deployable system must also handle
# cost, security, failure, and change. This checklist is the gap, in code.
GAP = [
    "Can I switch models without rewriting the agent?",
    "Can I see what it did, and what it cost?",
    "Can a bad tool call hurt anything?",
    "What happens when a tool fails?",
    "Can it run locally AND in the cloud?",
]
for item in GAP:
    print("[ ]", item)
print("Model:", fake_llm("check stock of apples"))
print("This workshop closes each gap above, one section at a time.")

Try it yourself

Read the checklist in the code. Tick which gaps you have felt in your own projects.

Check

What gap does this workshop close?

The gap between a working prototype and a system you would actually deploy.

Name two things a deployable system needs that a demo does not.

Any two of: switching models, cost control, security, failure handling, running in the cloud.

Back to contents

Workshop: What You Will Build

What it is

You will build a coordinated multi-agent system, starting from a single local agent and ending with a network of agents running in the cloud. Along the way, your system will be able to run entirely on your own machine using open models, with no cloud account required; move to a cloud environment without rewriting the core agent logic; call secure, authenticated tools through MCP; delegate work across an Orchestrator to Worker to Reviewer pattern; discover and route tasks to peer agents based on their capabilities; and run reliably on a serverless platform with tracing, cost tracking, and error recovery. You will build it step by step, and nothing is thrown away: the local agent becomes the cloud agent, and the cloud agent becomes one member of the team.

Why it matters

Building one system that grows is easier than building four separate systems. Each lab reuses the last one.

Note: Swap note: to use LMStudio, LiteLLM, or a real cloud model, replace fake_llm with the real call shown in Setup. No key or cloud account is needed to follow this workshop.

Python — copy and run
# A small simulated model. It does NOT call the internet.
# It reads keywords and returns a fixed, clear answer.
# Every example in this workshop runs offline, with no API key.
def fake_llm(prompt):
    text = prompt.lower()
    if "stock" in text and "apple" in text:
        return "ACTION: check_stock | ITEM: apples"
    if "stock" in text:
        return "ACTION: check_stock | ITEM: apples"
    if "add" in text or "restock" in text:
        return "ACTION: add_stock | ITEM: apples | AMOUNT: 10"
    if "low" in text:
        return "ACTION: list_low_stock"
    if "research" in text:
        return "PLAN: search, then write, then review"
    if "hello" in text or "hi" in text:
        return "Hello! I am your agent. How can I help?"
    return "I will check that for you step by step."

# What you will build: one agent first, then a network of agents.
# The same code grows: Agent -> portable Agent -> MCP tools -> team.
class Agent:
    def __init__(self, name):
        self.name = name
        self.memory = []
    def run(self, request):
        answer = fake_llm(request)
        self.memory.append((request, answer))
        return f"{self.name}: {answer}"

solo = Agent("Solo")
print(solo.run("check stock of apples"))
print("Next: this same agent becomes portable, then cloud-ready,")
print("then one member of a team. Nothing is thrown away.")

Try it yourself

Run the code, then add a second agent with a different name and run it too.

Check

What do you build first?

One single local agent.

What does it become by the end?

A network of agents running in the cloud, with MCP tools, discovery, and observability.

Back to contents

Part 2 — What You Will Learn

Nine topics, one at a time. Each one is a skill a production agent needs.

9 sections in this part.

Learn: Agent Anatomy: System Instructions, Memory, and Skills

What it is

Agent anatomy is the three parts every agent has. System instructions are the written rules for the agent, for example 'You are a shop assistant. Answer short.' Memory is what the agent learned so far, kept in a list, a file, or a database. Skills are the tools the agent is allowed to use, such as check_stock. The agent reads the instructions, checks its memory, picks a skill, and acts. If you change the instructions, you change how the agent behaves, without changing the code.

Why it matters

When an agent does something strange, check these three parts first. Most problems are a bad instruction, forgotten memory, or a missing skill.

Note: Swap note: to use LMStudio, LiteLLM, or a real cloud model, replace fake_llm with the real call shown in Setup. No key or cloud account is needed to follow this workshop.

Python — copy and run
# A small simulated model. It does NOT call the internet.
# It reads keywords and returns a fixed, clear answer.
# Every example in this workshop runs offline, with no API key.
def fake_llm(prompt):
    text = prompt.lower()
    if "stock" in text and "apple" in text:
        return "ACTION: check_stock | ITEM: apples"
    if "stock" in text:
        return "ACTION: check_stock | ITEM: apples"
    if "add" in text or "restock" in text:
        return "ACTION: add_stock | ITEM: apples | AMOUNT: 10"
    if "low" in text:
        return "ACTION: list_low_stock"
    if "research" in text:
        return "PLAN: search, then write, then review"
    if "hello" in text or "hi" in text:
        return "Hello! I am your agent. How can I help?"
    return "I will check that for you step by step."

# Agent anatomy: three parts. Instructions, memory, and skills.
# Instructions = what the agent should do. Memory = what it learned.
# Skills = the tools it is allowed to use.
class Agent:
    def __init__(self, instructions):
        self.instructions = instructions
        self.memory = []
        self.skills = {}
    def add_skill(self, name, function):
        self.skills[name] = function
    def run(self, request):
        print("Instructions:", self.instructions)
        answer = fake_llm(request)
        self.memory.append(answer)
        if "check_stock" in answer:
            return self.skills["check_stock"]("apples")
        return answer

def check_stock(item):
    return f"{item}: 12 in stock."

agent = Agent("You are a shop assistant. Answer short.")
agent.add_skill("check_stock", check_stock)
print(agent.run("check stock of apples"))
print("Memory:", agent.memory)

Try it yourself

Change the instructions in the code to 'You are a warehouse helper.' and run it again.

Check

What are the three parts of agent anatomy?

System instructions, memory, and skills.

What is a skill, in this lesson?

A tool the agent is allowed to use, such as check_stock.

Back to contents

Learn: The Portability Principle: ADK with LiteLLM, LMStudio, and Open Models like Gemma

What it is

The Portability Principle is a simple rule: keep your agent logic vendor-neutral. The agent never talks to a model directly. It talks to a small adapter, and the adapter talks to the model. ADK is a toolkit for building agents. LiteLLM is a connector that lets one call reach many different models. LMStudio is a program that runs open models on your own computer. Gemma is one such open model. With this setup, you can run Gemma locally today, and switch to a cloud model tomorrow, by changing the adapter only. The agent code stays the same.

Why it matters

Switching models is a real-life need: prices change, a model is removed, or a security rule says data must stay on your machine. Portability makes that switch a small change, not a rewrite.

Note: Swap note: to use LMStudio, LiteLLM, or a real cloud model, replace fake_llm with the real call shown in Setup. No key or cloud account is needed to follow this workshop.

Python — copy and run
# A small simulated model. It does NOT call the internet.
# It reads keywords and returns a fixed, clear answer.
# Every example in this workshop runs offline, with no API key.
def fake_llm(prompt):
    text = prompt.lower()
    if "stock" in text and "apple" in text:
        return "ACTION: check_stock | ITEM: apples"
    if "stock" in text:
        return "ACTION: check_stock | ITEM: apples"
    if "add" in text or "restock" in text:
        return "ACTION: add_stock | ITEM: apples | AMOUNT: 10"
    if "low" in text:
        return "ACTION: list_low_stock"
    if "research" in text:
        return "PLAN: search, then write, then review"
    if "hello" in text or "hi" in text:
        return "Hello! I am your agent. How can I help?"
    return "I will check that for you step by step."

# Portability Principle: the agent logic never talks to a model directly.
# It talks to a small "model adapter". Swap the adapter, keep the agent.
# Real code: from litellm import completion  (LiteLLM, one call, many models)
# Real local code: point LiteLLM at LMStudio, e.g. model="openai/gemma-3-4b-it"

class FakeModel:
    def ask(self, prompt):
        return fake_llm(prompt)

class LMStudioModel:
    # Real version: use LiteLLM with base_url="http://localhost:1234/v1"
    # and model="openai/gemma-3-4b-it". Here it falls back to the fake model
    # so the example runs offline with no LMStudio installed.
    def ask(self, prompt):
        print("(LMStudio not connected in this offline example - using fake model)")
        return fake_llm(prompt)

class Agent:
    def __init__(self, model):
        self.model = model
    def run(self, request):
        return self.model.ask(request)

for model in [FakeModel(), LMStudioModel()]:
    print(Agent(model).run("check stock of apples"))
print("Same agent, two models. No rewrite.")

Try it yourself

In the code, run the agent with the fake model, then with the LMStudio model. What changes in the output?

Check

What is the Portability Principle?

Keep agent logic vendor-neutral, so you can swap models without rewriting the agent.

What do ADK, LiteLLM, LMStudio, and Gemma each do?

ADK builds agents, LiteLLM connects to many models with one call, LMStudio runs models locally, Gemma is an open model.

Back to contents

Learn: Migrating a Local Agent to the Cloud Cleanly

What it is

Migrating means moving the same agent from your computer to the cloud. Cleanly means only the settings change, not the agent. Locally, the model is LMStudio and Gemma, and the tools are local files. In the cloud, the model is a cloud model, and the tools are the same MCP tools, reached over the network. The agent, its instructions, its memory, and its skills are the same. If your migration needs a rewrite, the agent was not portable. Fix the adapter, not the agent.

Why it matters

A clean migration is fast and safe. A messy one is where bugs and security holes appear.

Note: Swap note: to use LMStudio, LiteLLM, or a real cloud model, replace fake_llm with the real call shown in Setup. No key or cloud account is needed to follow this workshop.

Python — copy and run
# A small simulated model. It does NOT call the internet.
# It reads keywords and returns a fixed, clear answer.
# Every example in this workshop runs offline, with no API key.
def fake_llm(prompt):
    text = prompt.lower()
    if "stock" in text and "apple" in text:
        return "ACTION: check_stock | ITEM: apples"
    if "stock" in text:
        return "ACTION: check_stock | ITEM: apples"
    if "add" in text or "restock" in text:
        return "ACTION: add_stock | ITEM: apples | AMOUNT: 10"
    if "low" in text:
        return "ACTION: list_low_stock"
    if "research" in text:
        return "PLAN: search, then write, then review"
    if "hello" in text or "hi" in text:
        return "Hello! I am your agent. How can I help?"
    return "I will check that for you step by step."

# Migrate local to cloud cleanly: only the config changes, not the agent.
# Local: model = LMStudio, tools = local files. Cloud: model = cloud model,
# tools = the same MCP tools, now reached over the network.
import os

def build_model(where):
    if where == "local":
        return "LMStudio / Gemma (local, free, private)"
    return "Cloud model (paid, needs an account in real life)"

def build_agent(where):
    model = build_model(where)
    print(f"Agent running in: {where}, model: {model}")
    return fake_llm("check stock of apples")

print(build_agent("local"))
print(build_agent("cloud"))
print("The agent code is the same. Only build_model() changed.")

Try it yourself

Change the word 'local' to 'cloud' in the build_agent call and run the code again.

Check

What should change when you migrate to the cloud?

Only the settings: which model, and where the tools live.

What should NOT change?

The agent code, its instructions, memory, and skills.

Back to contents

Learn: Connecting to Enterprise Context and APIs Through MCP

What it is

MCP, the Model Context Protocol, is a standard plug for tools. The agent asks the MCP server for a tool, the server runs it, and returns the result. The agent never touches the file, the database, or the company API directly. That matters for enterprise context: the company's data stays behind the MCP server, and the server decides what the agent may see. The same MCP tool can be used by a local agent and a cloud agent, because both speak the same protocol. In this workshop the MCP code uses a small stand-in server that runs offline; the real code uses the official MCP SDK, and the import lines are shown in the code notes.

Why it matters

Without a standard like MCP, every tool needs its own special code, and every new agent has to learn it again. With MCP, tools are plug-and-play.

Note: Swap note: to use LMStudio, LiteLLM, or a real cloud model, replace fake_llm with the real call shown in Setup. No key or cloud account is needed to follow this workshop.

Python — copy and run
# A small simulated model. It does NOT call the internet.
# It reads keywords and returns a fixed, clear answer.
# Every example in this workshop runs offline, with no API key.
def fake_llm(prompt):
    text = prompt.lower()
    if "stock" in text and "apple" in text:
        return "ACTION: check_stock | ITEM: apples"
    if "stock" in text:
        return "ACTION: check_stock | ITEM: apples"
    if "add" in text or "restock" in text:
        return "ACTION: add_stock | ITEM: apples | AMOUNT: 10"
    if "low" in text:
        return "ACTION: list_low_stock"
    if "research" in text:
        return "PLAN: search, then write, then review"
    if "hello" in text or "hi" in text:
        return "Hello! I am your agent. How can I help?"
    return "I will check that for you step by step."

# MCP: a standard plug for tools. The agent asks the MCP server for a tool,
# the server runs it, and returns the result. The agent never touches the
# file or API directly. Real code: from mcp import ClientSession, StdioServerParameters
# and the official MCP Python SDK. Below is a small stand-in that runs offline.

class MCPServer:
    def __init__(self):
        self.tools = {"check_stock": lambda item: f"{item}: 12 in stock."}
    def list_tools(self):
        return list(self.tools)
    def call_tool(self, name, item):
        return self.tools[name](item)

class MCPAgent:
    def __init__(self, server):
        self.server = server
    def run(self, request):
        print("Tools available:", self.server.list_tools())
        answer = fake_llm(request)
        if "check_stock" in answer:
            return self.server.call_tool("check_stock", "apples")
        return answer

print(MCPAgent(MCPServer()).run("check stock of apples"))

Try it yourself

Add a second tool to the MCP server in the code, for example list_low_stock, and call it.

Check

What is MCP, in plain words?

A standard plug that lets an agent use tools on a computer, safely.

Why does the agent not touch the data directly?

So the server can control what the agent may see and do.

Back to contents

Learn: Identity and Security: Service Accounts, IAM, Dynamic Scope Elevation, Secure Tool Execution

What it is

Identity means knowing who is asking. A service account is an identity for a program, not a person. IAM is the list of what that identity is allowed to do. Secure tool execution means checking that list before running a tool, never after. Dynamic scope elevation means asking for a bigger permission for one job only, then giving it back. For example, an agent may normally only read stock, but for one restock job it may ask for write permission, use it once, and lose it again. That way, a mistake or a bad prompt cannot do lasting damage.

Why it matters

Security is not an extra at the end. If an agent can call tools, it must be checked, or it can delete data, spend money, or leak secrets.

Note: Swap note: to use LMStudio, LiteLLM, or a real cloud model, replace fake_llm with the real call shown in Setup. No key or cloud account is needed to follow this workshop.

Python — copy and run
# A small simulated model. It does NOT call the internet.
# It reads keywords and returns a fixed, clear answer.
# Every example in this workshop runs offline, with no API key.
def fake_llm(prompt):
    text = prompt.lower()
    if "stock" in text and "apple" in text:
        return "ACTION: check_stock | ITEM: apples"
    if "stock" in text:
        return "ACTION: check_stock | ITEM: apples"
    if "add" in text or "restock" in text:
        return "ACTION: add_stock | ITEM: apples | AMOUNT: 10"
    if "low" in text:
        return "ACTION: list_low_stock"
    if "research" in text:
        return "PLAN: search, then write, then review"
    if "hello" in text or "hi" in text:
        return "Hello! I am your agent. How can I help?"
    return "I will check that for you step by step."

# Identity and security: every tool call is checked first.
# A service account is an identity for a program, not a person.
# IAM = the list of what that identity is allowed to do.
# Scope elevation = asking for a bigger permission, for one job only.

ALLOWED = {"shop-agent": ["check_stock", "list_low_stock"]}

def can_run(account, tool):
    return tool in ALLOWED.get(account, [])

def secure_call(account, tool, item):
    if not can_run(account, tool):
        return f"DENIED: {account} may not run {tool}."
    if tool == "check_stock":
        return f"{item}: 12 in stock. (run as {account})"
    return "Done."

print(secure_call("shop-agent", "check_stock", "apples"))
print(secure_call("shop-agent", "delete_all_stock", "apples"))
print(secure_call("unknown-agent", "check_stock", "apples"))
print("Rule: check permission first, run the tool second. Never the other way round.")

Try it yourself

Try calling secure_call with the tool 'delete_all_stock'. What happens, and why?

Check

What is a service account?

An identity for a program, not a person.

What is dynamic scope elevation?

Asking for a bigger permission for one job only, then giving it back.

Back to contents

Learn: Agent-to-Agent (A2A) Patterns: Delegation, Task Decomposition, State Management

What it is

A2A means agents talking to agents. The main pattern is Orchestrator to Worker to Reviewer. The Orchestrator splits a big job into small tasks and gives them out. A Worker does one task and returns a draft. The Reviewer checks the draft and either approves it or sends it back. Task decomposition is splitting the big job into small, clear pieces. State management is keeping one shared record of the job, so every agent knows what is done and what is left. In the code, state is a plain Python dictionary. In a real system it might be a database, but the idea is the same.

Why it matters

One agent cannot do everything well. A team of small, focused agents is easier to test, easier to fix, and can do bigger jobs.

Note: Swap note: to use LMStudio, LiteLLM, or a real cloud model, replace fake_llm with the real call shown in Setup. No key or cloud account is needed to follow this workshop.

Python — copy and run
# A small simulated model. It does NOT call the internet.
# It reads keywords and returns a fixed, clear answer.
# Every example in this workshop runs offline, with no API key.
def fake_llm(prompt):
    text = prompt.lower()
    if "stock" in text and "apple" in text:
        return "ACTION: check_stock | ITEM: apples"
    if "stock" in text:
        return "ACTION: check_stock | ITEM: apples"
    if "add" in text or "restock" in text:
        return "ACTION: add_stock | ITEM: apples | AMOUNT: 10"
    if "low" in text:
        return "ACTION: list_low_stock"
    if "research" in text:
        return "PLAN: search, then write, then review"
    if "hello" in text or "hi" in text:
        return "Hello! I am your agent. How can I help?"
    return "I will check that for you step by step."

# Agent-to-Agent (A2A): a team. Orchestrator splits the job, Worker does it,
# Reviewer checks it. They share one state dict, so nothing is lost.
# Real A2A uses messages between agents; here they are plain Python calls.

class Worker:
    def work(self, task):
        return f"Draft report about {task}: apples are in stock (12)."

class Reviewer:
    def review(self, draft):
        if "apples" in draft and "12" in draft:
            return "APPROVED: " + draft
        return "REJECTED: missing facts. Please redo."

class Orchestrator:
    def __init__(self):
        self.state = {}
    def run(self, job):
        self.state["job"] = job
        self.state["draft"] = Worker().work(job)
        self.state["final"] = Reviewer().review(self.state["draft"])
        return self.state["final"]

print(Orchestrator().run("apples"))

Try it yourself

Change the job in the code from 'apples' to 'bread report' and run it again.

Check

What does the Orchestrator do?

It splits the job and gives tasks to Workers.

What does the Reviewer do?

It checks the draft and approves it or sends it back.

Back to contents

Learn: Discovery Services: Register, Locate, and Route Tasks

What it is

Discovery means agents can find each other without hard-coded addresses. An agent registers itself in a registry, saying 'I am worker-apples, I can research and write.' When a task arrives, the Orchestrator asks the registry 'who can research?' and routes the task to the first agent in the list. Add a new agent, and the team can use it at once. Remove one, and the registry stops sending it work. No code changes are needed to add or remove an agent.

Why it matters

Hard-coded addresses break as soon as the system grows. Discovery lets the team grow and change safely.

Note: Swap note: to use LMStudio, LiteLLM, or a real cloud model, replace fake_llm with the real call shown in Setup. No key or cloud account is needed to follow this workshop.

Python — copy and run
# A small simulated model. It does NOT call the internet.
# It reads keywords and returns a fixed, clear answer.
# Every example in this workshop runs offline, with no API key.
def fake_llm(prompt):
    text = prompt.lower()
    if "stock" in text and "apple" in text:
        return "ACTION: check_stock | ITEM: apples"
    if "stock" in text:
        return "ACTION: check_stock | ITEM: apples"
    if "add" in text or "restock" in text:
        return "ACTION: add_stock | ITEM: apples | AMOUNT: 10"
    if "low" in text:
        return "ACTION: list_low_stock"
    if "research" in text:
        return "PLAN: search, then write, then review"
    if "hello" in text or "hi" in text:
        return "Hello! I am your agent. How can I help?"
    return "I will check that for you step by step."

# Discovery: agents register what they can do, and others find them by skill.
# No hard-coded addresses. Add a new agent, and the team can use it at once.

class Registry:
    def __init__(self):
        self.agents = {}
    def register(self, name, skills):
        self.agents[name] = skills
        print(f"Registered {name}: {skills}")
    def find(self, skill):
        return [name for name, skills in self.agents.items() if skill in skills]

registry = Registry()
registry.register("worker-apples", ["research", "write"])
registry.register("worker-prices", ["research", "prices"])
registry.register("reviewer-1", ["review"])
print("Who can research?", registry.find("research"))
print("Who can review?", registry.find("review"))
print("Route the task to the first agent in the list.")

Try it yourself

Register a new agent called 'worker-milk' with the skill 'research', then ask who can research.

Check

What is a discovery registry?

A list where agents register what they can do, so others can find them.

Why not hard-code agent addresses?

Because the team changes, and hard-coded addresses break when it does.

Back to contents

Learn: Deploying to a Serverless Cloud Platform and Observing Agent Loops, Tool Calls, Latency, and Cost

What it is

Serverless means your agent runs as a small function in the cloud. The cloud starts it when a request arrives, and stops it after. You pay only while it runs. Observability means you can see what happened: the agent loop steps, the tool calls, the latency (how long it took), and the cost (how much money it spent). Tracing is the log of every step. Without observability, a slow or expensive agent is invisible until the bill arrives. In the code, the handler is a plain Python function that takes an event and returns an answer, with tracing, latency, and cost printed.

Why it matters

You cannot fix what you cannot see. Observability is what turns a cloud agent from a black box into a system you can run.

Note: Swap note: to use LMStudio, LiteLLM, or a real cloud model, replace fake_llm with the real call shown in Setup. No key or cloud account is needed to follow this workshop.

Python — copy and run
# A small simulated model. It does NOT call the internet.
# It reads keywords and returns a fixed, clear answer.
# Every example in this workshop runs offline, with no API key.
def fake_llm(prompt):
    text = prompt.lower()
    if "stock" in text and "apple" in text:
        return "ACTION: check_stock | ITEM: apples"
    if "stock" in text:
        return "ACTION: check_stock | ITEM: apples"
    if "add" in text or "restock" in text:
        return "ACTION: add_stock | ITEM: apples | AMOUNT: 10"
    if "low" in text:
        return "ACTION: list_low_stock"
    if "research" in text:
        return "PLAN: search, then write, then review"
    if "hello" in text or "hi" in text:
        return "Hello! I am your agent. How can I help?"
    return "I will check that for you step by step."

# Serverless deploy: your agent runs as a small function in the cloud.
# The cloud starts it when a request arrives, and stops it after.
# You pay only while it runs. Tracing = a log of every step and tool call.
import time

def trace(step, detail):
    print(f"[trace] {step}: {detail}")

def handler(event):
    start = time.time()
    trace("start", event.get("task", "no task"))
    answer = fake_llm(event.get("task", ""))
    trace("model", answer)
    trace("tool", "check_stock -> apples = 12")
    cost = 0.001  # example cost in dollars for this run
    latency = round(time.time() - start, 3)
    print(f"Latency: {latency}s. Cost: ${cost:.3f}.")
    return {"answer": "We have 12 apples in stock.", "latency_s": latency, "cost_usd": cost}

print(handler({"task": "check stock of apples"}))
print("In real life this function runs on a serverless platform,")
print("not on your computer. The code is the same shape.")

Try it yourself

Change the task in the handler call to 'check stock of bread' and run it again.

Check

What is serverless, in plain words?

Your code runs as a small function in the cloud, only when a request arrives.

What does observability show you?

The loop steps, tool calls, latency, and cost of each run.

Back to contents

Learn: Guardrails and Error Recovery: Failed Tool Calls, Graceful Degradation, Loop Prevention

What it is

Guardrails are rules that stop an agent from doing harm or wasting time. Error recovery is what the agent does when a tool fails: retry once, then fall back to a safe answer, and never crash. Graceful degradation means doing less, but still doing something useful, for example answering 'I cannot check stock right now, please try again' instead of crashing. Loop prevention means a step limit, so the agent cannot repeat the same action forever. In the code, the loop stops after three steps, and a failed tool is retried once, then a safe answer is given.

Why it matters

Real tools fail: networks drop, files are missing, APIs are down. An agent that crashes on the first failure is not ready for production.

Note: Swap note: to use LMStudio, LiteLLM, or a real cloud model, replace fake_llm with the real call shown in Setup. No key or cloud account is needed to follow this workshop.

Python — copy and run
# A small simulated model. It does NOT call the internet.
# It reads keywords and returns a fixed, clear answer.
# Every example in this workshop runs offline, with no API key.
def fake_llm(prompt):
    text = prompt.lower()
    if "stock" in text and "apple" in text:
        return "ACTION: check_stock | ITEM: apples"
    if "stock" in text:
        return "ACTION: check_stock | ITEM: apples"
    if "add" in text or "restock" in text:
        return "ACTION: add_stock | ITEM: apples | AMOUNT: 10"
    if "low" in text:
        return "ACTION: list_low_stock"
    if "research" in text:
        return "PLAN: search, then write, then review"
    if "hello" in text or "hi" in text:
        return "Hello! I am your agent. How can I help?"
    return "I will check that for you step by step."

# Guardrails and error recovery: plan for failure, not just success.
# 1) Retry a failed tool once. 2) Fall back to a safe answer.
# 3) Stop the loop after a few steps, so it cannot run forever.

def flaky_tool(tries):
    # Pretends to fail the first time, then work. Real tools do this too.
    if tries[0] == 0:
        tries[0] += 1
        raise RuntimeError("Tool failed: network error")
    return "apples: 12 in stock."

def run_with_guardrails(request):
    tries = [0]
    for step in range(1, 4):
        try:
            result = flaky_tool(tries)
            return f"Done on step {step}: {result}"
        except RuntimeError as error:
            print(f"Step {step} failed ({error}). Trying again...")
    return "Sorry, the tool is down. I cannot check stock right now."

print(run_with_guardrails("check stock of apples"))
print("Rule: retry once, then give a safe answer. Never loop forever.")

Try it yourself

Change the step limit in the code from 3 to 2 and run it again. What changes?

Check

What is graceful degradation?

Doing less, but still something useful, instead of crashing.

How do you prevent an endless loop?

Set a step limit, and stop when you reach it.

Back to contents

Part 3 — Hands-On Labs

Four labs. Each one builds on the last. Do them in order.

4 sections in this part.

Lab: Lab 1: Bootstrap a Local Agent

What it is

Set up ADK to run locally with the LiteLLM connector, LMStudio, and an open model. Build a functioning agent and test it on your own machine, with no cloud dependencies. Real setup, on your own machine: first, install LMStudio, download Gemma, and start its local server. Second, install the packages with pip install google-adk litellm. Third, point LiteLLM at LMStudio, with base_url http://localhost:1234/v1 and model openai/gemma-3-4b-it. The code below is the same agent with a stand-in model, so it runs offline here, with no LMStudio installed. Lab 1 is done when the agent answers on your machine, with no cloud.

Why it matters

If the agent does not work locally, it will not work in the cloud either. Local first is faster to test and free to run.

Note: Swap note: to use LMStudio, LiteLLM, or a real cloud model, replace fake_llm with the real call shown in Setup. No key or cloud account is needed to follow this workshop.

Python — copy and run
# A small simulated model. It does NOT call the internet.
# It reads keywords and returns a fixed, clear answer.
# Every example in this workshop runs offline, with no API key.
def fake_llm(prompt):
    text = prompt.lower()
    if "stock" in text and "apple" in text:
        return "ACTION: check_stock | ITEM: apples"
    if "stock" in text:
        return "ACTION: check_stock | ITEM: apples"
    if "add" in text or "restock" in text:
        return "ACTION: add_stock | ITEM: apples | AMOUNT: 10"
    if "low" in text:
        return "ACTION: list_low_stock"
    if "research" in text:
        return "PLAN: search, then write, then review"
    if "hello" in text or "hi" in text:
        return "Hello! I am your agent. How can I help?"
    return "I will check that for you step by step."

# Lab 1: Bootstrap a local agent. ADK + LiteLLM + LMStudio + Gemma.
# Real setup (do this on your own machine, not here):
#   1. Install LMStudio, download Gemma, start its local server.
#   2. pip install google-adk litellm
#   3. Point LiteLLM at LMStudio: base_url="http://localhost:1234/v1"
# Below is the same agent with a stand-in model, so it runs offline.

class LocalAgent:
    def __init__(self, model_name="gemma-3-4b-it (LMStudio)"):
        self.model_name = model_name
        self.memory = []
    def run(self, request):
        print(f"Model: {self.model_name} (local, no cloud)")
        answer = fake_llm(request)
        self.memory.append(answer)
        if "check_stock" in answer:
            return "apples: 12 in stock."
        return answer

agent = LocalAgent()
print(agent.run("check stock of apples"))
print(agent.run("hello"))
print("Lab 1 done when: the agent answers on your machine, with no cloud.")

Try it yourself

Run the code, then ask the agent about bread instead of apples.

Check

What three things do you need for Lab 1?

ADK, LiteLLM, and LMStudio with an open model like Gemma.

Why start with no cloud?

It is faster to test, free to run, and your data stays on your machine.

Back to contents

Lab: Lab 2: Move to the Cloud with Secure MCP Tools

What it is

Migrate your portable agent into a cloud environment and equip it with secure, authenticated, MCP-enabled tools, wired up with proper service accounts and IAM. In real life this lab needs a cloud account, a service account, and IAM rules that say which tools that account may use. The agent code does not change. Only the model and the tool connection change. The code below shows the same checks, offline: the MCP server checks IAM before every tool call, and a tool the account is not allowed to use is denied. Lab 2 is done when the same agent works in the cloud, and a forbidden tool is denied.

Why it matters

Moving to the cloud without security is how data leaks and bills explode. IAM first, tools second.

Note: Swap note: to use LMStudio, LiteLLM, or a real cloud model, replace fake_llm with the real call shown in Setup. No key or cloud account is needed to follow this workshop.

Python — copy and run
# A small simulated model. It does NOT call the internet.
# It reads keywords and returns a fixed, clear answer.
# Every example in this workshop runs offline, with no API key.
def fake_llm(prompt):
    text = prompt.lower()
    if "stock" in text and "apple" in text:
        return "ACTION: check_stock | ITEM: apples"
    if "stock" in text:
        return "ACTION: check_stock | ITEM: apples"
    if "add" in text or "restock" in text:
        return "ACTION: add_stock | ITEM: apples | AMOUNT: 10"
    if "low" in text:
        return "ACTION: list_low_stock"
    if "research" in text:
        return "PLAN: search, then write, then review"
    if "hello" in text or "hi" in text:
        return "Hello! I am your agent. How can I help?"
    return "I will check that for you step by step."

# Lab 2: Move to the cloud with secure MCP tools.
# Real setup needs a cloud account, a service account, and IAM rules.
# The code below runs offline and shows the same checks.

ALLOWED = {"cloud-agent": ["check_stock", "list_low_stock"]}
class CloudMCPServer:
    def call_tool(self, account, tool, item):
        if tool not in ALLOWED.get(account, []):
            return "DENIED by IAM."
        return f"{item}: 12 in stock. (secure MCP call as {account})"

server = CloudMCPServer()
print(server.call_tool("cloud-agent", "check_stock", "apples"))
print(server.call_tool("cloud-agent", "delete_all_stock", "apples"))
print("Lab 2 done when: the same agent works in the cloud,")
print("and a tool it is not allowed to use is denied.")

Try it yourself

Try calling the server with a different account name. What happens?

Check

What changes in Lab 2, and what stays the same?

The model and the tool connection change. The agent code stays the same.

What does IAM check before a tool runs?

Whether that service account is allowed to run that tool.

Back to contents

Lab: Lab 3: Build a Coordinated Multi-Agent Network

What it is

Build an Orchestrator to Worker to Reviewer system where agents delegate tasks, share state, and communicate end to end. Extended lab time is set aside so everyone gets their agents talking to each other. The Orchestrator takes the job, the Worker writes a draft, the Reviewer checks it, and the shared state dictionary holds the job, the draft, and the final answer, so nothing is lost. If the Reviewer rejects the draft, the Worker must redo it. That is the whole point of a Reviewer: a second pair of eyes. Lab 3 is done when all three agents talk, share state, and the Reviewer can reject a bad draft.

Why it matters

A network is more than three agents in one file. It is delegation, shared state, and a check at the end.

Note: Swap note: to use LMStudio, LiteLLM, or a real cloud model, replace fake_llm with the real call shown in Setup. No key or cloud account is needed to follow this workshop.

Python — copy and run
# A small simulated model. It does NOT call the internet.
# It reads keywords and returns a fixed, clear answer.
# Every example in this workshop runs offline, with no API key.
def fake_llm(prompt):
    text = prompt.lower()
    if "stock" in text and "apple" in text:
        return "ACTION: check_stock | ITEM: apples"
    if "stock" in text:
        return "ACTION: check_stock | ITEM: apples"
    if "add" in text or "restock" in text:
        return "ACTION: add_stock | ITEM: apples | AMOUNT: 10"
    if "low" in text:
        return "ACTION: list_low_stock"
    if "research" in text:
        return "PLAN: search, then write, then review"
    if "hello" in text or "hi" in text:
        return "Hello! I am your agent. How can I help?"
    return "I will check that for you step by step."

# Lab 3: Build a coordinated multi-agent network.
# Orchestrator -> Worker -> Reviewer, with shared state and end-to-end talk.
class Worker:
    def work(self, task):
        return f"Draft about {task}: apples in stock (12), bread low (3)."
class Reviewer:
    def review(self, draft):
        return "APPROVED: " + draft if "12" in draft else "REJECTED: redo."
class Orchestrator:
    def run(self, job):
        state = {"job": job}
        state["draft"] = Worker().work(job)
        state["final"] = Reviewer().review(state["draft"])
        print("Shared state:", state)
        return state["final"]

print(Orchestrator().run("apples report"))
print("Lab 3 done when: all three agents talk, share state,")
print("and the Reviewer can reject a bad draft.")

Try it yourself

Make the Worker write a draft without the number 12, and see what the Reviewer does.

Check

What three agents are in Lab 3?

Orchestrator, Worker, and Reviewer.

What is shared state, and why does it matter?

One shared record of the job, so every agent knows what is done and what is left.

Back to contents

Lab: Lab 4: Deploy to Production with Observability

What it is

Run your multi-agent system on a serverless platform, add tracing for agent loops and tool calls, track latency and cost, and put guardrails in place for graceful failure recovery. In real life, the handler code in this lab runs on a serverless platform, not on your computer, and the trace, latency, and cost go to a logging service. The code below shows the same shape, offline: every step is traced, the latency and cost are printed, and a failure still gives a polite answer, not a crash. Lab 4 is done when you can see the trace, the latency, and the cost, and a failure still gives a polite answer.

Why it matters

Deployment is not the end of the work. Observability and guardrails are what keep a deployed system alive.

Note: Swap note: to use LMStudio, LiteLLM, or a real cloud model, replace fake_llm with the real call shown in Setup. No key or cloud account is needed to follow this workshop.

Python — copy and run
# A small simulated model. It does NOT call the internet.
# It reads keywords and returns a fixed, clear answer.
# Every example in this workshop runs offline, with no API key.
def fake_llm(prompt):
    text = prompt.lower()
    if "stock" in text and "apple" in text:
        return "ACTION: check_stock | ITEM: apples"
    if "stock" in text:
        return "ACTION: check_stock | ITEM: apples"
    if "add" in text or "restock" in text:
        return "ACTION: add_stock | ITEM: apples | AMOUNT: 10"
    if "low" in text:
        return "ACTION: list_low_stock"
    if "research" in text:
        return "PLAN: search, then write, then review"
    if "hello" in text or "hi" in text:
        return "Hello! I am your agent. How can I help?"
    return "I will check that for you step by step."

# Lab 4: Deploy to production with observability.
# Serverless + tracing + latency and cost + guardrails + graceful failure.
import time
TRACE = []
def trace(step, detail):
    TRACE.append((step, detail))
    print(f"[trace] {step}: {detail}")

def deploy_handler(event):
    start = time.time()
    trace("start", event["task"])
    try:
        answer = fake_llm(event["task"])
        trace("model", answer)
        trace("tool", "check_stock -> apples = 12")
        result = "We have 12 apples in stock."
    except Exception as error:
        trace("error", str(error))
        result = "Sorry, the service is busy. Please try again."
    latency = round(time.time() - start, 3)
    print(f"Latency: {latency}s. Cost: $0.001. Trace steps: {len(TRACE)}.")
    return result

print(deploy_handler({"task": "check stock of apples"}))
print("Lab 4 done when: you can see the trace, the latency, the cost,")
print("and a failure still gives a polite answer, not a crash.")

Try it yourself

Change the task in the deploy call to 'add 10 apples' and run it again.

Check

What three things do you track in Lab 4?

Latency, cost, and the trace of loop steps and tool calls.

What should happen when a tool fails in production?

A polite, safe answer, not a crash.

Back to contents

Part 4 — Who, Prerequisites, and What You Take Away

Who this workshop is for, what you need before you start, and what you leave with.

2 sections in this part.

Workshop: Who Should Attend, and Prerequisites

What it is

This workshop is for software engineers, platform and infrastructure engineers, backend developers, and ML and AI practitioners who want to move from agent prototypes to systems they can actually deploy and operate. It is especially useful if you have already built an agent or two and now want to understand portability, security, multi-agent coordination, and production deployment. You should be comfortable with intermediate Python, meaning classes, async programming, and API requests; basic cloud infrastructure concepts, meaning service accounts, IAM, and serverless compute; and LLMs and basic prompting, with no advanced AI or maths required.

Why it matters

The prerequisites are there so the labs are about agents, not about learning Python from zero. If one item is missing, read that lesson first.

Note: Swap note: to use LMStudio, LiteLLM, or a real cloud model, replace fake_llm with the real call shown in Setup. No key or cloud account is needed to follow this workshop.

Python — copy and run
# A small simulated model. It does NOT call the internet.
# It reads keywords and returns a fixed, clear answer.
# Every example in this workshop runs offline, with no API key.
def fake_llm(prompt):
    text = prompt.lower()
    if "stock" in text and "apple" in text:
        return "ACTION: check_stock | ITEM: apples"
    if "stock" in text:
        return "ACTION: check_stock | ITEM: apples"
    if "add" in text or "restock" in text:
        return "ACTION: add_stock | ITEM: apples | AMOUNT: 10"
    if "low" in text:
        return "ACTION: list_low_stock"
    if "research" in text:
        return "PLAN: search, then write, then review"
    if "hello" in text or "hi" in text:
        return "Hello! I am your agent. How can I help?"
    return "I will check that for you step by step."

# Who should attend, and prerequisites — check yourself in code.
# Intermediate Python: classes, async, API requests.
# Basic cloud: service accounts, IAM, serverless.
# LLMs and basic prompting: no advanced maths needed.
skills = {"classes": True, "async": True, "api_requests": True,
          "service_accounts": True, "iam": False, "serverless": True,
          "llms": True, "prompting": True}
missing = [k for k, v in skills.items() if not v]
print("Your skills:", skills)
print("Missing:", missing if missing else "nothing — you are ready.")
print("Tip: if IAM is missing, read the identity lesson first.")

Try it yourself

Run the code and change one skill to False. What does it tell you to do?

Check

Who is this workshop for?

Engineers and developers who have built an agent or two and want to deploy real systems.

What Python level do you need?

Intermediate: classes, async programming, and API requests.

Back to contents

Workshop: What You Will Take Away

What it is

After completing the workshop, you will have a complete, deployable codebase for a working multi-agent system; the infrastructure scripts to run the whole system in your own environment; a vendor-neutral architecture you can adapt to your own models and cloud; practical patterns for MCP tool integration, identity, and secure execution; and production-ready habits for observability, cost tracking, and guardrails. Keep this list. It is your checklist for your own project: if you can tick every item, you have a production-ready system, not just a demo.

Why it matters

A workshop is only useful if you leave with something you can use on Monday. This list is that something.

Note: Swap note: to use LMStudio, LiteLLM, or a real cloud model, replace fake_llm with the real call shown in Setup. No key or cloud account is needed to follow this workshop.

Python — copy and run
# A small simulated model. It does NOT call the internet.
# It reads keywords and returns a fixed, clear answer.
# Every example in this workshop runs offline, with no API key.
def fake_llm(prompt):
    text = prompt.lower()
    if "stock" in text and "apple" in text:
        return "ACTION: check_stock | ITEM: apples"
    if "stock" in text:
        return "ACTION: check_stock | ITEM: apples"
    if "add" in text or "restock" in text:
        return "ACTION: add_stock | ITEM: apples | AMOUNT: 10"
    if "low" in text:
        return "ACTION: list_low_stock"
    if "research" in text:
        return "PLAN: search, then write, then review"
    if "hello" in text or "hi" in text:
        return "Hello! I am your agent. How can I help?"
    return "I will check that for you step by step."

# What you will take away: a codebase, scripts, and habits.
TAKEAWAYS = [
    "Complete, deployable multi-agent codebase",
    "Infrastructure scripts to run it in your own environment",
    "Vendor-neutral architecture (swap models without a rewrite)",
    "MCP and identity patterns (secure, authenticated tools)",
    "Production habits: observability, cost tracking, guardrails",
]
for item in TAKEAWAYS:
    print("[x]", item)
print(fake_llm("check stock of apples"))
print("Keep this list. It is your checklist for your own project.")

Try it yourself

Pick one takeaway and write one sentence about how you would use it in your own project.

Check

What is the most important takeaway?

A complete, deployable multi-agent codebase, plus the scripts to run it.

What does vendor-neutral mean for your takeaway?

You can adapt the architecture to your own models and cloud, without a rewrite.

Back to contents

Capstone — the full multi-agent system

Your capstone is the code below: one system that runs locally and deploys to the cloud. It reuses everything: the portable agent, MCP tools, IAM checks, Orchestrator to Worker to Reviewer, discovery, serverless shape, tracing, cost, and guardrails. Copy it, save it as capstone.py, run it with python3 capstone.py, and tick each item when it works.

Note: Swap note: to use LMStudio, LiteLLM, or a real cloud model, replace fake_llm with the real call shown in Setup. No key or cloud account is needed to follow this workshop.

Python — capstone, copy and run
# A small simulated model. It does NOT call the internet.
# It reads keywords and returns a fixed, clear answer.
# Every example in this workshop runs offline, with no API key.
def fake_llm(prompt):
    text = prompt.lower()
    if "stock" in text and "apple" in text:
        return "ACTION: check_stock | ITEM: apples"
    if "stock" in text:
        return "ACTION: check_stock | ITEM: apples"
    if "add" in text or "restock" in text:
        return "ACTION: add_stock | ITEM: apples | AMOUNT: 10"
    if "low" in text:
        return "ACTION: list_low_stock"
    if "research" in text:
        return "PLAN: search, then write, then review"
    if "hello" in text or "hi" in text:
        return "Hello! I am your agent. How can I help?"
    return "I will check that for you step by step."

# Capstone: the full multi-agent system. Runs locally, deploys to cloud.
# Orchestrator -> Worker -> Reviewer, discovery, MCP tools, guardrails,
# tracing, latency and cost. One file, no cloud account needed to run it.
import time

class Registry:
    def __init__(self):
        self.agents = {}
    def register(self, name, skills):
        self.agents[name] = skills
    def find(self, skill):
        return [n for n, s in self.agents.items() if skill in s]

class MCPTools:
    def check_stock(self, item):
        return {"apples": 12, "bread": 3, "milk": 0}.get(item, 0)

class Worker:
    def __init__(self, tools):
        self.tools = tools
    def work(self, task):
        stock = self.tools.check_stock("apples")
        return f"Report on {task}: apples in stock ({stock})."

class Reviewer:
    def review(self, draft):
        return "APPROVED: " + draft if "apples" in draft else "REJECTED."

def run_system(task):
    start = time.time()
    registry = Registry()
    registry.register("worker-1", ["research", "write"])
    registry.register("reviewer-1", ["review"])
    print("Discovery: researchers =", registry.find("research"))
    worker = Worker(MCPTools())
    draft = worker.work(task)
    print("Worker draft:", draft)
    final = Reviewer().review(draft)
    print("Reviewer:", final)
    print(f"Latency: {round(time.time() - start, 3)}s. Cost: $0.001.")
    return final

print(run_system("apples"))
print("Capstone done when: this runs locally, and you can point")
print("the same code at a cloud model and MCP server without rewriting it.")

Try it yourself

Change the task in the code from "apples" to "bread report" and run it again. Then add a second worker skill to the registry.

Check

What does the capstone reuse from the earlier parts?

The portable agent, MCP tools, IAM checks, Orchestrator to Worker to Reviewer, discovery, serverless shape, tracing, cost, and guardrails.

What changes to deploy it to the cloud?

Only the model adapter and the tool connection change. The agent, team, and guardrail code stay the same.

What to do next

Well done — you built a multi-agent system that runs locally and is ready for the cloud.

  1. Keep your capstone code. Add one new tool of your own, for example a tool that returns the total value of the stock.
  2. Try the same system for a different shop: change the items, keep the Orchestrator, Worker, Reviewer, and tools the same.
  3. Next course in this repo: MCP for AI Agents: Tools, Servers and Clients, in the Workshop folder. You already know MCP from this workshop, so you can focus on the TypeScript SDK and the real MCP server and client.
  4. After MCP, the repo also has the multi-agent financial agents workshop, in the Workshop folder under Multi-Agent Systems with Harness Engineering. That is the next big step: a real multi-agent system for finance.

Back to the top