Browse by problem
Find examples by the agentic design failure mode they prevent.
Delegation failures
Examples in this group address agents that act without a clear boundary: taking destructive actions without approval, assuming intent from incomplete context, or proceeding past failure without surfacing it. Look for examples tagged with the delegation cluster principles.
Visibility failures
Visibility failures include: background tasks that run silently with no progress feedback, async operations that complete with no confirmation, and agents that show internal state (log lines, token counts) instead of meaningful operational state. Examples in this group show the correct pattern for each failure type.
Trust and orchestration failures
Trust failures: actions that cannot be undone, handoffs without explicit user awareness, and approval flows that are bypassed under time pressure. Orchestration failures: pipelines that do not degrade gracefully, subagent errors that surface as generic failures, and output types that are not inspectable. Use examples.search via MCP to filter by cluster.
Agentic design patterns7
Corrective RAG: grade what you retrieved before you answer
Every retrieved passage is graded for relevance, the failures are discarded, and the answer is written only from what survived. If nothing survives, the pattern refuses to answer rather than inferring from unrelated context.
Dry-Run: simulate before you execute
The agent proposes an action, a simulator predicts its effect and reversibility, and a deterministic policy gate decides whether it runs. The model never reaches the real function; the boundary is an `if` in Python, not an instruction it can talk past.
Episodic and semantic memory: remember turns, and remember facts
Two stores answering different questions. Episodic keeps what was said and when; semantic keeps extracted, deduplicated facts about the user. Retrieval defaults to facts, and reaches for transcripts only when the question is genuinely about what happened.
ReAct: reason, act, observe, repeat
The model alternates between explicit reasoning and tool calls, feeding each observation back until it can answer. The reasoning is a first-class inspectable field rather than something that happened inside the model, and that is what separates ReAct from plain tool-calling.
Model calls and outputs31
Introduction
Runnable example (beginner) for script using openai, python-dotenv.
Making Requests
Runnable example (beginner) for script using openai.
Streaming
Runnable example (beginner) for script using openai.
Introduction
Runnable example (beginner) for script using openai.
Agent patterns12
Level 1: Augmented LLM — Single API Call
One model call with structured output, system prompt, and context. No loops, no tools.
Level 2: Prompt Chains & Routing — Deterministic DAGs
Multiple LLM calls in a fixed sequence. Code controls the flow, not the model.
Level 3: Tool-Calling Agent — Scoped Autonomy
The agent decides which tools to call and in what order, but only within a fixed set of well-defined capabilities.
Level 4: Agent Harness — Full Runtime Access
Give the agent a full runtime via the agent runtime SDK. It can search files, read docs, and reason through problems autonomously.
Workflow and orchestration8
Basic
Runnable example (beginner) for script using openai.
Structured
Runnable example (beginner) for script using openai, pydantic.
Tools
Runnable example (beginner) for script using openai, pydantic.
Retrieval
Runnable example (beginner) for script using openai, pydantic.
MCP tool use14
Client Sse
Runnable example (advanced) for script using mcp.
Client Stdio
Runnable example (advanced) for script using mcp.
Client Streamable Http
Runnable example (advanced) for script using mcp.
Server
Runnable example (advanced) for script using mcp, python-dotenv.
Knowledge and retrieval11
Extraction
Runnable example (intermediate) for script using docling, ipykernel.
Chunking
Runnable example (intermediate) for script using docling, ipykernel.
Embedding
Runnable example (intermediate) for script using docling, ipykernel.
Search
Runnable example (intermediate) for script using docling, ipykernel.
Framework integrations10
Tutorial: Notebook to Web App in Five Minutes
This notebook shows how to turn a small Python function into a shareable interface with Gradio or Streamlit. It focuses on one clear input -> processing -> output flow so the app wrapper stays explicit and easy to review.
Quickstart
Runnable example (beginner) for script using pydantic.
Agents
Runnable example (intermediate) for script.
Dependencies
Runnable example (intermediate) for script using pydantic.
Context management10
Get Single Page
Runnable example (intermediate) for script using docling, openai.
Web Search
Runnable example (intermediate) for script using docling, openai.
Search Handbook
Search Agent
Runnable example (intermediate) for script using docling, openai.
Also in this section