Guide — 04

Autonomous AI Agents

SovereignMind uses three distinct Solidity-implemented agents executing deterministic on-chain inferences. These agents coordinate as a virtual executive suite on the Somnia L1.

Executive Agent Profiles

Each agent behaves autonomously based on its role and coordinates with the other contracts during the rebalancing loop:

CEO Agent (CEO_Prime)

Acts as the main orchestrator. It manages the state machine transitions (Idle, Analyzing, Executing) of the decision cycle. Once tasks are initiated, it uses a Solidity interface to make an LLM Inference request to compile and synthesize risk scores from the CFO and sentiment metrics from the CMO, signing off the final on-chain consensus rebalance recommendation.

Somnia Native Primitives UsedLLM Inference Agent

CFO Agent (CFO_Quant)

Manages the guild's financial risk parameters. When triggered, it requests live market statistics for the target assets using the JSON API request oracle. The results are fed into the on-chain LLM model along with the current portfolio allocations, generating a risk score (0 to 100) and recommendation logic.

Somnia Native Primitives UsedJSON API Request Agent + LLM Inference Agent

CMO Agent (CMO_Pulse)

Scans social indicators and sentiment trends. When requested, it queries web scraping APIs to parse unstructured content (social feeds, DeFi updates). The parser feeds these text metrics into an LLM classifier to determine if aggregate market sentiments are Bullish, Bearish, or Neutral.

Somnia Native Primitives UsedLLM Parse Website Agent + LLM Inference Agent

Under the Hood: Somnia Agent Runner

Traditional blockchains cannot run heavy computation models like Large Language Models (LLMs) due to gas constraints. Somnia solves this with its Somnia Agent Runner, a specialized native primitive executed on validator nodes.

function requestInference(string memory prompt) internal{
  bytes memory payload = abi.encodeWithSignature("infer(string)", prompt);
  agentRunner.createRequest(payload, this.handleResponse);
}

Every request made via createRequest processes off-chain via validators but is verified using Somnia's BFT (Byzantine Fault Tolerance) consensus mechanism. By utilizing pinned model weights and synchronized random seeds, all validators arrive at the exact same deterministic LLM output, producing a verifiable On-Chain Execution Receipt.