1.5 KiB
1.5 KiB
Common Agentic Patterns
Pattern 1: Sequential Workflow
Tools execute in sequence (search → book → confirm):
# User: "Book a flight to Paris"
# Agent executes:
1. search_flights(origin="SF", destination="Paris", ...)
2. book_flight(flight_id="F1", passengers=[...])
3. send_confirmation(confirmation_id="ABC123")
Pattern 2: Parallel Tool Execution
Multiple independent tools (flights + hotels):
# User: "Find flights and hotels for Paris trip"
# Agent can call in parallel (if your implementation supports it):
1. search_flights(destination="Paris", ...)
2. search_hotels(city="Paris", ...)
Pattern 3: Conditional Branching
Tool selection based on context:
# User: "Plan my trip"
# Agent decides which tools to call based on conversation:
if budget_conscious:
search_flights(class="economy")
else:
search_flights(class="business")
Important Reminders
- Always set
strict: true- This enables validation - Require
additionalProperties: false- Enforced by strict mode - Use enums for constrained values - Better than free text
- Clear descriptions matter - Claude uses these to decide when to call tools
- Tool inputs are guaranteed valid - No validation needed in tool functions
- Handle tool execution failures - External APIs can fail
- Test multi-step workflows - Edge cases appear in tool composition
- Monitor agent behavior - Track tool usage patterns and failures