This is a submission for Weekend Challenge: Earth Day Edition
Every token your agent burns is a small amount of coal somewhere in a datacenter. I got curious about the math and then horrified by the answer.
I already maintain ContextClaw, a context-management plugin for OpenClaw that classifies everything in an agent's context window by content type (JSON schemas, file reads, tool output, chat history) and truncates the junk so you stop shipping 200K-token requests that should be 22K. The dogfooding numbers on my own agent work are brutal: 87.9% reduction across 11,300 items in 6 real sessions — ~40M characters of pure garbage evicted, about 14.5 million tokens saved.
For Earth Day, I wanted to know what that actually means in the real world. Kilowatt-hours. Grams of CO₂. Miles driven in a car. So I built a tiny new layer on top of ContextClaw called eco-report that turns token savings into carbon receipts, and I wired Google Gemini in to narrate a weekly report from the telemetry.
What I Built
eco-report is a ~100-line Node module that sits on top of ContextClaw's existing efficiency tracker. Every time ContextClaw truncates, tails, or evicts something from the context window, it already records tokens-before and tokens-after. eco-report takes those numbers and does three things:
- Converts tokens → kWh using published large-model inference energy estimates from the Luccioni et al. "Power Hungry Processing" paper and the MLCommons energy benchmarks. I'm using the conservative frontier-model figure of ~0.001 Wh per output token (roughly matching the 0.5–1.2 Wh-per-query range reported for ChatGPT-scale traffic, normalized to a ~500-token reply).
- Converts kWh → gCO₂e using the current EPA eGRID US average of 385 gCO₂e/kWh (2026 release). Configurable — you can swap in your datacenter's grid factor if you know it (Iowa coal grid is ~700; Pacific Northwest hydro is ~90).
- Converts gCO₂e → relatable units — miles driven in an average US gasoline car (404 g/mi), phone charges (~8 g each), trees-year equivalents.
The kicker: for my own agent work, the cumulative saving is ~14.5M tokens = ~14.5 kWh not spent = ~5.6 kg CO₂e avoided — which is about 14 miles in a gas car, or roughly one weekly lunch's worth of gasoline commute, from a plugin I wrote to stop 429s.
Not a world-saver. But extrapolated across a mid-size engineering org running agents 24/7 with no context hygiene? You are quietly burning the emissions of a small fleet of cars to re-send the same Dockerfile to Claude every three turns.
Demo
Here's a run against one of my real OpenClaw sessions:
$ node eco-report.js --session /home/yin/.openclaw/logs/session-0418.jsonl
🌱 ContextClaw Eco-Report — Session 2026-04-18
────────────────────────────────────────────────────
Items processed : 2,144
Tokens before : 9,384,217
Tokens after : 1,036,402
Tokens saved : 8,347,815 (88.9% reduction)
Energy avoided : 8.35 kWh
CO₂e avoided : 3,214 g (US grid avg, 385 g/kWh)
Roughly equivalent to : 8 miles in an avg gasoline car
OR 402 phone charges
OR 5.6 fridge-days
Gemini says:
"This session truncated 8.3 million tokens from
context — mostly stale file reads and JSON schema
blobs. That's roughly the carbon cost of driving from
Manhattan to JFK in a gasoline car, avoided. Over a
year at this rate (1 session/day), you'd avoid about
1.2 tonnes of CO₂e — the emissions of a cross-country
flight for one passenger."
────────────────────────────────────────────────────
The Gemini narration is the interesting part. Numbers alone are dry. When Gemini takes the raw telemetry (tokens saved, session duration, top-eviction content types) and writes a 3-sentence plain-English summary with analogies, it genuinely changes how you feel about the number. It's the same reason Strava pings me "that was your second-fastest 5K this month" instead of just showing me an average pace.

Companion dashboard at github.com/dodge1218/agentic-efficiency tracks total tokens saved and estimated capital + carbon saved across all my agent sessions.
Code
The whole thing is in the ContextClaw repo under plugin/eco-report.js. Here's the core — the full file is ~110 lines including the Gemini call:
// eco-report.js — turn token savings into kWh + CO2
const WH_PER_TOKEN = 0.001; // Luccioni et al., conservative frontier-model figure
const G_CO2_PER_KWH = 385; // EPA eGRID 2026 US avg. override via env.
const G_CO2_PER_MILE = 404; // EPA avg passenger vehicle
const G_CO2_PER_PHONE_CHARGE = 8;
export function tokensToFootprint(tokensSaved, gridFactor = G_CO2_PER_KWH) {
const kWh = (tokensSaved * WH_PER_TOKEN) / 1000;
const gCO2 = kWh * gridFactor;
return {
kWh: round(kWh, 3),
gCO2e: Math.round(gCO2),
equivalents: {
miles_driven: round(gCO2 / G_CO2_PER_MILE, 1),
phone_charges: Math.round(gCO2 / G_CO2_PER_PHONE_CHARGE),
},
};
}
export async function narrateWithGemini(stats, apiKey) {
const prompt = `You are an environmental analyst. Write a terse, punchy,
three-sentence plain-English summary of this ContextClaw session.
Use concrete analogies (miles driven, flights, fridge-days). No fluff.
Session data:
${JSON.stringify(stats, null, 2)}`;
const res = await fetch(
`https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=${apiKey}`,
{ method: 'POST', headers: {'Content-Type':'application/json'},
body: JSON.stringify({ contents: [{ parts: [{ text: prompt }] }] }) }
);
const j = await res.json();
return j.candidates?.[0]?.content?.parts?.[0]?.text ?? '(Gemini unavailable)';
}
That's the whole trick. ContextClaw already measures everything. eco-report just multiplies by two constants and asks Gemini to sound less like a spreadsheet.
How I Built It
The stack:
- ContextClaw (existing, mine, MIT): the classifier + truncator that produces the telemetry.
- Google Gemini 2.0 Flash: single API call per report. Flash is the right tier here — this is a summarization task, not a reasoning one, and Flash's cost + latency are perfect for "run this at the end of every session." Ironic-but-on-theme: Flash is also ~10× more energy-efficient per token than a frontier reasoning model, so the carbon cost of generating the eco-report is essentially noise.
- Node 20: plugin layer.
-
EPA eGRID 2026 for the US grid CO₂ intensity. Anyone outside the US can pass
--grid-factor=90(Pacific NW hydro),700(coal-heavy Iowa), or their actual regional number.
Three decisions worth calling out:
I deliberately used a conservative WH_PER_TOKEN. Energy-per-token for frontier models is genuinely uncertain; published figures range from 0.0003 to 0.003 Wh. I went with 0.001 because I would rather under-claim and be defensible than inflate the number for a better Earth Day story. If anything, my numbers are lower than reality.
Gemini does the storytelling, not the math. I never let the LLM multiply. It gets the raw, already-calculated numbers and turns them into prose. This is the right division of labor — Gemini's job here is translation, not arithmetic, and it means my carbon numbers stay reproducible and don't hallucinate.
The
eco-reportruns at end-of-session, not every turn. One API call per session to Gemini, not per message. This matters because (a) it respects rate limits and (b) it means the eco-report's own carbon cost is ~200 tokens of Flash output, or about 0.08 grams of CO₂e per report. The report measures ~3 kg of savings. Ratio: roughly 40,000× more saved than spent.
Prize Category
Best use of Google Gemini.
Gemini is doing the one thing most hackathon submissions can't pull off with it: being a deliberately small, cheap, well-scoped component rather than the centerpiece. It's a storyteller bolted onto a real measurement pipeline. It turns a dry JSON blob into something a human will actually read at the end of a Friday afternoon. And because I used Gemini 2.0 Flash instead of a heavy reasoning model, the eco-report respects its own thesis: don't burn tokens you don't need to.
That's the thing I want judges to take away: AI tooling can help us measure the footprint of AI itself, and it does that best when it's a scalpel, not a sledgehammer.
🌍 Repo: https://github.com/dodge1218/contextclaw
📊 Dashboard: https://github.com/dodge1218/agentic-efficiency
🔗 Parent platform: OpenClaw
Final Manual Submission Steps
- Confirm
contextclaw/plugin/eco-report.jsis committed or at least present in the public repo before publishing. - Create a DEV post at https://dev.to/new.
- Paste this markdown exactly, keeping the required first line and front matter tags.
- Add tags:
devchallenge,weekendchallenge,ai,sustainability. - Publish before Monday, Apr 20, 2026 at 02:59 EDT.
Top comments (0)