AI agents are moving from “chatbots with tools” to autonomous systems that observe state, decide, and execute transactions. In Web3, the hard question isn’t whether agents can act—it’s what parts of an agent you can safely anchor on-chain without lighting money on fire.
An “on-chain AI agent” usually means: (1) something that makes decisions using an AI model, and (2) those decisions are enforced, recorded, or verifiable via smart contracts. The architecture you choose determines your costs, latency, user trust, and regulatory exposure.
What an on-chain agent actually is
At minimum, an on-chain agent needs three layers:
- Perception (inputs): on-chain state (balances, prices, governance) plus off-chain signals (news, social, order books).
- Reasoning (policy/model): an LLM, classifier, or RL policy that outputs an action.
- Actuation (execution): smart contracts that can move funds, place orders, vote, or update parameters.
The integration point is almost always the actuation layer: the chain enforces “what happened,” not “how the model thought.” The architectural decision is how much of perception and reasoning you want to (or can) make verifiable.
Architecture patterns (from most on-chain to least)
1) Fully on-chain logic (no ML)
This is the “agent” pattern many protocols already use: deterministic rules encoded in contracts (rebalancers, liquidation bots, TWAP executors).
Pros: cheapest trust model, fully auditable, composable, no off-chain dependency.
Cons: not actually AI; limited adaptability; hard to incorporate unstructured data.
When it wins: if your “AI” requirement is really “automated policy.” For example: a treasury rebalancer that shifts allocations when on-chain volatility crosses thresholds.
2) On-chain policy + off-chain inference (oracle-signed actions)
Here, the AI model runs off-chain, but the contract enforces a tight policy: “Only execute if the signed recommendation meets constraints.”
How it works:
- An off-chain agent reads state + external data.
- It generates a proposed action (e.g., swap X for Y).
- A signer (or threshold committee) attests to the action.
- The contract validates the signature and checks risk constraints (slippage, max position size, cooldowns) before executing.
Pros: practical today; cheap; strong guardrails can live on-chain.
Cons: trust shifts to the signer set; model output isn’t verifiable; censorship and liveness issues.
Real example: many “automation” systems look like this: an off-chain bot proposes transactions, while contracts enforce caps and invariants.
3) Hybrid with verifiable compute (ZK/TEE-backed inference)
This pattern tries to reduce “trust me, I ran the model” by proving it.
Two major approaches:
- Zero-knowledge proofs (ZK): prove that given inputs and a committed model, inference produced a specific output.
- Trusted execution environments (TEEs): rely on hardware attestation that code ran in an enclave.
Pros: stronger correctness guarantees; can reduce reliance on multisig signers.
Cons: heavy engineering; ZK inference can be expensive/slow for large models; TEEs introduce hardware trust and side-channel concerns.
When it wins: high-value agents (treasuries, market makers, credit scoring) where counterparties demand verifiability.
4) Agent-as-a-protocol (on-chain state machine + off-chain “brains”)
This is the most scalable mental model: treat the agent as a protocol with an on-chain state machine.
- The contract stores the agent’s state (positions, budgets, permissions, memories as hashes/commitments).
- Off-chain services propose state transitions.
- On-chain verification checks invariants and applies transitions.
Pros: clean separation of concerns; composable; upgrades can be governed; easy to sandbox.
Cons: still off-chain reasoning; requires strong state design and careful replay protection.
Core tradeoffs founders should decide early
Trust vs cost: who do users need to believe?
- Pure on-chain automation: users trust math and audits.
- Signed recommendations: users trust the signer set and ops security.
- ZK/TEE: users trust cryptography or hardware supply chains.
Opinionated take: if you can’t clearly explain your trust model in one paragraph, you don’t have one—you have a future incident report.
Latency vs composability
On-chain actions have block-time latency and mempool dynamics. Agents that need fast reactions (MEV-sensitive execution, liquidation defense) often require:
- private transaction relays / bundles,
- pre-signed transactions,
- or specialized execution networks.
But every “speed hack” can reduce composability and transparency. Decide whether your agent is a market participant (speed matters) or a governance/treasury actor (correctness matters).
Transparency vs privacy
On-chain inputs/outputs are public. If your agent uses proprietary signals (order flow, private partnerships, user data), you’ll likely keep reasoning off-chain.
Privacy tools can help, but they add complexity:
- Commit-reveal schemes for delayed transparency.
- ZK proofs to show constraints were met without revealing full inputs.
- TEEs to keep data confidential while attesting to execution.
Determinism and reproducibility
Smart contracts are deterministic; LLM inference often isn’t (sampling, model updates, tool calls).
If your agent’s output must be reproducible (for disputes, audits, or governance), you’ll need:
- fixed model versions (hash-committed weights),
- deterministic inference settings,
- explicit tool call logs,
- and canonicalization of inputs.
Upgradability and “agent drift”
Agents improve over time, but upgrades change behavior—sometimes subtly.
Best practice:
- Treat model updates like contract upgrades: timelocks, changelogs, and rollback plans.
- Commit model versions on-chain (even if weights live off-chain).
- Add “circuit breakers” (pause, withdraw to safe address, reduce risk limits).
A practical reference architecture
If you’re building today and want a credible path to verifiability later:
On-chain Agent Controller (smart contract):
- custody (or delegated allowances)
- risk limits (max exposure, whitelists, cooldowns)
- invariant checks (slippage, oracle bounds)
- role-based permissions (operator, guardian, governance)
Off-chain Agent Runtime:
- data ingestion (on-chain + off-chain)
- model inference + tool selection
- transaction construction (simulation + gas estimation)
Attestation layer:
- start with a multisig/threshold signature
- evolve to TEE attestations or ZK proofs for specific computations
Observability:
- on-chain events with action rationale hashes
- off-chain logs mapped to transaction IDs
- automated post-trade checks and anomaly detection
This design lets you ship with sane security controls while keeping an upgrade path toward stronger guarantees.
Failure modes to plan for (not after launch)
- Oracle manipulation: the agent “believes” bad data; mitigate with multiple feeds, bounds, TWAPs.
- Prompt/tool injection: off-chain runtimes are vulnerable; isolate tools, use allowlists, validate outputs.
- MEV and sandwiching: mitigate with private execution, slippage caps, and batch auctions where possible.
- Key compromise: treat operator keys like hot wallets; use spend limits, delayed withdrawals, guardians.
- Model collapse or drift: monitor performance and enforce safe-mode behavior on anomalies.
Conclusion
On-chain AI agents aren’t about putting an LLM on Ethereum. They’re about choosing which parts of an autonomous system must be enforced and which parts can be trusted—then paying the cost in gas, complexity, or operational risk.
For most teams, the winning approach is a hybrid: keep inference off-chain, put strict constraints and custody rules on-chain, and add verifiable compute only where it materially changes trust. Build the agent like a protocol: explicit state, explicit permissions, explicit upgrade paths. That’s how you get autonomy without turning your treasury into an experiment.