Key Facts
- Role: Lead Engineer (Contract)
- Stack: LangGraph, Azure AI Foundry, GPT-o3 & GPT-o4-mini, Pinecone, Cohere, Postman/Newman
- Target: Enterprise Logistics (Sorted.com)
- Status: Completed Production Pilot
Executive Summary
At Sorted, the core business value is "Adapter-as-a-Service": customers integrate once with the Sorted API, and the platform handles the complexity of translating that data for hundreds of carriers (FedEx, DPD, DHL, etc.).
The bottleneck was human analysis. Carrier APIs are notoriously complex—a single FedEx quoting endpoint can have over 1,000 fields. Business Analysts (BAs) spent weeks researching schemas and drafting integration specs before engineering could even start. I built a multi-agent orchestration system to automate this technical analysis. By injecting internal heuristics and API standards into a cognitive architecture, the system reduced the research phase of new carrier integrations by ~40 hours per carrier.
The Challenge
The "Translation Problem" in logistics is massive and high-stakes:
- Abstraction vs. Precision: Sorted promises a simplified, single API, but carriers require intricate data (dangerous goods codes, customs declarations, specific address formatting).
- Schema Volume: A single carrier might have 50+ endpoints; mapping them manually is prone to human error and extreme latency.
- Operational Strictness: Mapping errors lead to packages being stuck at customs or returned, causing direct financial loss to customers.
The Stack
I designed a hierarchical agent system optimized for precision and verifiable outputs:
- Orchestration: LangGraph (on Azure AI Foundry) for stateful, multi-turn agent workflows.
- LLMs: GPT-o3 (Architect/Orchestrator) and GPT-o4-mini (Specialized Workers).
- Vector Store: Pinecone (hosting internal documentation and successful integration precedents).
- Verification: Newman/Postman CLI for automated carrier sandbox testing.
- Reranking: Cohere for grounding the agents in the most relevant technical documentation.
Key Architectural Decisions
1. Hierarchical LangGraph Orchestration
I split the cognitive load between an Orchestrator and a "Worker Swarm" to ensure absolute mapping integrity.
- The Orchestrator (GPT-o3): Acts as the Lead Solution Architect. It holds the "Golden Source" context (Sorted's OpenAPI schema) and enforces integration standards. It is responsible for conflict resolution and high-level strategy.
- Specialist Workers (GPT-o4-mini): Smaller, cheaper models delegated to specific domains like "Address Validation," "Customs Declarations," and "Dangerous Goods." Some workers utilize QLoRA-adapted models to enforce strict JSON output formatting.
2. Active Verification (Tool-in-the-Loop)
The system doesn't just read documentation; it verifies assumptions against live carrier sandboxes.
- Automated Payloads: Agents generate synthetic payloads based on their drafted mappings.
- Newman Integration: The system executes these payloads against carrier sandboxes via the Postman CLI.
- Error Reflection: API errors (e.g., "Field X is required for international shipments") are fed back into the LangGraph loop, allowing the Orchestrator to refine the mapping automatically.
3. Precision RAG with Cohere Reranking
To ground the agents in reality, I built a Retrieval-Augmented Generation pipeline that prioritizes technical precedent over generic documentation.
- Precedent Mapping: The system indexes successful integration specs from the past 5 years.
- Reranking: I used Cohere to rerank search results from Pinecone, ensuring that the agents look at how we solved this for DHL when mapping a similar field for a new European carrier.
4. Bounded Confidence Scoring
Every mapping decision is assigned a confidence score based on the model's self-assessment and the success of the active verification step.
- Human-in-the-loop Gates: Low-confidence mappings are explicitly flagged in the final output, allowing Business Analysts to focus their energy exclusively on edge cases rather than the 90% of standard fields.
Outcome
This tool transformed a multi-week research task into a semi-automated, verifiable process. It allowed Business Analysts to shift from "data entry and manual research" to "review and approval," saving approximately one full work week (40 hours) of effort for every new carrier integration added to the Sorted ecosystem.