Best practices
For tool-based search (Method 1)
- Dynamic content: Use for real-time searches and dynamic RAG applications
- Error handling: Return appropriate messages when searches fail
- Result limits: Return only the most relevant results to avoid context overflow
For top-level search (Method 2)
- Pre-fetched content: Use when you already have search results
- Batch processing: Ideal for processing multiple search results at once
- Testing: Great for testing citation behavior with known content
General best practices
Structure results effectively:
- Use clear, permanent source URLs
- Provide descriptive titles
- Break long content into logical text blocks to give Claude finer citation boundaries
Maintain consistency:
- Use consistent source formats across your application
- Ensure titles accurately reflect content
- Keep formatting consistent
Handle errors gracefully: when a search fails or returns nothing, return a plain text block describing the outcome (for example,
\{"type": "text", "text": "No results found."\}) instead of raising an error: Claude explains the empty result to the user, and the conversation continues.