Inspiration

It started with a conversation about EV chargers. We learned that smaller companies installing EV charging stations earn carbon credits - but have absolutely no practical way to sell them. The voluntary carbon market is dominated by large brokers and opaque platforms designed for enterprises with dedicated sustainability teams.

When we dug into existing carbon credit marketplaces, we found a massive vacuum: SMEs on both sides of the market - sellers with credits they can't monetize and buyers who want to offset but don't know where to start - are completely underserved. The terminology is confusing, the registries are fragmented across Verra, Gold Standard, ACR, and others, and pricing is a black box.

We asked ourselves: what if AI agents could simply handle all of this? What if a buyer could describe their company in plain English and have an agent estimate their footprint, find matching credits, and purchase them - all in one conversation? What if that agent could then keep doing it autonomously, every month, within a set budget?

That's how CarbonBridge was born: an agent-first carbon credit exchange where AI does the brokering.

What We Learned

  • The voluntary carbon credit market is surprisingly fragmented - five major registries, dozens of project types, and no standardized pricing. We integrated CarbonPlan's OffsetsDB (10,000+ real projects) to ground our agents in actual market data rather than hallucinated numbers.
  • Multi-turn conversational agents are hard to get right. We built a LangGraph state machine with deterministic guard rails on top of Pydantic AI to prevent the wizard from going off-track, while still feeling natural.
  • Choosing the right model for the right task matters enormously. Claude excels at warm, conversational guidance (our wizard), while Gemini Flash is perfect for fast, cheap batch operations (autonomous purchasing, seller advisory). Using both keeps costs down and quality up.
  • Agent explainability isn't optional - it's the feature. Buyers trusting an AI to spend their money need to see exactly why it chose a specific listing. Our Decision Explainer with full score breakdowns and reasoning traces turned out to be one of the most compelling parts of the demo.
  • Financial-grade atomicity matters even in a hackathon. We used Couchbase sub-document mutations and TigerBeetle's distributed ledger to prevent double-selling credits under concurrent checkout - a real problem in carbon markets.

How We Built It

CarbonBridge runs as a microservice architecture orchestrated by Polytope, which manages all our Docker containers, networking, and hot-reload with a single command. Polytope's MCP server integration also served as our AI-assisted development environment, letting coding agents directly inspect and manage running services.

Three AI Agents (Pydantic AI + LangGraph):

  1. A conversational Buyer Wizard (Claude) orchestrated by a LangGraph state machine - manages multi-turn conversation flow across 7 steps with deterministic guard rails that override the LLM when extracted data warrants step progression. Streamed via SSE for real-time chat.
  2. An Autonomous Buyer Agent (Gemini Flash) that runs on a schedule, searching, scoring, and purchasing credits matching a buyer's saved criteria. Executes payments autonomously via Stripe Agent Wallet with per-transaction caps and budget ceilings.
  3. A Seller Advisory Agent (Gemini Flash) that analyzes market conditions and provides pricing and positioning recommendations grounded in real OffsetsDB data.

Backend: FastAPI (Python 3.13) with LangGraph for multi-turn state management, APScheduler for autonomous agent scheduling, and a fake registry API for credit verification demos.

Payments: The Stripe API handles standard buyer checkout via Payment Elements. For the autonomous buyer agent, Stripe Agent Wallet enables AI-initiated transactions without human intervention - the agent independently executes purchases within configured budget limits, with full audit trail.

Frontend: React 19 with React Router v7, Tailwind CSS, shadcn/ui components, and custom SSE streaming hooks for real-time agent interaction. Stripe Elements for payment.

Data Layer: Couchbase for document storage (users, listings, orders, agent runs with full decision traces). TigerBeetle as a distributed double-entry financial ledger for carbon credit accounting - each user has pending and settled accounts, with atomic transfers on payment confirmation. This gives us immutable, auditable records with the consistency guarantees that carbon credit trading demands.

Auth & Security: Curity Identity Server provides financial-grade authentication via the Phantom Token pattern. Kong API Gateway intercepts all requests, exchanges opaque tokens for signed JWTs via Curity's introspection endpoint, and forwards verified claims to the backend. Sensitive token content never reaches the browser.

Market Data: Nightly sync with CarbonPlan OffsetsDB (10,000+ real projects across 5 registries) grounds all agent recommendations in actual market data.

Challenges We Faced

  • Agent determinism vs. flexibility: The wizard agent needs to feel conversational but also reliably advance through steps. We solved this with a LangGraph state machine that applies deterministic guard rails post-LLM - if the data indicates progression, we force the step transition regardless of what the model says.
  • Autonomous payments without humans in the loop: Letting an AI agent spend real money requires serious guardrails. Stripe Agent Wallet gave us the foundation for autonomous agentic transactions, but we still had to layer on per-transaction caps, monthly budget ceilings, and idempotency checks to prevent duplicate purchases if the scheduler fires twice.
  • Concurrent quantity management: When multiple buyers check out simultaneously, credits can be oversold. We implemented atomic sub-document mutations in Couchbase to reserve quantities at checkout and release them on timeout - no race conditions. TigerBeetle's double-entry ledger ensures the financial side is equally bulletproof.
  • SSE streaming through Phantom Token auth: Standard EventSource doesn't support custom headers, but Curity's Phantom Token pattern (via Kong) requires an Authorization header on every request. We built a custom streaming hook using fetch + ReadableStream instead.
  • Grounding agents in real data: LLMs love to make up numbers. We integrated CarbonPlan's OffsetsDB (synced nightly, 10,000+ projects) so agents reference real market prices, project types, and registry distributions when making recommendations.
  • Balancing model cost vs. quality: Running Claude for every agent operation would be expensive. We split across two models - Claude for the high-touch wizard experience, Gemini Flash for batch operations - keeping the total inference cost manageable for a marketplace that needs to scale.

Built With

Share this project:

Updates