E-Commerce Order Resolution Agent Benchmark Generator
Generate an automated LLM-as-a-judge Python evaluation script to benchmark retail order resolution agents against return policies and edge cases.
Use this template when deploying or auditing automated retail customer care agents handling returns, refunds, and exchanges. It produces a complete automated evaluation harness to detect policy deviations, hallucinated concessions, and latency bottlenecks.
Role: Principal AI Evaluation Engineer specializing in retail customer care automation and LLM-as-a-judge benchmarking systems.
Context
- Target Retailer: {{brand_name}}
- Live Agent Endpoint: {{agent_endpoint}}
- Authoritative Policy Source: {{return_policy_rules}}
- Test Corpus Location: {{edge_case_dataset}}
- Maximum Concession Margin: {{tolerance_threshold}}
- Primary Evaluation Metrics: {{eval_metric_suite}}
Task
Generate a production-grade Python evaluation script that sends synthetic customer scenarios to {{agent_endpoint}}, evaluates the conversational agent responses against {{return_policy_rules}} using LLM-as-a-judge techniques, and asserts that financial concessions do not exceed {{tolerance_threshold}}.
Method
- Parse {{edge_case_dataset}} into structured synthetic customer sessions containing order histories, return reasons, and emotional escalation markers.
- Construct an asynchronous execution loop to replay sessions against {{agent_endpoint}} while recording request-response pairs and token latency.
- Build an evaluation engine incorporating {{eval_metric_suite}} to score policy adherence, factual grounding, and tone consistency.
- Embed deterministic boundary assertions that detect illegal refund approvals exceeding {{tolerance_threshold}} without human-in-the-loop triggers.
- Implement an LLM judge prompt that scores the agent transcripts against exact clauses inside {{return_policy_rules}}.
- Generate summary aggregate statistics including pass rates, false refund rates, hallucinated policy rates, and 95th percentile latency.
- Format execution logs into structured JSON artifacts and terminal console outputs with actionable failure traces.
Constraints
- The generated script MUST be self-contained, executable Python (>=3.10) using standard async libraries (aiohttp, pydantic, pytest-compatible).
- The output MUST NOT hardcode mock secrets or omit error handling for network timeouts.
- Evaluation logic MUST isolate financial over-concession as a blocking catastrophic failure.
- Include type hints and inline docstrings explaining scoring thresholds across {{eval_metric_suite}}.
Output format
- Section 1: Environment prerequisites and installation instructions (Bash).
- Section 2: Complete executable Python evaluation script containing test data parsers, async runner, judge logic, and assertion suite.
- Section 3: Sample JSON report schema outputted by the runner (20-30 lines of JSON).
- Total script length should not exceed 250 lines of code.
Self-review
- Verify all {{return_policy_rules}} and {{tolerance_threshold}} constraints are verified in assertions.
- Ensure async execution handles rate limits gracefully when querying {{agent_endpoint}}.
- Check that evaluation metric definitions align directly with {{eval_metric_suite}}.
Explicit role, a named task, and discrete steps the model can follow.
Background, inputs and variables the model needs before it starts.
Hard boundaries — what the model must and must not do.
A named, field-level shape for the response.
Ordered work items that force analysis before an answer.
Length and structure that travel across frontier models.
Signal density — instruction weight without padding.
Documented variables so the scaffold adapts to new inputs.
Quality bar, assumptions and behaviour when inputs are thin.
How much real usage the template has behind it.