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.
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.
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.
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.
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 | ||
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.
Retrieves full order details by ID or natural language reference. Handles "my last order" and "CDN-00421" equally.
Returns carrier, tracking number, ETA, and current status. Links to carrier tracking when available.
Checks whether an order is cancellable based on status. Confirms or explains why cancellation isn't possible.
Validates return eligibility by delivery date and policy window. Initiates return process or explains ineligibility.
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:
Call 1 result: extracted intent type and order ID from user message, with confidence level
JS DB lookup result: order found or not found, status surfaced immediately
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.
claude-sonnet-4-20250514 — used for both intent extraction and support response generation
luminary-proxy.vikramyeldandi.workers.dev — default route proxies both API calls to Anthropic
JavaScript object store with 4 Caden orders — replaces a real order API for demo purposes
No framework dependencies — single HTML file, portable, zero build step