Skip to content

Stray-South/agent-commerce-protocol

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

agent-commerce-protocol

Lifecycle protocol for ephemeral AI agents. Lease, metered execution, termination, and settlement — composable with any x402 payment gateway and any receipt format compatible with cognitive-meter.

What it does

Spawns an AI agent for a specific task, meters its work via signed receipts, and terminates the agent when its budget or TTL is exhausted. The "summon-work-die" lifecycle is protocol-level: agents don't need to know how they'll be killed, and the orchestrator doesn't need to know what the agent is doing.

The lifecycle

  1. Lease — a Lease Capability Token (LCT) is issued with a short TTL.
  2. Work — the agent makes requests through an x402 gateway. Each request consumes from the lease budget; the gateway returns signed receipts for every metered call.
  3. Refresh — the lease controller refreshes the LCT while the lease is active and within budget.
  4. Combust — the controller stops refreshing. The agent's next request fails with 402; the agent terminates.
  5. Settle — accumulated receipts are bundled, the final receipt chain is verified, and payment is split per the configured policy.

Components

  • commerce/ — core protocol: LCT tokens, lease controller, settlement engine, fleet relay, termination, agent card, receipt bundling.
  • phase0/ — FastAPI vertical slice demonstrating the full lifecycle with a mock LLM.
  • tests/ — ~180 tests covering the commerce modules and an adversarial agent suite.

Quick start

Install:

pip install -e ".[dev]"

Run the Phase 0 vertical slice (FastAPI server + mock LLM):

cd phase0
pip install -e .
uvicorn phase0_agent.server:app --reload

Drive a full lease lifecycle from the included integration script:

phase0/scripts/test_vertical_slice.sh

You'll see the lease open, receipts accumulate while the agent works, the LCT refresh stop, and the agent terminate on the next request when its lease goes stale.

Design decisions

  • LCT default TTL: 60 seconds, refreshed every 30s while the lease is active.
  • Settlement default split: 85% creator / 15% platform, with a 48-hour hold period.
  • Receipt chain: Ed25519 signatures + SHA-256 hash chain (cognitive-meter receipt v1 format).
  • Combustion: passive (stop refreshing the token) rather than active (explicit kill signal). The agent experiences termination as a 402 on its next call, not as an interrupt.

Related work

License

Apache 2.0

About

Lifecycle protocol for ephemeral AI agents: lease, metered execution, termination, settlement. Reference implementation in Python.

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors