Spaces:
Sleeping
Design Notes: Logistics Shipment RL Environment
Why This Problem?
India's logistics sector processes over $200B of freight annually. During major disruptions (port strikes, monsoon floods, highway accidents), human dispatchers must manually triage hundreds of concurrent shipments in minutes. This environment simulates that exact crisis β testing whether an LLM can act as autonomous operational infrastructure.
Key Architectural Decisions
1. Turn-Based with Deterministic Background Updates
The environment uses a turn-based loop rather than continuous steps. Within each turn, the agent can issue a sequence of JSON actions.
Crucially, background traffic (route congestion) only updates at the end of a turn. This was a major design correction: originally, background traffic updated after every action, which caused non-deterministic behavior where the agent's world model (from get_network_status) would become invalid mid-turn. By decoupling the updates to the end-of-turn, the environment ensures stable planning for the agent.
2. Independent Reward Signals with Anti-Hacking Safeguards
Rather than a single scalar reward, the training pipeline utilizes three independent reward functions:
- Structure: Evaluates valid JSON, correct start/end actions, and penalizes spam/rambling.
- Routing: Evaluates whether delayed shipments were moved to clear routes.
- Communication: Evaluates whether apologies and ETAs were sent to delayed customers.
Anti-Hacking Penalties: To prevent exploitation, strict negative rewards were enforced:
-0.5for duplicateend_turncalls-0.3for spammingget_network_status-0.6for choosing congested alternate routes-0.8for omitting a valid route ID entirely-0.5for duplicate or spam ETA messages
3. Four-Phase Curriculum Learning (GRPO)
The agent was trained using Group Relative Policy Optimization (GRPO) via TRL and Unsloth. The training followed a strict 4-phase curriculum:
- Phase 1 (Easy): Baseline routing on
TASK-EASY(1 disruption). - Phase 2 (Medium): Triage prioritization on
TASK-MEDIUM(3 simultaneous disruptions) with a lowered learning rate to prevent catastrophic forgetting. - Phase 3 (Hardening): Interleaved Easy/Medium scenarios with high rollout diversity (
num_generations=6) to reinforce learned logic. - Phase 4 (Correction): Applied the strictest anti-hacking penalties (e.g.,
-0.8for empty routes) to patch loopholes discovered in earlier phases.
4. NLP-Scored Communication
The communicate_eta action is graded by a lightweight heuristic that checks for:
- Empathetic language ("apologize", "sorry", "regret")
- Specific ETA commitment ("arrive by 6pm", "reschedule to Monday")
- Cause of delay ("port congestion", "carrier strike", "weather")
- Message length (longer = more effort)
This tests a different capability than rerouting math: can the agent produce professional, customer-facing communication under pressure?
5. Three Difficulty Tiers for Benchmarking
| Tier | Challenge | Design Intent |
|---|---|---|
| EASY | 2 shipments, 1 disruption, 3 turns | Validates basic rerouting ability |
| MEDIUM | 4 shipments, 3 simultaneous disruptions, 5 turns | Tests triage prioritization under pressure |
| HARD | 7 shipments, 4 critical failures, 7 turns | Stress-tests maximum crisis management capacity |
An agent that scores well on EASY but poorly on HARD reveals brittleness under complexity β a real finding, not a grader artifact.
Final Results Anatomy
The final architecture achieved a +327% performance improvement (0.18 baseline β 0.7683 trained average).
Key behaviors learned by the final model:
- World Modeling: The agent learned to always call
get_network_statusas its first action to construct a mental model of route congestion. - SLA Protection: The agent learned to check route load before blindly rerouting, avoiding the
-0.6penalty for congested routes. - Empathy Under Pressure: The agent learned to reliably dispatch well-formed apologies to the correct disrupted customers.
Known Limitations
- Route graph is static: Routes don't dynamically close or change congestion mid-episode. A future version could add stochastic disruption evolution.
- Single-agent only: The environment is not designed for multi-agent scenarios where separate dispatchers handle different regions.
- No partial observability: The agent always sees the full network state after
get_network_status. A more challenging variant would restrict observations to a regional viewport.
Future Extensions
TASK-KOLKATAβ Monsoon flood response at KOPTTASK-VIZAGβ Cyclone-induced port closure on the eastern coastTASK-MUNDRAβ Container ship grounding at India's largest private port- Dynamic route congestion that evolves each turn
- Multi-modal transport (sea + rail + road intermodal chains)