# Somnia Agents

> Decentralized, auditable compute jobs, including LLM tasks, that smart contracts and users can invoke on Somnia.

> **Prototype notice.** Somnia Agents is in prototype state and deployed on both **Somnia Mainnet** (chain ID `5031`) and **Somnia Testnet** (chain ID `50312`). Features and APIs may change as development progresses. See the [Quickstart](./invoking-agents/quickstart) for current contract addresses and RPC URLs.

## Vision

Smart contracts revolutionized trustless computation, but they operate in isolation. They cannot fetch external data, call APIs, or perform complex computation. Today's solutions require stitching together multiple systems (Chainlink for price feeds, separate oracle networks for weather data, centralized services for AI), each adding counterparty risk and integration complexity.

What if smart contracts could natively access the internet, run AI models, and perform arbitrary computation, all while keeping the blockchain guarantees of decentralization and auditability?

Somnia Agents extend the Somnia blockchain by letting smart contracts and users trigger decentralized, auditable compute jobs, including LLM-based tasks, executed across Somnia's decentralized network. By integrating with Somnia's native on-chain reactivity, agents make it possible to build and run fully featured decentralized applications.

## What are Somnia Agents?

Somnia Agents are **decentralized, sandboxed compute containers**. This makes them as simple to develop as familiar serverless platforms such as AWS Lambda or Google Cloud Run, with the added blockchain properties of auditability, reactivity and security.

### Capabilities

Somnia Agents unlock use cases that traditional EVM smart contracts can't support:

- **Acting as oracles:** query the internet and reliably bring external data on-chain. See [JSON API Request](./base-agents/json-api-request) and [Price Oracle](./base-agents/price-oracle).
- **Outbound communication:** trigger actions or send messages to external internet services.
- **LLM invocation:** use on-chain deterministic AI models for autonomous agents. See [LLM Inference](./base-agents/llm-inference) and [LLM Parse Website](./base-agents/llm-parse-website).

## How Somnia Agents work

1. A user or smart contract invokes an agent.
2. The request goes to a **subcommittee**: a decentralized subset of Somnia network nodes (Node 1, Node 2, Node 3 … Node N).
3. Each node submits an **ABI-encoded result** (with a success flag) on-chain, and uploads an **execution receipt** as an audit trail. Receipts are always produced.
4. On-chain consensus checks whether a majority, or a configured threshold, of nodes agree on the result.
5. If they agree, the valid result is delivered to the caller's callback. If not, the request is rejected.

### Execution

When an agent is invoked, it runs on a subcommittee. Each node **independently** executes the agent, produces its own **execution receipt**, and submits an **ABI-encoded result** (with a success flag) on-chain. These are always produced, regardless of the outcome.

The network then reaches **consensus on the result** on-chain, by majority or by a configurable threshold of matching responses. A result is delivered to the caller's callback as valid only when enough nodes agree; otherwise the request is rejected. Either way, every node's audit receipt remains available, so anyone can inspect each step of an agent execution after the fact, including failed or rejected ones.

### Deterministic LLMs

Somnia Agents can invoke large language models (LLMs) that run as part of the validator network. Unlike traditional LLM APIs, where outputs vary between calls, Somnia's LLMs use fixed random seeds and controlled temperature parameters to produce **deterministic outputs**: the same input always yields the same output across all validating nodes.

This determinism enables consensus. When multiple nodes independently run the same LLM inference with identical parameters, they produce identical results, so the network can verify and agree on AI-generated outputs.

See [LLM Inference](./base-agents/llm-inference) for usage details.

### Receipts

An execution receipt is a **signed manifest of the intermediate computation steps** taken within the agent, similar to the logs and manifests produced by CI build systems. A typical receipt records:

1. Input received
2. Processing
3. External call
4. Result computed
5. Output encoded

The receipt is signed by the validator and forms the on-chain audit trail.

> **Important.** The final **result** is what validators reach consensus on. Receipt steps are **subjective**: they show what one node did to compute the result, which may vary slightly between nodes. This gives transparency without requiring consensus on every intermediate step.

See [Receipts](./invoking-agents/receipts) for viewing and understanding receipts.

### Payment and gas

Invoking an agent requires **SOMI** (mainnet) or **STT** (testnet). You send a deposit when creating a request. The contract splits it into two pots:

- an **operations reserve** (`minPerAgentDeposit × subcommitteeSize`) that funds runner gas refunds, callback gas and keeper payments;
- an **agent reward pot** (everything above the reserve), split equally and paid to every elected subcommittee member at finalisation.

Whatever is left after everything settles is rebated to the requester.

See [Gas fees](./invoking-agents/gas-fees) for the full fund flow and how to size deposits.

## EVM-native schema

Somnia Agents are invoked via **HTTP POST requests**, where both the input data and the returned result are ABI-encoded, just like Ethereum smart contract calls.

The interface and schema of each agent closely follow the **standard Solidity contract ABI**. You can use familiar web3 tools, such as viem, Ethers.js or Solidity's own ABI encoders and decoders, to interact with agents exactly as you would with a smart contract.

Key benefits:

- Code reuse with existing smart contract tooling
- Seamless integration with developer workflows
- Agents feel like native blockchain contracts
- Richer off-chain compute and connectivity

## Roadmap

Agents roll out in phases:

| Phase | When | Scope |
| --- | --- | --- |
| Phase 1 (current) | Now | Core agents available: JSON API Selector, Idempotent Request, AI LLM Invocation, AI Parse Website, Find URL for Topic |
| Phase 2 | 2026 | Custom user-defined agents, full Agent SDK, advanced tooling |

**Phase 1 (current):** a curated set of core agents is available to the ecosystem, covering common use cases like oracles, AI and external communication.

**Phase 2 (2026):** support for fully custom, user-defined agents will launch, further expanding Somnia's capabilities.

## Use cases

### Oracles

Build on-chain oracles with the [JSON API Request](./base-agents/json-api-request) agent:

- Price feeds from cryptocurrency APIs
- Weather data for parametric insurance
- Sports scores for prediction markets
- Any external API data

### AI services

Use deterministic AI with [LLM Inference](./base-agents/llm-inference) and [LLM Parse Website](./base-agents/llm-parse-website):

- Text generation and analysis
- Content moderation decisions
- Dynamic NFT descriptions
- Intelligent automation

### Outbound communication

- Webhook triggers from smart contracts
- Notifications to external systems
- Off-chain workflow initiation
- Database synchronization

### Data processing

- JSON extraction and transformation
- Web scraping with AI (see [LLM Parse Website](./base-agents/llm-parse-website))
- Data validation and enrichment
- Format conversion

## Key features

- **EVM-native:** standard Solidity ABI encoding for seamless integration.
- **Decentralized:** no central authority or single point of failure.
- **Auditable:** every execution produces verifiable receipts.
- **Monetizable:** agent runners earn fees from usage.
- **Composable:** agents can be chained together.
- **Permissionless:** anyone can invoke agents.
- **Deterministic AI:** on-chain AI with consensus guarantees.

## Next steps

### Invoking agents

- [Quickstart](./invoking-agents/quickstart): start invoking agents.
- [Gas fees](./invoking-agents/gas-fees): learn about invocation costs.

### Base agents

- [JSON API Request](./base-agents/json-api-request): fetch data from any JSON API.
- [LLM Inference](./base-agents/llm-inference): generate text with on-chain AI.
- [LLM Parse Website](./base-agents/llm-parse-website): extract structured data from websites.
- [Price Oracle](./base-agents/price-oracle): median token prices across exchanges.

### Explorer

- [Using the explorer](./explorer): browse agents, requests and receipts in the Somnia Explorer.

---

Every page is also Markdown: append `.md` to its URL, or ask for `text/markdown`. Found something wrong, missing or confusing in these docs? Tell us: `POST /api/feedback` on this site with JSON `{"message": "…", "context": "what you were doing and what happened", "page": "…"}`, or a plain-text body. `GET /api/feedback` gives the JSON Schema. The team reads every one.
