Claude Agent SDK workshops

Back to Workshops

Guided JupyterLab workshops for the Claude Agent SDK for Python: what an agent is and how to run one, how to extend it, and how to build a chat application on it.

Run the workshops

These workshops run on your own machine only, so there is no Binder, Codespaces or in browser version to launch. The GitHub repository explains what you need and how to start them.

Agent foundations with the Claude Agent SDK

Guided JupyterLab workshops on what an AI agent is and how to run one with the Claude Agent SDK for Python: the agent loop, tools and their results, what a run costs, instructions, models, permissions, conversations, sessions, streaming and structured output.

10 workshops About 2h 35m python claude agents foundations
1 Run your first agent 15m

Find out what an AI agent is by running one with the Claude Agent SDK. Send a prompt and take apart the messages that come back, ask a question the model cannot answer on its own, then give it one tool and watch it read a file to get the answer.

2 Watch the agent loop 15m

Slow an agent's run down until each step can be seen. Ask a question that takes several tool calls, then take the run apart, to see what a request from the model is, who carries it out, how the result gets back, and why every request is larger than the one before.

3 Read what a run cost 15m

Open the message that ends every agent run. Read how the run ended and how much work it was, what the token counts mean, what the dollar figure is and is not on a subscription, and what comes back when a run is stopped by its turn limit before it finishes.

4 Give the agent its instructions 15m

Find out what a system prompt is and what the choice of one costs. Answer the same customer question under a prompt of your own, under the same prompt with one rule changed, and under the instructions Claude Code itself runs on, then compare what each sent to the model.

5 Choose a model and how hard it thinks 15m

Find out what the choice of model changes. Run one task that needs two documents read together on a small model and on a larger one, and compare the turns, tokens, time and estimated cost of each. Then lower the effort, and turn thinking back on to see what it adds.

6 Decide what the agent can do 20m

Find out how an agent's tools are given, approved and withheld. Give an agent a tool that writes a file and watch the call be refused, then allow it by name, allow it with a permission mode, and take the tool away again, reading from each result what was asked for, what was denied and what was written.

7 Hold a conversation 15m

Find out how an agent remembers what was said. See two separate runs know nothing of each other, then keep a client connected and hold a conversation of two turns on one session, measure what each turn was sent, and read how full the model's context window is.

8 Pick up where you left off 15m

Find out where a conversation goes when the program that held it ends. List the sessions the SDK keeps on disk and read one back, resume it from a new run that shares nothing with the first, fork it to try another way forward without changing the original, and delete what you made.

9 Stream the reply as it is written 15m

Find out how to show an answer while the model is still producing it. Time a reply that arrives all at once, turn on partial messages and count the events one reply is made of, print the text piece by piece as it is written, and compare the pieces with the complete message that follows them.

10 Get data back, not prose 15m

Find out how to use an agent as a function in a program. Ask for a shop's opening hours and see why a reply written for a person is hard for code to use, then describe the shape you want with a JSON Schema, get back a dictionary that matches it, and answer questions from it in ordinary Python.

Extending an agent with the Claude Agent SDK

Guided JupyterLab workshops on giving an agent built with the Claude Agent SDK for Python more to work with: your own tools, MCP servers, your own data, project instructions, skills, approvals, hooks, subagents and long sessions.

9 workshops About 2h 45m python claude agents tools
1 Give the agent a tool of your own 20m

Turn a Python function into a tool an agent can ask for. Decorate a stock lookup with @tool, put it in a server that runs inside your own program, and watch the agent call it. Then run the same question against a vague description and an honest one, add a second tool, and mark tools that only look so that the SDK runs them side by side.

2 Connect an MCP server 15m

Find out what the Model Context Protocol is by using it. Take a stock lookup that lives in a small server program of its own, have the SDK start it and connect to it, read its state and its tools with get_mcp_status(), ask the agent a question through it, and see how a server that fails to start is reported.

3 Answer from your own data 20m

Put what you know within an agent's reach, two ways. Have the agent search and read the shop's documents with its built-in tools, then build a small orders database and give the agent a tool that runs read-only queries on it. Ask a question that needs both, compare what each way costs, and learn what the SDK leaves for you to supply.

4 Give instructions that persist 15m

Keep an agent's standing instructions in a file. Put the shop's house rules in a CLAUDE.md, run the agent without them and then with setting_sources set to load them, see which files a session was given and what they add to every request, and learn what the option lets in and why the other workshops keep it empty.

5 Package know-how as a skill 15m

Give an agent a procedure it loads only when it needs it. Install the shop's way of answering a refund request as a skill, see that only its one line description is in the agent's context to begin with, watch the agent call the Skill tool when a refund comes up, and compare a request that needs the skill with one that does not.

6 Ask before acting 20m

Put a decision of your own in front of what an agent changes. Write a can_use_tool callback that stands in for a person, and watch it allow one call, refuse another with a reason the model then reads, and let a third through with its input changed. Then answer a clarifying question the agent asks through the same callback.

7 Put guardrails in code 20m

Find out what a prompt can only ask for and what code can enforce. Give an agent a rule in its system prompt and a request that argues with it, then enforce the same rule with a PreToolUse hook that refuses the call whatever the model was told, and keep a log of every tool call with a PostToolUse hook.

8 Hand work to subagents 20m

Give part of a job to a second agent. Have an agent read ten supplier files to answer one question, then define a subagent with AgentDefinition to do the reading and report back, compare what the main conversation holds each way, and run the main agent and the subagent on different models.

9 Keep a long session small 20m

See what fills an agent's context window and what is done about it. Measure a session by what is in it, fill it with tool results, compact it and read the summary that replaces the history, find out what survived, and then give an agent twenty tools and have their definitions wait until they are looked for.

Building a chat app with the Claude Agent SDK

Guided JupyterLab workshops that build a web chat application on the Claude Agent SDK for Python, a step at a time: a first reply, streaming, a conversation per visitor, showing the agent's work, approvals, tools, history and usage.

8 workshops About 2h 45m python claude agents web
1 Build the smallest chat app 20m

Put an agent behind a web page. Start a small web server written with FastAPI, see what a chat page and its server say to each other, replace the server's canned reply with a run of the agent, and find out what the application cannot do yet.

2 Stream the reply to the browser 20m

Show the agent's reply in a web page while the model is still writing it. Watch a reply arrive all at once, turn on partial messages and send each piece of text from the server as an event, read the raw stream in a terminal, then change the page to add each piece to the reply as it arrives.

3 Keep a conversation for each visitor 25m

Give a web chat a memory, and each visitor a conversation of their own. Have the page keep an id, keep a connected client on the server for each id, restore what was said when the page is reloaded, open a second visitor beside the first, and pick a conversation up again after the server restarts.

4 Show the agent at work 15m

Let a web chat show what its agent is doing. Watch a reply pause while the agent reads files, send the page an event for each tool request and each result, and draw them as lines in the conversation so that a pause reads as work.

5 Approve from the browser 25m

Let the person in a web chat decide what its agent may do. Give the agent a tool that writes files and see the write refused, have the server put each request to the page and wait for an answer with a time limit, show the request in the chat with buttons to allow or refuse it, and add a button that stops a run part way through.

6 Plug in your tools 20m

Give the assistant behind a web chat tools of the shop's own. Show in the page which tools the agent has, plug in a tool for the stock list and one in front of the orders database, approve each by name, install a skill for refund replies, and see each one used from the chat.

7 Come back to a conversation 20m

Let the people using a web chat find their conversations again. List the sessions the SDK has kept, show them in the page, open an earlier one by its id and carry on after the server has restarted, and branch a conversation into a copy that goes its own way.

8 Show usage and set limits 20m

Make a web chat say what it uses, and stop it using too much. Show under the conversation what each turn sent to the model and what it wrote, show how full the conversation's context is, let the person in the chat choose the model, and put a limit on the turns one message can take.