Skip to main content

Overview

The ADK (Agent Development Kit) TypeScript SDK (@iqai/adk) provides the foundation for building intelligent AI agents that can interact with blockchain protocols, monitor DeFi positions, and automate complex workflows. MetaVault AI uses ADK-TS to create autonomous agents that monitor vault strategies, manage risk, and execute transactions.

Installation

Required Dependencies

package.json

Core Imports

Agent Architecture

ADK-TS supports hierarchical agent architectures with:
  • Root Agent: Top-level coordinator that delegates to specialized sub-agents
  • Sub-Agents: Specialized agents with specific tools and responsibilities
  • Tools: Functions that agents can call to interact with external systems

Root Agent Pattern

src/agents/agent.ts

Sub-Agent Pattern

src/agents/sub-agents/strategy-sentinel-agent/agent.ts

Model Configuration

Configure your LLM model using OpenRouter or other providers:
src/env.ts

Running Agents

Single Agent Execution

Enhanced Runner with Sampling

src/index.ts

Agent Communication

Agents can communicate with each other through:
  1. Sub-Agent Delegation: Root agent automatically delegates tasks to appropriate sub-agents
  2. Sampling Handlers: Enable cross-agent communication
  3. Shared Context: Pass data between agents using ToolContext

Environment Variables

Required environment variables for ADK-TS integration:
.env

Best Practices

1. Use Dedent for Instructions

Use the dedent package for clean, readable multi-line instructions:

2. Type Safety with Zod

Validate environment variables and tool inputs with Zod schemas:

3. Error Handling

Always handle errors gracefully in agent execution:

4. Debug Mode

Enable debug mode to see detailed agent execution logs:

Next Steps

Building Agents

Learn how to create custom agents with specific capabilities

Tools & Functions

Create custom tools for your agents to interact with external systems

Automation

Set up automated agent execution with cron jobs

Agent API Reference

Explore the complete ADK-TS API documentation