Authors:
- Olivier Zhang, AI Solutions Architect
- Adrien Delaroche, Principal Architect
- Jaysse Chen, AI Solutions Architect
The world of Web3 trading demands intelligent systems that can understand natural language, execute complex transactions safely, and maintain compliance across jurisdictions. Traditional bot architectures struggle with these requirements, often resulting in rigid, monolithic systems that are difficult to scale and maintain.
The good news: Google’s Agent Development Kit (ADK) transforms how we build trading systems. By leveraging ADK’s multi-agent architecture, developers can create sophisticated trading assistants that naturally understand user intent, execute trades safely, and scale effortlessly.
The pattern: We’ll explore architectural patterns that demonstrate how ADK can convert natural language queries like “Buy 0.1 BTC” or “Convert my ETH to SOL” into intelligent trading workflows—all while maintaining compliance and safety checks at every step.
In this post, we’ll explore how ADK’s unique features enable a new generation of intelligent Web3 trading applications through proven architectural patterns.
The power of ADK in Web3 trading
Traditional trading bots struggle with understanding user intent and are constrained by their limited, predefined functionality. ADK’s hierarchical multi-agent architecture excels at understanding user intent and intelligently routing tasks to specialized agents for execution. Here’s how ADK transforms Web3 trading:
1. Hierarchical Agent Architecture
ADK enables a clean separation of concerns through specialized agents with their dedicated tools:
Each agent is an expert in its domain:
- Root Agent (trading_assistant): Understands user intent and orchestrates the workflow
- Spot Agent: Specializes in buy/sell operations with dedicated trading tools
- Convert Agent: Handles direct crypto-to-crypto conversions
- Portfolio Agent: Manages balance queries and portfolio analytics
- Market Data Agent: Provides real-time pricing and exchange rate information
Note how agents share common tools (like get_price
and get_portfolio
), enabling efficient resource utilization while maintaining clear responsibilities.
2. Natural Language to Action
With ADK, users can trade using everyday language. The framework handles the complexity of understanding intent and routing to the right specialist:
3. Built-in Compliance and Safety
ADK’s callback system enables sophisticated compliance checks without cluttering your business logic:
root_agent = Agent(
name="trading_assistant",
before_agent_callback=load_user_profile, # Load user profile
before_model_callback=kyc_compliance_check, # Pre-execution checks
)
# Sub-agents can have more specific compliance checks
spot_agent = Agent(
name="spot_agent",
before_model_callback=[kyc_compliance_check, region_compliance_check],
before_tool_callback=trade_params_compliance_check, # Validate trade parameters
)
ADK’s hierarchical callbacks enable defense-in-depth compliance:
Three levels of progressive validation:
Coarse: Load context when agent starts
Medium: Validate compliance before LLM processing
Fine: Check parameters before tool execution
How to build trading agents with ADK
1. Orchestrate multiple specialized agents
ADK’s power for trading lies in its ability to orchestrate specialized agents. Each agent focuses on its expertise while working together seamlessly:
from google.adk.agents import Agent
# Define specialized agents for different trading operations
spot_agent = Agent(
name="spot_agent",
model="gemini-2.5-flash",
description="Handles spot trading operations",
instruction="""You are a cryptocurrency exchange spot trading expert, specializing in helping users execute buy and sell operations."""
)
# Create other specialized agents
convert_agent = Agent(...)
portfolio_agent = Agent(...)
market_data_agent = Agent(...)
# Root agent orchestrates through sub_agents
root_agent = Agent(
name="trading_assistant",
model="gemini-2.5-flash",
description="Trading assistant handling various trading requests",
instruction="You are a professional cryptocurrency trading assistant, skilled at understanding user trading needs and connecting them to the appropriate specialized agents.",
sub_agents=[
spot_agent,
convert_agent,
portfolio_agent,
market_data_agent,
],
before_agent_callback=load_user_profile, # Load user context
before_model_callback=kyc_compliance_check # Pre-execution checks
)
2. Implement compliance without complexity
ADK’s callback system enables sophisticated compliance checks without cluttering your business logic:
from google.adk.agents.callback_context import CallbackContext
from google.adk.models import LlmRequest, LlmResponse
from google.genai import types
def kyc_compliance_check(callback_context: CallbackContext,
llm_request: LlmRequest) -> Optional[LlmResponse]:
"""Pre-execution KYC validation"""
kyc_verified = callback_context.state.get("kyc_verified", False)
if not kyc_verified:
# ADK gracefully handles validation failures
return LlmResponse(
content=types.Content(
role="model",
parts=[types.Part(text="Please complete KYC verification")]
)
)
return None # Continue processing if KYC is verified
3. Maintain conversation state
ADK’s session management maintains user context throughout the conversation:
# Load and maintain user context in callbacks
def load_user_profile(callback_context):
# State persists across agent interactions
callback_context.state["user_id"] = user_id
callback_context.state["kyc_verified"] = kyc_status
callback_context.state["region"] = region
callback_context.state["restricted_coins"] = restrictions
# All agents can access this context
return None
Here’s how these three capabilities work together to enable sophisticated trading workflows:
The synergy between these capabilities enables:
- Intelligent Routing: Root agent understands intent and delegates to the right specialist
- Layered Security: Multiple compliance checkpoints ensure safe execution
- Context Awareness: State persists across the entire conversation, enabling personalized experiences
Bringing it all together
Google’s Agent Development Kit transforms Web3 trading by providing a sophisticated framework that combines three powerful capabilities:
-
Hierarchical Multi-Agent Architecture enables specialized agents to work together, each focusing on their domain expertise while sharing common tools.
-
Natural Language Understanding allows users to interact naturally, with ADK handling the complexity of intent analysis and routing.
-
Built-in Compliance and Safety ensures every transaction passes through multiple validation layers without complicating the core business logic.
Together, these capabilities create a trading experience that feels natural to users while maintaining the strict safety requirements of financial applications. ADK enhances the flexibility of traditional trading systems while dramatically improving user experience through intelligent natural language interfaces.