Phase 14: Agent Engineering

The Harness as a Library — Subagents and Session Store

A harness you can import: built-in tools, subagents for context isolation, hooks, W3C trace propagation, session persistence. The Claude Agent SDK is the reference example — the library form of the Claude Code harness — and Claude Managed Agents is the hosted alternative for long-running async work. Explain the difference between the Anthropic Client SDK (raw API) and the Claude Agent SDK (harness shape). Describe subagents — parallelization and context isolation — and when to reach for them. Name the Python SDK's session store surface (append, load, listsessions, delete, listsubkeys) and the role of --session-mirror. Implement a stdlib harness with built-in tools, subagent spawning with isolated context, lifecycle hooks, and a session store. A raw LLM API gets you one round-trip. A production agent needs tool execution, MCP servers, lifecycle hooks, subagent spawning, session persistence, trace propagation. Claude Agent SDK ships this shape as a library — the same harness Claude Code uses, exposed for custom agents. Client SDK (anthropic). Raw Messages API. You own the loop, the tools, the state. Agent SDK (claude-agent-sdk). Built-in tool execution, MCP connections, hooks, subagent spawning, session store. The Claude Code loop as a library. The SDK ships 10+ tools out of the box: file read/write, shell, grep, glob, web fetch, more. Custom tools register via the standard tool-schema interface. Two purposes documented by…

The Harness as a Library — Subagents and Session Store: A harness you can import: built-in tools, subagents for context isolation, hooks, W3C trace…

This free lesson is part of the AI Engineering from Scratch curriculum. Read the full explanation, run the lesson code, and verify the result in the interactive reader or from the repository source.

Browse the complete course catalog or open this lesson on GitHub.