Agentic Order Management
for Caden Electronics

A two-call agentic pipeline that extracts intent, queries a mock order database, and returns contextual support responses — with a live reasoning trace visible to the user.

Brand Caden Electronics
Model Claude Sonnet 4
Pattern Hybrid 2-call agentic
Token budget ~430 tokens / turn
Overview

The Problem

Standard chatbot support agents handle order queries with a single prompt that embeds the entire database into the system prompt. This works at small scale — but burns 400–600 tokens on every request, including those that don't need order data at all (greetings, general questions, policy queries).

Agent 07 explores a leaner alternative: a two-stage pipeline where the first call is cheap and structural (intent extraction), JavaScript handles the zero-cost data lookup, and only the second call gets contextual data injected — keeping total tokens per turn well under 500 even with a full order record in scope.

Architecture

Two-Call Hybrid Pipeline

Each user message travels through three stages. Only the first and third involve the LLM — the middle stage is pure JavaScript execution at zero token cost.

CALL 1
Intent extractor
~150 sys tokens
~80 max output
JSON intent
JS LOOKUP
Mock DB query
0 tokens
instant
order record
CALL 2
Support response
~150 sys + ~100 ctx
800 max output
answer
UI
Render response
+ order card
+ trace log
DESIGN DECISION

Agent 07 is granted a deliberate exception to the portfolio's 1-call-per-interaction rule. The rationale: genuine tool use requires at minimum a classification pass before the lookup. The hybrid pattern is cheaper than simulated tool use (which embeds the full DB in every call) while being architecturally more honest — the reasoning trace shows real intermediate output, not staged theater.

Token Analysis

Token Budget per Turn

All figures are per-interaction estimates. The key advantage over simulated tool use: context injected into Call 2 is scoped to a single order record (~100 tokens), not the full database (~500 tokens).

Component Call 1 Call 2 Total
System prompt ~150 tok ~150 tok 300
User message ~30 tok ~30 tok 60
Order record (injected) 0 ~100 tok 100
Conversation history 0 ~80 tok avg 80
Max output 80 tok 800 tok 880
Estimated per turn ~430 input + 880 output
COMPARISON

Simulated tool use (full DB in system prompt) would cost ~650 input tokens per turn regardless of query type. The hybrid pattern saves ~220 input tokens per interaction — and keeps output quality higher because Call 2 receives precise, scoped context rather than a noisy full dataset.

Capabilities

What Agent 07 Can Do

🔍
Order Lookup

Retrieves full order details by ID or natural language reference. Handles "my last order" and "CDN-00421" equally.

📦
Shipment Tracking

Returns carrier, tracking number, ETA, and current status. Links to carrier tracking when available.

✕
Cancellation

Checks whether an order is cancellable based on status. Confirms or explains why cancellation isn't possible.

↩
Returns & Refunds

Validates return eligibility by delivery date and policy window. Initiates return process or explains ineligibility.

UI Design

Visible Reasoning Trace

The thought trace panel at the top of the chat interface shows real intermediate outputs — not staged animations. Each step corresponds to an actual pipeline event:

Step 1

Call 1 result: extracted intent type and order ID from user message, with confidence level

Step 2

JS DB lookup result: order found or not found, status surfaced immediately

Step 3

Call 2 completion: support response generated with scoped order context injected

The trace is collapsible and defaults to expanded during active processing. This makes the agentic pattern legible to technical evaluators without cluttering the experience for casual users.

Technical Stack

Implementation

Claude Sonnet

claude-sonnet-4-20250514 — used for both intent extraction and support response generation

CF Worker

luminary-proxy.vikramyeldandi.workers.dev — default route proxies both API calls to Anthropic

Mock DB

JavaScript object store with 4 Caden orders — replaces a real order API for demo purposes

Vanilla JS

No framework dependencies — single HTML file, portable, zero build step