CORE CONCEPT Dynamic Tasks Dynamic Tasks are the core building blocks of the Cyne AI framework, enabling agents to perform specific tasks such as whale tracking, liquidity management, token swapping, and more.
Overview
Each task in Cyne AI consists of the following key components:
name : A unique identifier for the action.
similes : Alternative names or triggers for the action.
description : A detailed explanation of the action's purpose.
validate : Logic to check whether the action can be executed based on the current context.
handler : The implementation of the action's behavior.
examples : Demonstrates how the action works in practice.
Action Structure
The structure of an action in Cyne AI follows the format below:
Copy interface Action {
name: string;
similes: string[];
description: string;
validate: (runtime: IAgentRuntime, message: Memory) => Promise<boolean>;
handler: (
runtime: IAgentRuntime,
message: Memory,
state?: State
) => Promise<void>;
examples: ActionExample[][];
suppressInitialMessage?: boolean;
}
Key Components
name : Unique name for the action.
similes : Triggers or alternative names that activate the action.
description : A clear and concise explanation of the action's functionality.
validate : Ensures the action can be executed under the current conditions.
handler : Defines the logic and operations executed by the action.
examples : Provides real-world usage examples.
suppressInitialMessage : Suppresses automatic responses if the action generates its own output.
Built-In Actions in Cyne AI
1. CONTINUE
Continues the conversation by gathering more context or expanding on a topic.
Copy const continueAction: Action = {
name: "CONTINUE",
similes: ["ELABORATE", "KEEP_TALKING"],
description: "Expands on a topic or gathers additional context.",
validate: async () => true,
handler: async (runtime, message, state) => {
// Logic to continue the conversation
},
};
2. IGNORE
Disengages gracefully from conversations when the discussion is finished or irrelevant.
Copy const ignoreAction: Action = {
name: "IGNORE",
similes: ["STOP_TALKING", "END_CONVERSATION"],
description: "Stops responding when the conversation is no longer relevant.",
handler: async () => true,
};
3. TRACK_WHALE
Monitors large transactions on Solana and alerts users to potential market impacts.
Copy const trackWhaleAction: Action = {
name: "TRACK_WHALE",
similes: ["MONITOR_WHALE", "DETECT_WHALE"],
description: "Tracks large token transactions in real time.",
validate: async (runtime, message) => {
const content = (message.content as Content).text;
return /track whale/i.test(content);
},
handler: async (runtime, message, state) => {
const whaleData = await runtime.getWhaleActivity();
return `Whale Alert: ${whaleData.amount} SOL moved to Pool ${whaleData.pool}.`;
},
};
4. EXECUTE_SWAP
Facilitates token swaps using the DEX aggregator for optimal rates.
Copy const executeSwapAction: Action = {
name: "EXECUTE_SWAP",
similes: ["SWAP_TOKENS", "TRADE"],
description: "Performs token swaps with the best available rates on the DEX aggregator.",
validate: async (runtime, message) => {
const content = (message.content as Content).text;
return /\bswap\b/i.test(content) && content.includes("to");
},
handler: async (runtime, message, state) => {
const [fromToken, toToken] = message.content.text.split("to").map((t) => t.trim());
const swapResult = await runtime.dexAggregator.swap(fromToken, toToken);
return `Swapped ${swapResult.amount} ${fromToken} to ${swapResult.amount} ${toToken} at the best rate.`;
},
};
5. ANALYZE_RISK
Performs risk analysis on a smart contract or liquidity pool.
Copy const analyzeRiskAction: Action = {
name: "ANALYZE_RISK",
similes: ["RISK_ANALYSIS", "CHECK_RISK"],
description: "Evaluates the risk level of a given contract or liquidity pool.",
validate: async (runtime, message) => {
const address = (message.content as Content).text;
return /0x[a-fA-F0-9]{40}/.test(address); // Validates Ethereum-style contract address
},
handler: async (runtime, message) => {
const riskScore = await runtime.riskAnalyzer.analyze(message.content.text);
return `Risk Analysis: The contract has a risk score of ${riskScore}. ${riskScore > 70 ? "High Risk!" : "Low Risk."}`;
},
};
6. GENERATE_REPORT
Creates detailed performance or trend reports.
Copy const generateReportAction: Action = {
name: "GENERATE_REPORT",
similes: ["CREATE_REPORT", "PORTFOLIO_REPORT"],
description: "Generates a comprehensive report of portfolio performance or market trends.",
validate: async (runtime, message) => {
const text = (message.content as Content).text;
return /generate report/i.test(text);
},
handler: async (runtime, message) => {
const reportData = await runtime.generatePortfolioReport();
return `Portfolio Report: ${reportData.summary}`;
},
};
Creating Custom Actions
Basic Template
Copy const customAction: Action = {
name: "CUSTOM_ACTION",
similes: ["ALTERNATIVE_TRIGGER"],
description: "Defines the purpose of this action.",
validate: async (runtime, message) => {
// Custom validation logic
return true;
},
handler: async (runtime, message, state) => {
// Custom action logic
},
examples: [
[
{
user: "{{user1}}",
content: { text: "Trigger message" },
},
{
user: "{{user2}}",
content: { text: "Response", action: "CUSTOM_ACTION" },
},
],
],
};
Best Practices for Actions
Clear Purpose : Define a single, well-focused purpose for each action.
Robust Validation : Check prerequisites and validate inputs.
Error Handling : Handle errors gracefully and provide meaningful feedback.
Comprehensive Documentation : Provide examples and explain expected inputs, outputs, and scenarios.
Last updated 3 months ago