AI + Web3 Integration · 5 min read ·
A practical guide to on-chain AI agent architectures—what to keep on-chain vs off-chain, key tradeoffs, and patterns that actually ship.
On-chain AI agents are the natural collision point between two powerful ideas: autonomous software (agents) and credibly neutral execution (blockchains). Done well, they let you build systems that can decide and act with transparent rules, auditable state, and enforceable permissions—without trusting a single operator.
Done poorly, they become expensive, slow, and insecure “AI theater” glued to a smart contract.
This post breaks down realistic architectures for on-chain AI agents, what belongs on-chain, what shouldn’t, and the tradeoffs founders and developers need to confront early.
An AI agent, at minimum, has:
“On-chain AI agent” does not usually mean running an LLM inference inside the EVM (you can, but you probably shouldn’t). In practice, it means:
The core question is: what do you need the chain to guarantee? Everything else should be optimized for cost and speed.
Most shippable systems look like this:
Smart contracts define what the agent is allowed to do:
This is where you get real value: even if the agent operator is compromised, the contracts constrain damage.
Keep on-chain what must be auditable or composable:
Avoid dumping verbose “chat logs” on-chain. Store commitments (hashes), not paragraphs.
LLMs are expensive and non-deterministic. Put them off-chain:
This layer is also where you can swap models as capabilities change—without redeploying contracts.
Agents often need facts not natively on-chain:
Options range from Chainlink-style feeds, to optimistic oracles, to custom committees, to TEEs. Each choice changes the trust model.
Execution can be:
The chain is the final arbiter: calls either meet policy constraints or revert.
Pros: simple, cheap, great for MVPs.
Cons: availability depends on operator; censorship risk; limited decentralization.
Example: a treasury rebalancer bot that can only swap within a whitelist and daily budget.
Pros: better liveness and censorship-resistance; competitive execution; easy auditing.
Cons: more complexity (replay protection, partial fills, MEV considerations).
Example: an agent posts “swap up to 100k USDC for ETH if price < X, max slippage Y”; searchers execute when profitable.
Pros: strongest guarantees; less trust in agent operator.
Cons: expensive and hard; limited model flexibility; tooling immature.
Example: a credit/risk scoring step proven by ZK (or attested), used to approve an on-chain loan limit.
Blockchains want deterministic execution; modern AI is probabilistic.
If you need reproducible outputs, you must either:
Most teams should accept that model reasoning stays off-chain and focus on on-chain constraints.
Putting more on-chain increases auditability—but quickly becomes unusable.
Practical guidance:
If your agent uses off-chain signals, your security is now the oracle’s security.
Mitigations:
Agents need keys, but keys get compromised.
Use:
A good on-chain agent design assumes compromise and limits damage.
Agents that broadcast predictable actions get sandwiched.
Countermeasures:
If your agent trades on public mempools without protection, it’s donating to MEV searchers.
The winning architecture for on-chain AI agents is not “LLMs on Ethereum.” It’s verifiable authority on-chain paired with flexible reasoning off-chain.
Put guardrails, accounting, and enforcement in smart contracts. Use off-chain models for planning and iteration. If you truly need stronger integrity, selectively add attestations or proofs—but treat them as scalpel tools, not a default.
On-chain agents are less about making AI trustless and more about making AI accountable. That’s the trade—and the opportunity—for AI + Web3 integration.