Summary of Today’s Gen AI Classroom: Let the Framework Do the Plumbing – The Claude Agent SDK (28 Sep 2026)

Last week we did everything by hand: memory, parsing, and tool execution. Today we handed that work to a framework and built with the Claude Agent SDK.

1. How to Learn Any Agent SDK

Don’t memorise syntax. Every SDK has a different author and a different style, so .invoke in one means nothing in another. Learn the four interfaces instead:

  1. How do I specify the model?
  2. How do I attach a tool?
  3. How do I manage memory?
  4. How do I set limits?

Know those and moving to Gemini’s ADK or another kit is a small step.

2. What Makes This SDK Unusual

It doesn’t call the model over HTTP the way the low-level library does. It wraps the Claude Code CLI, passing JSON arguments to it under the hood.

  • There’s no agent object to construct, unlike LangChain. The CLI is the agent.
  • Authenticate with an API key, or with a Claude Code subscription (which has tighter daily limits).

3. Setup

uv add claude-agent-sdk      # or: pip install claude-agent-sdk
  • The Claude Code CLI comes bundled with the package. If you want to point at a system install instead, use ClaudeAgentOptions(cli_path="..."). That’s the fix for the Windows path problem we hit.
  • Keep your ANTHROPIC_API_KEY in .env and load it with os.getenv.
  • Never name your file claude.py. It shadows the package and imports break. Call it claude_test.py.
  • In VS Code, install the Python and Jupyter extensions.

4. Async in One Minute

  • Synchronous: each call blocks until it finishes.
  • Asynchronous: while one call waits on I/O, others keep running. Well-behaved code.
  • asyncio runs the event loop; await says “wait for this one before moving on.”

Notebook gotcha: asyncio.run() fails inside Jupyter because a loop is already running. Either await the call directly in the cell, or move to a .py file and use asyncio.run() there.

5. The Two Entry Points

Entry pointUse it for
query()Stateless, one-shot calls. No memory between calls.
ClaudeSDKClientStateful, interactive conversations.

We proved query() is stateless the same way as last week: it doesn’t remember your name. For continuity, use the client object, or pass continue_conversation=True / resume with a session ID.

6. Reading the Response

Messages come back in a hierarchy:

  • System message: setup and available tools
  • Assistant message: the model’s reply, as a list of content blocks
  • Result message: final metadata, including duration and cost in USD

Four block types: text, thinking, tool use, and tool result.

7. Cost: Set Your Model Explicitly

We asked the same trivial question on two models:

ModelCost for one simple query
Default (Opus)≈ $0.02
Haiku≈ $0.003

That’s roughly a 7x difference on a one-line question. Always set the model in ClaudeAgentOptions, and use max_turns to stop a tool-call loop running away. Then read the cost in the result message so you know what you spent.

8. Tools and Permissions

The SDK ships with the built-in Claude Code tools. We had it list every .py file in the directory without writing any tool code.

Permissions are the part to take seriously:

  • Read access is usually safe. Write and delete are not.
  • allowed_tools is an allowlist that auto-approves the tools you list. It does not remove the rest.
  • To actually block something, use disallowed_tools or set a stricter permission_mode.
  • An agent with unchecked write access on your machine is a bad day waiting to happen.

9. Where MCP Fits

Custom tools in this SDK are MCP components. Think of MCP as the type-C charger for tools: write the tool once, plug it into any compatible client. A two-week deep dive on building MCP servers is coming.

✅ Action Items

  1. Review the committed code and write your own version from scratch as reference.
  2. Run it under the debugger and watch the internal sequence of SDK calls.
  3. Compare Opus and Haiku on the same prompt and record the cost difference yourself.
  4. Try the built-in tools with read-only permissions before you allow anything to write.

Course update: class summaries are also going out as five-slide daily posts on the Quality Thought Instagram channel, mirroring LinkedIn.

⏭️ Next up: OpenAI agents and problem definition, then MCP servers and A2A communication.

By continuous learner

enthusiastic technology learner

1 comment

Leave a Reply

Discover more from Direct AI Powered By Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading