For installation, workspace setup, and the full development lifecycle, see the SDK overview. This page walks through two complete examples.
Example 1: Banking Assistant
A single-agent banking assistant with custom Python tools and a session-scoped memory store for account data.Overview
The assistant handles three tasks:- Check account balances
- Transfer funds between accounts
- Answer general banking questions
Implementation
1. Define Custom Tools
Tools are async Python functions registered with@Tool.register. They access session memory and emit structured logs via RequestContext and Logger.
2. Define Memory Store
A session-scoped memory store holds account data and is referenced by the agent prompt using{{memory.accountInfo.accounts}}.
3. Define Agent
4. Create Custom Orchestrator
5. Build Application
6. Start Application
Testing
Project Structure
Key Takeaways
- Modular design - Separate tools, agents, and orchestration into distinct files
- Memory integration - Use memory stores to inject account context directly into agent prompts
- Comprehensive logging - Track all operations using
Logger - Security - Never request passwords or PINs; always confirm amounts before executing transfers
Example 2: Multi-Agent Customer Service
A customer service application that routes requests across three specialized agents and handles escalation between them.Overview
Three agents cover distinct domains:- SupportAgent - Handles general inquiries
- BillingAgent - Manages payments and billing
- TechnicalAgent - Resolves technical issues
Application Architecture
Implementation
1. Define Specialized Agents
Each agent is scoped to a domain and equipped with the MCP tools it needs.2. Create Multi-Agent Orchestrator
The orchestrator uses keyword matching to route requests and detects signals in agent responses to trigger escalation.3. Build Application
4. Start Application
Workflow Examples
Billing query:Testing
Best Practices
- Agent specialization - Keep each agent focused on a single domain.
- Clear routing - Implement routing logic with sensible fallbacks for unmatched queries.
- Escalation paths - Define explicit signals (for example.
"unable to","need specialist") for inter-agent escalation. - Memory usage - Share data across agents via memory stores rather than passing it in messages.
- Error handling - Handle failures gracefully at each level of the orchestration chain.