Case study · E-commerce · AI agents

Order-fulfillment agents that find margin per order.

For an e-commerce operator in a commodity market, the price was fixed. The only place left to win was the cost of each order. I built the fulfillment system as a graph of autonomous agents on AWS AgentCore, each one narrow, each one accountable, all of them holding a hard margin floor.

Agent-graph designAWS AgentCoreGuardrails & margin floorEval & observability
Oshri Cohen, AI order-fulfillment agents
Oshri CohenDigital products delivered
The problem

When you can't move the price, you move the cost.

In a commodity market, every competitor charges roughly the same. The order isn't where you make money. The cost of fulfilling it is.

Price is fixed

The market sets it. Discounting is a race to the bottom, and there's no premium tier to climb into. The top line was effectively capped.

Margin hides in the order

Sourcing, shipping and returns all have choices behind them, and each choice moves the per-order cost by a few points. At volume, a few points is the business.

Humans can't price every order

Re-evaluating sourcing, carrier and routing on every single order, in real time, is not a job a human can do at scale. It is exactly a job for a system.

What I built

A graph of narrow agents, not one big swarm.

Specialist agents

Each agent owns one decision, sourcing, carrier selection, returns handling, and does it well. Narrow scope means I can reason about, test and trust each one, instead of debugging an opaque mega-agent.

A directed graph, not a free-for-all

Agents are wired into an explicit graph with defined hand-offs, so work flows along paths I designed. No agent improvises outside its lane; the orchestration is the product, not an afterthought.

A hard margin floor

The system optimizes cost per order aggressively, but a guardrail enforces a margin floor no decision can breach. It finds margin where it exists and refuses orders that would lose money.

Hosted on AWS AgentCore

The agent graph runs on AWS AgentCore, so hosting, scaling and the runtime are managed infrastructure. I spent the effort on the decision logic and guardrails, not on babysitting servers.

Traceable & accountable

Every order carries a trace: which agent decided what, on what input, and why. When a margin looks wrong, I can follow it back to the exact step instead of guessing.

Built for e-commerce reality

Sourcing, shipping and returns are modeled as the real, messy levers they are. It's the kind of operational AI I describe across e-commerce work, see the broader picture on the e-commerce page.

How it stays honest

Optimization with brakes.

01 · Guardrails

The floor that doesn't move

Cost optimization without a floor will happily chase volume into a loss. The margin floor is enforced as a hard constraint, not a suggestion an agent can talk itself out of.

  • A hard margin floor enforced on every order
  • Agents constrained to their lane in the graph
  • Refuse-the-order paths when no choice clears the floor
  • Decisions bounded by explicit rules, not vibes
02 · Evaluation & observability

Watching what the agents actually do

Autonomous agents drift. The only way to trust them in production is to measure them continuously and trace every decision back to its inputs.

  • Per-order traces across the whole agent graph
  • Evals that catch quality and margin regressions
  • Observability into where cost is won and lost
  • Signals fed back into the agents that make the calls
03 · Cost control

The agents pay for themselves

An agent system that costs more to run than it saves is a science project. I kept the model and orchestration spend in proportion to the per-order margin it captures.

  • Right-sized models per agent, not one expensive model everywhere
  • Orchestration cost tracked against margin captured
  • AgentCore hosting tuned for scale, not vanity
  • Cheaper paths adopted as they become available
The result

Margin where there wasn't any.

Marginfloor
A hard floor no order can breach
Perorder
Margin found in sourcing, shipping & returns
Agentgraph
Narrow specialists, traceable end to end

When the price is fixed, the only honest place to compete is the cost of the order. The agents don't chase volume, they hold the floor and find the margin.

Oshri Cohen · On the fulfillment system
Common questions

What operators ask about this.

Why a graph of narrow agents instead of one capable agent?

Because narrow agents are accountable. Each one owns a single decision, sourcing, carrier, returns, so I can test it, reason about it and trace it. One big agent doing everything is an opaque box: when a margin comes out wrong, you can't tell which part of its reasoning failed. A directed graph of specialists keeps the system legible at scale.

How do you stop cost optimization from losing money?

A hard margin floor, enforced as a constraint the agents can't override. The system optimizes the cost of each order aggressively across sourcing, shipping and returns, but no decision is allowed to breach the floor. When no available choice clears it, the system refuses the order rather than fulfilling it at a loss.

Why AWS AgentCore?

AgentCore handles hosting, scaling and the agent runtime as managed infrastructure, so I could spend the engineering effort on the decision logic, guardrails and observability, the parts that actually capture margin, instead of operating servers. It's the hosting platform for the agent graph, not a constraint on the design.

Need agents that
hold the line?

If your margin is hiding in operations and you want autonomous systems you can actually trust, let's talk about what to build.

hello@oshricohen.me(514) 777-3883Canada · USA · Remote