TimoBy Amotion AI

Agent Patterns and Frameworks: CCDV-F study guide

CCDV-F · Agents and Workflows, topic weight 4.9% of the exam

Agent Patterns and Frameworks sits in Domain 1, Agents and Workflows (14.7% of the CCDV-F exam), with a topic weight of 4.9%. It tests whether you know the four building blocks every Claude agent is made of (the tool-use loop, subagents, memory and context-window management) and whether a third-party agent framework helps or gets in the way.

What the official guide covers

The Claude Certified Developer Foundations exam guide (version 1.0, effective July 2026) describes this topic as common agent design patterns and agentic abstraction frameworks for multi-step tasks:

What the guide listsWhat it means in practice
Tool-use loopsClaude calls tools, your code or the SDK runs them, results go back, and the loop repeats until Claude finishes
Sub-agentsSeparate agent instances with their own context, used to isolate, parallelise or specialise work
MemoryInformation kept outside the context window so it survives across sessions or across compaction
Context-window managementKeeping the window useful as it fills: clearing old tool results, compacting history, counting tokens
Agentic abstraction frameworks (for example Strands, LangGraph, PydanticAI)Libraries that wrap model calls, tools and control flow; know what they add and what they hide

Pattern 1: the tool-use loop

Every agent is a loop: Claude returns tool_use blocks, the tools run, tool_result blocks go back, and the loop continues until stop_reason is end_turn. With the Messages API you write the loop, or the client SDK's beta tool runner drives it. The Claude Agent SDK has it built in, running read-only tools in parallel and state-changing tools (Edit, Write, Bash) one at a time. Mechanics are in CCAR-F 1.1.

Two habits make the loop work. It ends on a success check, a step limit or an error, not only when Claude decides it is done. And the agent builds its picture of the world through tools rather than a long prompt: it reads before it writes and checks the result after it acts, so every agent needs a tool that shows what its last action changed.

Pattern 2: subagents

A subagent is a separate agent instance with a fresh context window. In the Agent SDK it receives its own system prompt, project CLAUDE.md, its tools and the prompt the parent writes, never the parent's conversation, and only its final message returns. The SDK docs list four benefits: context isolation, parallel work, specialised instructions and tool restrictions. The cost: each hand-off loses whatever the parent forgot to write down. See CCAR-F 1.3 for how context is passed.

Pattern 3: memory

Memory is anything the agent can read back later that is not in the current context window. Three forms matter:

Memory formWhere it livesWho writes it
Memory tool (Messages API)A /memories directory that your handler maps to real storageClaude, through view, create, str_replace, insert, delete and rename commands
CLAUDE.md filesProject and user files loaded at session startYou
Auto memory (Claude Code and the Agent SDK)~/.claude/projects/<project>/memory/, with a MEMORY.md indexClaude

The memory tool is client-side: Claude asks for file operations and your application performs them, so you choose the storage and must validate paths to block directory traversal. The Python SDK includes a ready-made local filesystem handler:

import os
import anthropic
from anthropic.tools import BetaLocalFilesystemMemoryTool

client = anthropic.Anthropic()
memory = BetaLocalFilesystemMemoryTool(base_path="./memory")   # /memories maps to this folder

runner = client.beta.messages.tool_runner(
    model=os.environ["CLAUDE_MODEL"],          # a pinned model ID from your config
    max_tokens=1024,
    messages=[{"role": "user", "content": "Remember that the customer Acme prefers email follow-ups."}],
    tools=[memory],
)
final_message = runner.until_done()           # the runner executes memory commands until Claude finishes
print(final_message.content)

Choose the memory scope at design time

Before picking a mechanism, decide what the agent must know when the next session starts. The shape of the sessions decides it, not what is quickest to write:

ScopeWhat survivesFitsWhat you give up
In-context onlyThe current conversation, until it endsOne short session that fits the window and is never resumedEverything at session end; cost grows with every turn
External storeRecords your code writes and reads back at session start or on demandA thread that continues over days, or state shared between users or agent instancesA read on each session and the code to manage it
SummarisedA condensed digest injected into the next sessionLong conversations that would outgrow the windowAny detail the summary leaves out, so avoid it while a session still needs exact code or values
StatelessNothingJobs that take an input, finish and closeAny follow-up that needs earlier work

The common trap is in-context memory chosen because a prototype ran as one long session. Production often runs many shorter sessions with replayed history, and the injected history alone can fill much of the window before the first tool call. Moving to an external store then happens under deadline pressure instead of at design time.

Pattern 4: context-window management

The context window holds the system prompt, tools, history and every tool input and output, and it does not reset between turns. The Claude API gives you several controls:

  • Context editing, tool result clearing. Clears older tool results once the context passes a trigger, keeping the most recent ones. It is a beta feature set in the context_management parameter.
  • Server-side compaction (beta). Summarises earlier parts of the conversation on the server so it can continue past the window limit.
  • Token counting. Estimate a request's size before you send it.
response = client.beta.messages.create(
    model=os.environ["CLAUDE_MODEL"],
    max_tokens=4096,
    messages=messages,
    tools=tools,
    betas=["context-management-2025-06-27"],
    context_management={"edits": [{
        "type": "clear_tool_uses_20250919",
        "keep": {"type": "tool_uses", "value": 3},      # keep the three most recent tool results
        "exclude_tools": ["memory"],                   # never clear memory reads
    }]},
)

If you compact by hand instead, your summariser prompt decides what the agent knows afterwards. "Summarise the conversation" tends to drop the state that matters; name it: files changed, decisions taken at each branch point, errors hit and how each was resolved, and open tasks.

A filling window rarely announces itself. The usual symptom is an agent that chooses tools well for several turns and then starts picking the wrong one or returning partial work, because old tool results have pushed the instructions out of focus. Before rewriting tool descriptions, check token use per turn. Development fixtures are usually much shorter than production tool outputs, so measure with the largest real inputs you can find, using token counting, before you ship.

Clearing and compaction remove detail, so pair them with memory for what must survive. The Agent SDK compacts automatically and emits a compact_boundary message; rules that must persist belong in CLAUDE.md, which is re-injected on every request. More on the Context Engineering page.

Frameworks: Strands, LangGraph and PydanticAI

The exam guide names three third-party frameworks as examples. Each one wraps model calls, tool definitions and control flow in its own abstractions:

FrameworkWhat its own documentation says it is
Strands AgentsAn open-source SDK published by AWS, for Python and TypeScript, built around a model-driven approach; Claude is one of its supported model providers
LangGraphA low-level orchestration framework and runtime for long-running, stateful agents, modelling a workflow as a graph of nodes and edges with shared state; it uses Claude through LangChain's Anthropic integration
Pydantic AIA Python agent framework from the Pydantic team with typed tools and validated structured output; Anthropic is one of its supported providers

Anthropic's guidance is the part most likely to be tested. Building effective agents names the Claude Agent SDK and the Strands Agents SDK among frameworks that simplify routine work such as calling the model, parsing tools and chaining calls. It recommends starting with the API directly, since many patterns take a few lines, and warns that extra abstraction can hide the real prompts and responses and make debugging harder. If you use a framework, understand the code underneath.

SituationChooseWhy
Two or three tools, a simple loopMessages API directlyA few lines of code; nothing hidden
Agent needs files, shell, subagents and compactionClaude Agent SDKThose patterns come built in
Team already standardised on a framework and its toolingThat framework, with request logging turned onReuse what the team knows, but keep the real prompts visible
Long session filling with old tool resultsContext editing plus the memory toolClear stale detail, keep durable facts
Facts must carry over to tomorrow's sessionMemory tool or CLAUDE.mdThe context window does not persist between sessions
Verbose sub-task pollutes the main contextSubagentOnly its summary returns to the parent

Rules that decide exam answers

  • Memory is not context, and the memory tool runs on your side. The window ends with the session; memory is what you store outside it. Claude asks for file operations, and your code executes them and checks paths.
  • Clearing and compaction lose detail. Pair them with memory for anything that must survive, and name that state in any summariser prompt you write.
  • Degrading tool choice after a fixed number of turns points at the window first. Check token use before you touch the schema.
  • Subagents isolate context by design. If a subagent needs something, it must be in the prompt the parent writes.
  • Start simple, then add a framework. Anthropic recommends direct API calls first; a framework is justified by what it saves, not by default.
  • Debug through the abstraction. When a framework-built agent misbehaves, inspect the actual requests and tool results it sends.

Where it appears in the exam

Agent Patterns and Frameworks is part of Domain 1, Agents and Workflows (14.7% of the exam), with a 4.9% topic weight, roughly two or three items on a 53-item exam. Expect scenarios about agents that degrade as sessions grow, forget facts between sessions, or get poor work from subagents, and teams choosing between direct SDK code and a framework.

Two sample questions

These are original Timo practice questions. They are not official exam questions.

Question 1

A research agent built on the Messages API runs for hours and calls a web search tool hundreds of times. Answers late in the session get worse, and the team notices the context is mostly old search results. Key facts found early must still be available at the end. What should the developer do?

Answer: D. Clearing removes stale search results while the memory tool keeps the facts that must survive. A makes the context larger, not smaller. B throws away the early findings the task needs. C limits output length, not the history that fills the window.

Question 2

A team built an agent with an agent framework. Claude sometimes calls a tool with the wrong argument names, and the team cannot tell why from the framework's own logs. Following Anthropic's guidance on frameworks, what should they do first?

Answer: B. Anthropic warns that framework abstractions can hide the real prompts and tool definitions, so the first step is to see what the model actually received. A swaps one abstraction for another without finding the cause. C hides the failure instead of fixing it. D adds guidance without knowing what is wrong.

Build exercise

  1. Run the memory tool example above twice in separate processes and confirm the second run reads the stored fact.
  2. Build a loop that calls a search tool 30 times. Add the context_management edit and log input tokens per request before and after.
  3. Move one verbose step (summarising ten files) into an Agent SDK subagent and compare the parent's context use with and without it.
  4. Rebuild the same two-tool agent in one framework from the guide's list. Turn on its request logging and find the exact tool definitions it sends to Claude.

Practise this topic

Sources