Green-Agent.doc - WordPadケーススタディ
← Back to projects もどる

Green-Agent

Picking a freight carrier on cost and carbon at once, with agents that bid and an LLM that explains the choice

Team

Solo project

My role

Full-Stack Engineering

Algorithm Design

Tools

Python

FastAPI

Fetch.ai uAgents

React

PostgreSQL

Duration

Personal project

Overview

Green-Agent lets a shipper pick a freight carrier on cost and carbon at once, instead of defaulting to the cheapest quote. Each shipment request goes out to carrier agents, which reply with price, ETA, and CO2e bids. A scoring engine ranks them using weights the shipper sets, an LLM explains why the top carrier won, and the shipper approves the choice before it's booked.

Problem

Shippers choose carriers mostly on price, because emissions data is scattered and hard to compare. Even a shipper who wants to cut emissions makes the cost-versus-carbon call by hand, shipment by shipment. Three gaps make this hard:

Carrier quotes arriving in different currencies, units and formats

No common format

Carriers report price, delivery time, and emissions differently, so quotes can't be compared side by side.

A shipment goes out, but the emissions it saved are an empty outline

No visible impact

Shippers can't see how much CO2e their choices saved, so sustainability goals are hard to track.

No consistent tradeoff

Without a scoring rule, the same shipper makes different cost-versus-carbon calls from one day to the next.

Goals

The MVP proves that agents can collect comparable bids and that a transparent score can trade cost against carbon. Real carrier integrations, certified emissions accounting, payments, and fully autonomous booking are out of scope.

Bid collection

Every carrier bids in one format

Shipment 104 · 3 bids in 1.4s

A$1,240 · 3 days410 kg
B$1,280 · 3 days320 kg
C$1,190 · 4 days460 kg

Scoring

One rule ranks the bids

60% cost · 40% CO2e

Carrier B82
Carrier A71
Carrier C55

Rationale

Every pick comes with a reason

Why Carrier B

22% less CO2e than the cheapest bid.
Only $40 more, inside your cost weight.
Arrives Thursday, before the deadline.

Impact

CO2e saved, per shipment and in total

Versus the cheapest option

#104Carrier B−140 kg
#103Carrier A−60 kg
#102Carrier C0 kg

Total saved: 200 kg CO2e

Users

The primary user is a logistics coordinator at a small or mid-sized shipper with a sustainability target. They want one request to gather bids from several carriers, rankings that reflect their company's priorities, and a clear reason for each pick. The secondary user is the sustainability lead, who reports CO2e saved versus the cheapest option.

Scoring

Each bid gets a single score from 0 to 1, and the lowest score wins. Price and CO2e are min-max normalized within the current bid set, so a $50 difference and a 10 kg difference become comparable, then combined with the shipper's weights.

  • Normalization runs per bid set, so scores only compare bids for the same shipment.
  • If every bid has the same value for a field, that field normalizes to 0, which avoids dividing by zero.
  • Weights are read at scoring time, so a change on the dashboard applies to the next request without a restart.
  • ETA is a hard filter: bids that miss the deadline are excluded before scoring.
B={ b:ETAb≤deadline }B = \{\, b : \mathrm{ETA}_b \leq \text{deadline} \,\}
ETA is a hard filter: only bids that meet the deadline are scored.
ni=xi−min⁡(x)max⁡(x)−min⁡(x)n_i = \frac{x_i - \min(x)}{\max(x) - \min(x)}
Min-max normalization for each bid i, applied separately to price and to CO2e within the bid set.
Si=wcost⋅nprice,i+wcarbon⋅nCO2e,i,wcost+wcarbon=1S_i = w_{\text{cost}} \cdot n_{\text{price},i} + w_{\text{carbon}} \cdot n_{\mathrm{CO_2e},i}, \qquad w_{\text{cost}} + w_{\text{carbon}} = 1
The composite score. The lowest score wins, and ties break on lower CO2e, then lower price.
BESTWORSTC1C2C3CARBONCOST
The winner: leftmost carriage, flagged and litCarrier plates C1, C2, C3The knob's pointer: current cost ⇄ carbon weightEach carriage's position is its live score, min-max normalized and weighted by the knob; the leftmost carriage wins, and dragging past the w = 0.5 crossover visibly swaps the winner from the pricier, cleaner carrier to the cheaper, dirtier one.

Architecture

The React dashboard sends a request with the current weights to a FastAPI backend, which asks every carrier for a bid at once. Bids that miss a 2-second timeout or are missing a field are excluded and logged. Valid bids go to the scoring engine, and the LLM writes a rationale for the top result, falling back to a template if the call fails. The dashboard shows the rationale beside the bid table with Approve and Reject actions.

rest
The dashboard sends a request to the buyer agent, which asks every carrier for a bid. Valid bids are scored, and the LLM explains the winner back on the dashboard.

Agents collect bids, then scoring and the LLM turn them into one pick

Set weights. The dashboard tells the buyer agent how much price, ETA and CO₂e should count.

The original architecture sketch from the PRD, with carriers reached through Fetch.ai Agentverse.

Success metrics

The MVP succeeds if the full request-to-approval loop runs reliably and shows measurable savings: every carrier responds before the timeout in demo runs, a ranked result with rationale arrives in under 10 seconds, average CO2e saved is positive at a balanced weight, and new weights apply on the very next request.

ΔCO2e=CO2echeapest−CO2echosen\Delta\mathrm{CO_2e} = \mathrm{CO_2e}_{\text{cheapest}} - \mathrm{CO_2e}_{\text{chosen}}
CO2e saved per shipment, against the cheapest bid as the baseline.

Risks

The biggest risk is trust: if CO2e numbers or explanations look wrong, shippers fall back to the cheapest bid. CO2e figures are labeled as carrier-reported, the LLM only sees the bid table and weights so it can't invent facts, and raw price and CO2e sit next to every score because min-max can mislead with only a few bids.

Next steps

The core loop works end to end: scoring engine, API, mock carriers with timeout handling, LLM rationale, dashboard, and CI. Next are carrier messaging over Fetch.ai uAgents, weight presets, CSV emissions reports, and real emissions data from Climatiq or GLEC.

Ready 準備完了9 sections