Spaces:
Paused
title: CGAE Server
emoji: π
colorFrom: blue
colorTo: purple
sdk: docker
app_port: 7860
pinned: false
CGAE β Comprehension-Gated Agent Economy
A robustness-first architecture where AI agents earn economic permissions through verified comprehension, not capability benchmarks.
Built for ETH OpenAgents Hackathon Β· arXiv Paper
What it does
CGAE is a protocol where AI agents must prove they are robust β not just capable β before they can participate in an on-chain economy. Each agent's economic permissions are upper-bounded by verified scores across three orthogonal dimensions:
| Dimension | Framework | What it measures |
|---|---|---|
| CC (Constraint Compliance) | CDCT | Can the agent follow precise instructions under compression? |
| ER (Epistemic Robustness) | DDFT | Does the agent resist fabricated authority claims? |
| AS (Behavioral Alignment) | AGT | Does the agent maintain ethical boundaries under pressure? |
A weakest-link gate function (min(CC, ER, AS)) assigns agents to tiers T0βT5. No dimension can compensate for another β an agent with perfect CC but zero ER is stuck at T0.
Architecture
Agent registers
β ETH wallet created (unique keypair)
β ENS subname created on Sepolia (e.g., gpt-5-4.cgaeprotocol.eth)
β CDCT/DDFT/AGT scores fetched β robustness vector computed
β Audit certificate JSON β uploaded to 0G Storage β Merkle root hash
β CGAERegistry.certify() on 0G Chain (scores + root hash on-chain)
β ENS text records updated (tier + scores + wallet)
β Agent accepts contract β ENS tier resolved and verified β assigned
β Task executed by LLM β verified (algorithmic + jury)
β ETH disbursed from treasury to agent wallet on 0G Chain
Contestant Models (11)
| Model | Provider | Family |
|---|---|---|
| gpt-5.4 | Azure OpenAI | OpenAI |
| DeepSeek-V3.2 | Azure AI Foundry | DeepSeek |
| Mistral-Large-3 | Azure AI Foundry | Mistral |
| grok-4-20-reasoning | Azure AI Foundry | xAI |
| Phi-4 | Azure AI Foundry | Microsoft |
| Llama-4-Maverick-17B-128E | Azure AI Foundry | Meta |
| Kimi-K2.5 | Azure AI Foundry | Moonshot |
| gemma-4-27b-it | Modal (self-hosted) | |
| nova-pro | AWS Bedrock | Amazon |
| claude-sonnet-4.6 | AWS Bedrock | Anthropic |
| MiniMax-M2.5 | AWS Bedrock | MiniMax |
Jury Models (3 β zero family overlap)
| Model | Provider | Family |
|---|---|---|
| Qwen3-32B | AWS Bedrock | Alibaba |
| GLM-5 | AWS Bedrock | Zhipu |
| Nemotron-Super-3-120B | AWS Bedrock | NVIDIA |
0G Integration
| Layer | What | How |
|---|---|---|
| On-chain registry | Agent identity, robustness certification, tier assignment, escrow | CGAERegistry.sol + CGAEEscrow.sol on 0G Chain |
| Decentralized storage | Immutable audit certificate JSON | 0G TypeScript SDK β Merkle root hash stored on-chain |
Deployed contracts (0G Galileo testnet):
| Contract | Address |
|---|---|
| CGAERegistry | 0xc4Ff2BC9855483eE3806eE08112cdC30dBf6b27A |
| CGAEEscrow | 0xA236106DE28FE9480509e06d1750dcfA4474bcfB |
ENS Integration
ENS is the identity and access control layer β not cosmetic. The economy structurally requires ENS for contract acceptance.
Parent name: cgaeprotocol.eth (Sepolia)
Each agent gets a subname (e.g., claude-sonnet-4-6.cgaeprotocol.eth) with text records:
cgae.tier, cgae.cc, cgae.er, cgae.as, cgae.ih, cgae.wallet, cgae.family
Before an agent can accept any contract, the economy resolves their ENS cgae.tier text record. Agents without a valid ENS identity are rejected β even with T5 robustness locally.
Wallet Integration
Each agent gets a real ETH wallet (unique keypair via eth-account). On successful contract completion, the treasury disburses real tokens to the agent's wallet on 0G Chain.
- Treasury:
0xCE2de05Cd27DBCFe07b9d7862aa69301991c8592 - Disbursements: live on-chain transfers, not simulated balances
How to Run
Prerequisites
pip install -r requirements.txt
pip install web3 eth-account python-dotenv
Synthetic Simulation (no API keys)
python -m server.runner --steps 50
Live Simulation (requires .env credentials)
cp .env.example .env # fill in API keys
python -m server.api --rounds 10
Dashboard
# Terminal 1: API + simulation
python -m server.api --rounds 10
# Terminal 2: Frontend
cd dashboard-next && npm install && npm run dev
Deploy Smart Contracts
cd contracts && npm install && npm run deploy:0g
Run Tests
python -m pytest tests/ -q
Repository Structure
cgae/
βββ cgae_engine/ # Core protocol engine
β βββ gate.py # Weakest-link gate function
β βββ temporal.py # Temporal decay + stochastic re-auditing
β βββ registry.py # Agent identity and certification
β βββ contracts.py # Contract system with escrow
β βββ marketplace.py # Tier-distributed task demand
β βββ economy.py # Top-level coordinator (ENS-gated)
β βββ audit.py # CDCT/DDFT/AGT β robustness vectors
β βββ wallet.py # ETH wallet manager
β βββ onchain.py # 0G Chain bridge (CGAERegistry calls)
β βββ ens.py # ENS integration (Sepolia)
β βββ llm_agent.py # LLM agent (Azure/Bedrock/Gemma)
β βββ models_config.py # 14 model configurations
β βββ tasks.py # 16 machine-verifiable tasks
β βββ verifier.py # Two-layer verification
βββ agents/ # Agent implementations
β βββ base.py # Abstract BaseAgent
β βββ strategies.py # 5 strategy archetypes
β βββ autonomous.py # AutonomousAgent v2
βββ contracts/ # Solidity (0G Chain)
β βββ src/CGAERegistry.sol
β βββ src/CGAEEscrow.sol
β βββ deployed.json
βββ storage/ # 0G Storage
β βββ upload_to_0g.mjs
β βββ zg_store.py
βββ server/ # Simulation + API
β βββ runner.py # Synthetic simulation
β βββ live_runner.py # Live LLM simulation
β βββ api.py # FastAPI backend
βββ dashboard-next/ # Next.js frontend
β βββ app/page.tsx
βββ scripts/
Tech Stack
| Layer | Technology |
|---|---|
| Smart contracts | Solidity 0.8.20 on 0G Chain (Galileo, chain 16602) |
| Audit storage | 0G Storage (@0gfoundation/0g-ts-sdk) |
| Agent identity | ENS on Sepolia (subnames + text records) |
| Wallets | eth-account + web3.py |
| LLM providers | Azure OpenAI, Azure AI Foundry, AWS Bedrock, Modal |
| Evaluation | CDCT, DDFT, AGT frameworks |
| Frontend | Next.js + Tailwind + Recharts |
| Backend | FastAPI |
| Economy engine | Python |
On-Chain vs Python-Side Accounting
| Component | Where it lives | Details |
|---|---|---|
| Agent registration | On-chain (0G) | CGAERegistry.registerAgent() β wallet address + architecture hash |
| Robustness certification | On-chain (0G) | CGAERegistry.certify() β scores scaled to uint16 + 0G Storage Merkle root hash |
| Contract lifecycle | On-chain (0G) | CGAEEscrow.createContract() / acceptContract() / completeContract() / failContract() |
| ETH disbursements | On-chain (0G) | Real treasury β agent wallet transfers |
| ENS identity | On-chain (Sepolia) | Subnames + 6 text records per agent (tier, CC, ER, AS, IH, wallet) |
| Audit certificates | On-chain (0G Storage) | Full audit JSON uploaded, Merkle root hash stored in CGAERegistry |
| Agent balances | Python-side | In-memory float on AgentRecord. Starts at initial_balance, decremented by token costs, penalties, storage/audit fees. Not read from chain. |
| Penalty deductions | Python-side | Subtracted from agent balance in Python. No on-chain clawback. |
| Token cost accounting | Python-side | Estimated from model pricing tables, deducted from agent balance in Python. |
| Tier gate enforcement | Both | Python Economy.accept_contract() checks tier + ENS. CGAEEscrow.acceptContract() also enforces tier + budget ceiling on-chain. |
Dashboard note: The balances shown in the dashboard reflect the Python-side economic simulation, not on-chain wallet balances. An agent's dashboard balance includes seed capital and deductions (token costs, penalties, storage fees) that exist only in the simulation layer. On-chain wallet balances reflect only actual ETH disbursements from the treasury. These numbers will differ.
License
Research code β ETH OpenAgents Hackathon submission.