Status: Draft Versão: 1.0 Data: 2026-06-07 Autor: AntigravityOrchestrator / OpenCode Ecosystem v5.1.0 Gap: Mecanismos econômicos de agentes sobre Token Economy Core (SPEC-022)
O Token Economy Core (SPEC-022) fornece operações básicas (mint, transfer, burn, fee market, reward, audit). Não há mecanismos de:
- Precificação por operação: agentes executam operações sem custo individual
- Rate limiting: agentes sem saldo mínimo não podem operar
- Staking: agentes não podem travar tokens para obter benefícios
- Slashing: não há penalidade por má conduta ou inatividade
- Allowances: agentes não têm limites de gasto por período
- Tiers: não há diferenciação de agentes por nível de stake
┌────────────────────────────────────────────────────────┐
│ Agent Economics Layer │
│ │
│ ┌────────────────┐ ┌──────────────────┐ │
│ │ AgentPricing │ │ RateLimiter │ │
│ │ · cost/op │ │ · min_balance │ │
│ │ · fee_deduct │ │ · throttle │ │
│ └───────┬────────┘ └────────┬─────────┘ │
│ │ │ │
│ ┌───────▼─────────────────────▼─────────┐ │
│ │ TokenEconomy (SPEC-022) │ │
│ │ · mint / transfer / burn │ │
│ │ · ledger / fee market │ │
│ └───────┬─────────────────────┬─────────┘ │
│ │ │ │
│ ┌───────▼────────┐ ┌────────▼────────┐ │
│ │ AgentStake │ │ SlashManager │ │
│ │ · stake() │ │ · slash() │ │
│ │ · unstake() │ │ · appeal() │ │
│ │ · tier() │ │ │ │
│ └────────────────┘ └──────────────────┘ │
│ │
│ ┌────────────────┐ ┌──────────────────┐ │
│ │ AllowanceCtrl │ │ TierSystem │ │
│ │ · daily_limit │ │ · Bronze │ │
│ │ · weekly_limit │ │ · Silver │ │
│ │ · reset() │ │ · Gold │ │
│ └────────────────┘ └──────────────────┘ │
└────────────────────────────────────────────────────────┘
| Componente | Responsabilidade |
|---|---|
| AgentPricing | Define custo por operação (execute_task, mcp_call, llm_inference) |
| RateLimiter | Bloqueia operações se saldo do agente abaixo do mínimo |
| AgentStake | Gerencia tokens travados para prioridade e benefícios |
| SlashManager | Penaliza agentes por má conduta ou inatividade |
| AllowanceController | Limites de gasto por período (diário/semanal) |
| TierSystem | Níveis baseados em stake total (Bronze/Silver/Gold) |
Execute operation: Agent → Pricing.cost(op_type) → RateLimiter.check(agent) → AllowanceCtrl.check(agent, cost) → deduct → execute → audit
Stake: Agent → Stake.stake(amount) → TokenEconomy.transfer → locked balance → tier recalc
Slash: AuditSystem → SlashManager.slash(agent, amount, reason) → TokenEconomy.burn(staked) → tier recalc → audit
Tier calc: TierSystem recompute on stake change → apply benefits (discount, priority, limits)
- Slashing atua primeiro sobre stake locked, depois sobre saldo livre
- Allowance reset automático no início de cada período
- Tier apenas aumenta; downgrade requer período de carência
- RateLimiter não bloqueia o admin
- Pricing é configurável por tipo de operação
@dataclass
class AgentStakeInfo:
agent_id: str
staked_amount: int = 0
locked_until: float = 0.0
tier: str = "bronze" # bronze | silver | gold
@dataclass
class OperationCost:
op_type: str # "execute_task" | "mcp_call" | "llm_inference"
base_cost: int # unidades atômicas
per_unit_cost: int = 0 # custo adicional por unidade
@dataclass
class AgentAllowance:
agent_id: str
daily_limit: int
weekly_limit: int
daily_spent: int = 0
weekly_spent: int = 0
last_daily_reset: str = ""
last_weekly_reset: str = ""Deduzir custo da carteira do agente ao executar operação.
def test_operation_pricing():
econ = AgentEconomics(TokenEconomy())
econ.economy.mint("agent-a", 1000)
econ.execute("agent-a", "mcp_call", params={"service": "search"})
assert econ.economy.balance("agent-a") == 1000 - econ.pricing("mcp_call")Bloquear operação se saldo do agente estiver abaixo do mínimo.
def test_rate_limiting():
econ = AgentEconomics(TokenEconomy())
econ.set_min_balance("agent-a", 500)
econ.economy.mint("agent-a", 100)
with pytest.raises(InsufficientBalanceError):
econ.execute("agent-a", "mcp_call")Travar tokens e verificar tier upgrade.
def test_agent_staking():
econ = AgentEconomics(TokenEconomy())
econ.economy.mint("agent-a", 5000)
econ.stake("agent-a", 3000)
assert econ.get_stake("agent-a") == 3000
assert econ.get_tier("agent-a") == "silver"
assert econ.economy.balance("agent-a") == 2000 # saldo livrePenalizar agente com perda de tokens staked.
def test_agent_slashing():
econ = AgentEconomics(TokenEconomy())
econ.economy.mint("agent-a", 5000)
econ.stake("agent-a", 3000)
econ.slash("agent-a", 1000, "violation")
assert econ.get_stake("agent-a") == 2000 # stake reduzido
assert econ.economy.total_supply() == 4000 # queimado
assert len(econ.audit_trail) > 0Respeitar limite diário de gasto do agente.
def test_spending_allowance():
econ = AgentEconomics(TokenEconomy(), daily_limit=500)
econ.economy.mint("agent-a", 5000)
ok1 = econ.check_allowance("agent-a", 300)
ok2 = econ.check_allowance("agent-a", 300) # excede
assert ok1 is True
assert ok2 is FalseGold tier recebe desconto em taxas.
def test_tier_benefits():
econ = AgentEconomics(TokenEconomy())
econ.economy.mint("agent-a", 10000)
econ.stake("agent-a", 8000)
assert econ.get_tier("agent-a") == "gold"
fee = econ.calculate_operation_cost("agent-a", "mcp_call")
# gold tier tem 50% discount
expected = int(econ.pricing("mcp_call") * 0.5)
assert fee == expected| CT | Nome | Nível | Coverage Target |
|---|---|---|---|
| 01 | Agent Operation Pricing | N2 | 100% |
| 02 | Token-Based Rate Limiting | N2 | 100% |
| 03 | Agent Staking | N2 | 100% |
| 04 | Slashing por Má Conduta | N3 | 100% |
| 05 | Spending Allowance | N2 | 100% |
| 06 | Agent Tier Benefits | N3 | 100% |
- SPEC-022 ↔ SPEC-023: 0.95 — Agent Economics estende Token Economy Core
- SPEC-023 ↔ SPEC-024: 0.90 — Slashing e allowances são auditáveis
- DecisionNode ↔ SPEC-023: 0.85 — Decisões de stake/slash registradas
- Buterin, V. (2014). Ethereum Whitepaper. https://ethereum.org/whitepaper
- OpenCode Ecosystem AGENTS.md v5.1.0
- SPEC-022 Token Economy Core