About the Project

Inspiration: I wanted to answer a simple question: what if AI agents could buy their own compute? Agents are getting smarter (long-context reasoning, tool use, agentic loops), but they're always constrained by what humans pre-provision. They can't rent a GPU when they need one, can't discover a tool they lack and pay $0.05 to use it, can't make a spend decision and get human approval in real time. The hackathon challenge—three sponsors, three problems—crystallized this into a concrete demo: Akash (where to run it), Pomerium (who's allowed), Zero (how it pays). One agent, one loop, all three layers visible.

What I learned:

The cost model was the core insight. Running a compute job locally is free but slow; renting a GPU is fast but costs money. The decision isn't binary—it depends on job size, wall-clock time, parallelism, and your hardware. I built a decision tree that estimates peak VRAM, wall-clock GPU-hours, and parallelism, then calculates: $$\text{rent cost} = n_{\text{gpus}} \times \text{gpu-hr rate} \times t$$ $$\text{savings vs AWS} = \text{aws-list-price} - \text{akash-spot-price}$$

The math is simple, but the decision is the demo—it's where the agent becomes rational about money. An A100 on Akash costs $0.90/hr; on AWS it's $4.10/hr. That 82% gap is real and provable.

Akash's reverse auction was humbling. Providers bid on requests, the tenant picks the cheapest, and escrow streams per-block. Bids expire in ~5 minutes. The Console API (HTTP, not blockchain client) made integration tractable, but I had to accept that the demo is probabilistic—a bid might time out, requiring a retry or fallback. I learned to respect real systems' chaos.

Pomerium taught me that governance isn't a binary gate; it's per-tool and per-user. An agent trying to provision_gpu with a $500 spend should require identity verification and approval, but fetching a public paper shouldn't. The MCP-aware routing was the 3x multiplier—not just "agent is approved" but "this specific agent, calling this specific tool, needs a verified human OK."

Zero's runtime capability discovery flipped how I think about agent APIs. Instead of "here's a paid tool, here's the docs, here's the key," it's "agent, you're allowed to discover and pay for tools on-demand." No API key, no signup, just USDC on Base and a minimal interface.

How I built it:

I started with the cost model (orchestrator/costmodel.py), because without it the demo is just "watch the agent spend money." The model had to be real and tested—tests/test_costmodel.py verifies the local-vs-rent decision and the AWS savings math. That's the IP.

Then I wired Akash: orchestrator/akash.py calls the Console Managed-Wallet REST API to provision, check status, and terminate. No blockchain client needed. The vLLM SDL (deploy/worker-vllm.sdl.yaml) is a minimal inference worker that runs on GPU.

Pomerium came next: I wrote pomerium/config.yaml to gate the dangerous tools (provision_gpu, spend) by identity, extracted the approver's identity from the JWT assertion, and added a spend-threshold check in the FastAPI server. The approval flow is human-in-the-loop: if spend > $1, a button appears in the dashboard; click it, and the agent proceeds.

Zero integration (orchestrator/zero.py) wraps the zero CLI to discover and pay for capabilities at runtime.

The dashboard (dashboard/index.html) is the third character in the story. It shows the agent's reasoning (pi traces over SSE), the cost decision, the approval prompt, live Akash status (provider, ingress URL, GPU availability), and a treasury that ticks down as the agent spends.

The ledger (orchestrator/ledger.py) is append-only and streams to the dashboard—every event (fetch, decide, provision, approve, spend, terminate) is immutable and visible.

Challenges:

  1. Akash bid timing. The reverse auction takes ~80 seconds, and bids expire in ~5 minutes. If the network stutters or the bid loses, the demo stalls. I mitigated by pre-warming a deployment and building scripts/demo_timeline.py—a scripted, realistic event sequence that populates the dashboard without real Akash/Zero calls. On stage, this is my failsafe.
  2. Zero wallet funding. The Zero CLI needs a human to visit a browser-based funding page—you can't script it. I had to pre-fund the wallet early and keep the balance above the biggest experiment cost.
  3. Integration complexity. Akash, Pomerium, and Zero all have different auth models, API shapes, and latency profiles. The FastAPI backend acts as a coordinator—it translates agent requests to Akash Console API calls, checks Pomerium gates, invokes Zero, and logs everything to the ledger. The glue layer is ~500 lines and worth every one.
  4. Keeping it real. It would be trivial to mock everything and show a fake demo. I committed to real integrations: real Akash provision (dseq + ingress URL), real Pomerium OIDC + per-tool gates, real Zero payment (USDC on Base). The cost is that three external systems can fail; the payoff is that the demo proves the stack works.

CODE: https://github.com/Bruno-rose/treasure-roach

Built With

Share this project:

Updates