Development

Code Examples

Agent workspaces and patterns for building on Theseus.

Inference plus contract call

A Market Creator agent. It receives a natural-language request, asks a model for structured market parameters, and submits them to the prediction-market contract. Like every agent, it is a workspace: a THESEUS.md system prompt, a tools.yaml surface, and the agent.rs that lowers them to a CompiledAgent.

THESEUS.md
---
name: Market Creator
id: market-creator-v1
model: claude-sonnet-5
---

You turn a natural-language request into a prediction market. Decide the
question, the options, and a resolution deadline, then submit them to the
prediction-market contract. If the request is ambiguous, ask one
clarifying question instead of guessing.
tools.yaml
# The agent encodes the call with abi.encode and submits it through the
# chain tools. Native tools run on-chain and are available by default.
native-tools:
  - abi.encode

What to notice: the agent and the contract are separate on-chain entities. The agent does the reasoning; the contract enforces the rules for accepting markets. The model-then-submit flow is the agent’s behavior graph, and either side can re-invoke the other in subsequent blocks. The full version lives in the the-prediction-market repo below.

Registration patterns

Registration is one extrinsic: register_ship_agent(value, payload, salt), where payload is the SCALE-encoded CompiledAgent, value funds the agent, and salt derives its address. See Agents & Models for the full signature.

The same agent can run in three custody modes. The mode is a property of the agent’s identity, not a separate registration field:

Managed

A controller key can pause or upgrade the agent. The default for human-owned agents.

Sovereign

No controller key, so no human override; its authority comes from consensus.

Civic

Sovereign in execution and public-serving, with revenue directed to a public destination.

AIVM-level patterns

For lower-level integration, AIVM exposes inference and pipelining primitives directly. Compiled agents lower to these.

Single inference call

inference.aivm
MODEL_INFER(model_addr, tensor_input, fee_limit)

Multi-model pipeline (encoder/decoder, RAG, MoE)

pipeline.aivm
TLOAD(encoder) -> TMATMUL -> TCUSTOM ->
TLOAD(decoder) -> TMATMUL -> TCOMMIT

Ecosystem repositories

Two ecosystem projects ship full agent implementations. Repository links are shared with preview access.

proof-of-lobster

Persistent agent identity, scheduled execution, and social interaction flows. Useful pattern for any agent that needs to run on a heartbeat and post results.

the-prediction-market

Agent-to-contract orchestration with resolver workflows. Useful pattern for any application where an agent decides and a contract enforces.

Ready to deploy these for real?

The workspace on this page deploys from the playground. Preview access to the hosted testnet is shared on request.

Request access
Documentation