Case study · Logistics AI agents

Triaging shipment exceptions with agents that ask before they act

Every delayed shipment produced emails: carriers, customers, warehouses, customs brokers. Staff read, classified and chased each one by hand. The goal was agents that classify exceptions, look up shipment state through governed tools and draft the next action, with a person approving anything that changes the world.

Case studyLogistics · Freight and fulfilmentSumanta Mukhopadhyay8 min read
#agents#ai#llm#mcp#security
CASE STUDY · CASE STUDY · LOGISTICS AI AGENTS28 Oct 2026 · 01:26 GST
At a glance
SectorLogistics · Freight and fulfilment
My roleAI architect
EngagementArchitecture, build and hand-off
ScopeAgent design, tool layer, approvals, evaluation, observability
What changed
  • Exception emails arrive classified, with shipment context attached, instead of as raw inbox items
  • Read-only lookups automated; every state-changing action approved by a person
  • Agent behaviour measured against a labelled set before each release
  • Every run traceable from email to tool calls to the approved action
LangGraphModel Context ProtocolStructured outputsMessage queuesTMS APIsApproval UIEvaluation harnessOpenTelemetry

Anonymised composite. Client names, identifying details and confidential figures are withheld; public facts are cited in the references.

The situation

A logistics operator's customer service and operations teams handled shipment exceptions largely by email. A late container, a failed delivery, a missing customs document or an address query each arrived as free text, often with attachments, sometimes in a long thread. Staff read each message, worked out which shipment it concerned, looked it up in the transport management system (TMS), decided what to do and then did it, across several screens.

The work was repetitive but not trivial. The hard part of each email was usually the same: identify the shipment, understand the exception, gather the facts. The decision itself was often quick once the facts were on one screen.

What had to be true

  • Structured, not chatty: every email becomes a typed exception record, or is routed to a person as unclassifiable.
  • Governed tools: the agent reaches systems only through a defined, permissioned tool layer.
  • Read freely, write with approval: lookups are automatic; anything with side effects needs a person.
  • Inbound email is untrusted and never treated as instructions.
  • Measured and traceable: behaviour evaluated before release, every run inspectable afterwards.

Architecture

The design favoured a defined workflow with agentic steps over an open-ended autonomous agent. Anthropic's guidance on building agents makes the same distinction, recommending the simplest pattern that works and adding autonomy only where it earns its keep1.

Intake
Shared mailboxescarriers, customersQueueone message per jobAttachment parsingPDF, images
Understand
Classifierstructured outputExtractorreferences, dates, partiesShipment matcherconfidence scored
Orchestrate
LangGraph workflowper exception typeState checkpointdurableInterruptshuman approval
Tools
MCP serversscoped toolsTMS read toolsstatus, eventsTMS write toolsapproval onlyMessaging toolsdrafts only
Assure
Labelled eval setreal exceptionsTracesOpenTelemetryAudit logwho approved what
Layered architecture: a fixed workflow, typed outputs at each step, and every system reached through scoped tools.

The data flow, end to end

  1. ReceiveEmail lands on a queue with its thread and attachments
  2. ClassifyException type, shipment references and key facts as a typed record
  3. MatchReferences resolved to a shipment; low confidence routed to a person
  4. Look upRead-only MCP tools fetch status, milestones and contacts from the TMS
  5. ProposeDraft action and reply prepared; workflow pauses for approval
  6. ActOn approval, write tool executes; outcome logged and thread updated
The workflow pauses before any side effect, and resumes from a durable checkpoint after a person decides.

Classification and extraction used structured outputs, where the model's response is constrained to a supplied JSON schema5, so downstream steps receive valid records rather than prose. Approval pauses used LangGraph interrupts, which persist graph state while waiting for human input and resume with that input3. More in structured outputs for reliable LLM integration.

The hard part: tools you can trust an agent with

The model was rarely the weak point. The tool layer was where safety lived. The MCP specification describes tools as model-invoked and recommends that a human can always deny a tool invocation2. The design took that literally:

  • Separate read and write servers, with write tools reachable only from the post-approval step of the workflow.
  • Narrow tools: "get shipment milestones" and "request redelivery", not a general API passthrough.
  • Service identity per tool, scoped to the minimum permissions in the TMS.
  • Email as data: inbound text is passed as content to classify, never as instructions, because prompt injection and excessive agency both appear in the OWASP Top 10 for LLM applications4.

The checklist used is in securing MCP servers and prompt injection defence for agents.

Give an agent the narrowest tools that do the job, and put approval in the workflow, not in the prompt.

How it ran

Agent
  1. Classifies and extracts
  2. Looks up shipment state
  3. Drafts action and reply
Operator
  1. Reviews the case card
  2. Approves, edits or rejects
  3. Handles unclassified mail
Systems
  1. TMS via MCP tools
  2. Messaging via drafts
  3. Traces and audit log
The operator sees one case card with facts gathered; the decision stays with them.
Phase 1Understand
  • Exception taxonomy
  • Labelled sample of emails
  • Current handling steps
Phase 2Read-only
  • Classification and matching
  • Lookup tools
  • Case cards in shadow
Phase 3Assisted actions
  • Write tools behind approval
  • Draft replies
  • Evaluation gate
Phase 4Extend and hand off
  • More exception types
  • Runbooks and owners
  • Autonomy reviews
Read-only first; write tools added only once classification and matching were measured.

Evaluation followed evaluating AI agents for reliability, scoring classification, shipment matching and proposed actions separately, so a regression could be located rather than just noticed.

Key decisions and trade-offs

DecisionAlternativeWhy
Fixed workflow with agentic stepsOpen-ended autonomous agentPredictable, testable paths per exception type
MCP tool layerDirect API calls from promptsStandard, reusable tools with permissions in one place
Approval before side effectsFull autonomyTrust earned with evidence, not assumed
Structured outputs everywhereFree-text parsingTyped records that downstream code can rely on
Separate scores per stepOne end-to-end scoreRegressions can be traced to a step

What I'd do again, and differently

Again: start read-only, build the labelled set from real emails, and keep write tools behind approval. Differently: invest earlier in shipment matching. Ambiguous references caused more escalations than misclassification did, and better matching would have improved every downstream step.

If you are designing agents that touch operational systems, the AI architect page describes how I approach it, or analyse your challenge and bring the result to a call.

References
  1. 1
  2. 2
  3. 3
  4. 4
    OWASP Top 10 for LLM ApplicationsOWASP GenAI Security Project
  5. 5
FAQ

Common questions

Should agents act autonomously on shipments?

Not at first. Read-only lookups can be automated safely; actions that change bookings, notify customers or incur cost should be drafted by the agent and approved by a person until the evaluation evidence supports more autonomy.

Why use MCP for the tool layer?

MCP gives a standard way to describe and expose tools, so the same governed tools can be used by different agents and clients, with permissions and logging in one place.

How do you defend against malicious instructions in inbound emails?

Treat email content as untrusted data, never as instructions; restrict which tools the agent can call from that context, and require approval for any action with side effects.

Keep reading

Related

Open to advisory, fractional CTO & select builds

Let's talk about what you're building.

The fastest route is a free 30-minute call. Prefer to write? Send a message and I'll reply personally within two business days.

Start a conversation

How would you like to reach me?

Book a 30-min callFastest. Pick any open slot on my calendar.→ Write in GmailOpens a pre-filled draft in your browser.→ Use my email appOutlook, Apple Mail or your default client.→

I reply personally within two business days. Time zones from the Americas and Europe to the Middle East and Asia-Pacific.