
The Core Agent Workflow
When triggered by an event (such as a user deposit, a scheduled rebalance, or a significant market shift), the agents responsible for a specific strategy execute a collaborative workflow:- Planner Agent: Initiates the process by analyzing the current state, the trigger event, and the strategy’s objectives. It drafts a preliminary plan of action (e.g., “deploy new capital,” “adjust allocation,” “harvest rewards”).
- Replanner Agent: Critically reviews the initial plan. It iterates on the strategy, considering potential risks, alternative approaches, and market data to refine the plan for optimal outcomes and safety.
- Executor Agent: Prepares for the execution phase. It identifies the necessary “tools”—specific smart contract interactions (like swaps via Shogun, lending via integrated protocols), API calls, or internal Neko functions required to implement the refined plan.
- Action-Planner Agent: Performs the final validation. Using the refined plan and the tool readiness information from the Executor, it constructs the precise sequence of on-chain transactions needed (e.g., exact swap amounts, lending parameters) and confirms the final execution steps, especially for complex multi-step actions.
Data-Driven Decision Making
This entire workflow is deeply informed by a rich tapestry of on-chain and off-chain data, allowing the agents to make contextually relevant and timely decisions. Before planning and replanning, agents retrieve critical information using Neko’s core AI capabilities:- RAG Database (Semantic Context): Agents query the Retrieval-Augmented Generation database for relevant knowledge, similar past scenarios, or contextual information based on semantic similarity.
- Time-Series Database (Market & Prediction Data): Agents access real-time and historical market data (prices, volume), protocol states, and potentially predictive analytics derived from models.
- Time-Series Database (Agent Transaction History): Agents review their own past actions and outcomes for the specific strategy (long-term memory), enabling learning and strategy refinement over time.
Underlying Technology
The DeFAI Multiagent System leverages a high-performance, secure technology stack optimized for demanding DeFi operations:- RIG Agent Framework: A Rust-based agent framework provides the core structure, ensuring fast runtime and efficient execution critical for timely market interactions.
- Large Language Models (LLMs): Advanced models (like experimental Google Gemini versions) power the reasoning, planning, and decision-making capabilities of the specialized agents (Planner, Replanner, Action-Planner).
- RAG & CAG Databases: These form the core memory system. The Retrieval-Augmented Generation (RAG) database provides semantic context and relevant knowledge, while the Context-Augmented Generation (CAG) database stores heuristics, learned best practices, and long-term transaction history (agent memory).
- Time-Series Database: Provides essential real-time and historical market data, protocol states, and predictive analytics used throughout the decision-making process.
- Event-Driven Architecture & Scheduling: The system operates based on triggers (user actions, market events, scheduled routines like rebalancing), indicating an underlying mechanism for event handling and task scheduling.
