ExamplescriptintermediateRunnableresearch-brief
Search Handbook
Runnable example (intermediate) for script.
Key Facts
- Level
- intermediate
- Runtime
- Python
- Pattern
- Context-backed research with explicit evidence
- Interaction
- Live sandbox • Script
- Updated
- 14 March 2026
Navigate this example
Library
Browse examplesReopen the wider library to compare adjacent patterns and linked learning paths.Interaction
Run sandbox nowTry the interaction directly in this example’s guided sandbox surface.Source
Open full sourceRead the real implementation, highlighted checkpoints, and runtime requirements.MCP
Call via MCPUse the same resource inside agents, deterministic exports, and MCP setup flows.
Linked principles
search_handbook.py
python
from pathlib import Path
HANDBOOK_PATH = Path(__file__).parent.parent / "data" / "handbook.md"
def search_handbook(query: str) -> str:
"""Retrieve the handbook content for the agent to interpret.
Note: The query parameter is accepted but not used - we return the full handbook.
This simulates Retrieval Augmented Generation (RAG). In a real application with
large handbooks or contexts, you would implement semantic search, filtering, or
chunking to retrieve only relevant sections based on the query.
"""
if not HANDBOOK_PATH.exists():
return "Handbook not found."
return HANDBOOK_PATH.read_text(encoding="utf-8")
def get_tool_definition():
return {
"type": "function",
"name": "search_handbook",
"description": "Retrieve the AI implementation handbook content. Use this when the user asks questions about AI implementation requirements, regulations, or procedures.",
"parameters": {
"type": "object",
"properties": {
"query": {
"type": "string",
"description": "The question or query - used for context, but the full handbook will be returned",
},
},
"required": ["query"],
"additionalProperties": False,
},
"strict": True,
}
Related principles
- P4trustApply progressive disclosure to system agencyProvide the minimum information necessary by default, while enabling users to inspect additional detail when confidence, understanding, or intervention is required.Open principle →
- P6visibilityExpose meaningful operational state, not internal complexityPresent the state of the system in language and structures that are relevant to the user, rather than exposing low-level internals that do not support action or understanding.Open principle →
- P7trustEstablish trust through inspectabilityUsers should be able to examine how a result was produced when confidence, accountability, or decision quality is important.Open principle →
- P9orchestrationRepresent delegated work as a system, not merely as a conversationWhere work involves multiple steps, agents, dependencies, or concurrent activities, it should be represented as a structured system rather than solely as a message stream.Open principle →