Traditional unit tests break when you introduce non-deterministic LLMs, but Diego Damico has a solution for the Sylius Shopping Agent. By shifting focus from exact text matching to verifying store state and tool execution, the team ensures the agent behaves correctly regardless of how it phrases its answers. This approach treats the agent's actions as the source of truth, a necessary pivot for anyone shipping production-grade conversational commerce.

The Shift From Text to State

The core problem with testing agents is that the same input can yield different outputs on every run. Damico explains that while the wording may vary, the outcome cannot. If a shopper requests a sold-out XXL Apollo T-Shirt, the agent must not add it to the cart, regardless of the explanation provided. The eval framework checks acceptance criteria like cart contents and tool calls, ensuring the business logic holds even when the conversational style drifts.

Hybrid Grading: Code and Judges

To handle the ambiguity of natural language, the system uses a two-tier grading mechanism. Deterministic checks use code to verify tool calls, product listings, and cart modifications. For nuanced responses, a separate 'judge' model evaluates the reply against a plain-language rubric. In the example provided, the judge verifies that the agent correctly identifies the stock status and offers a valid alternative, such as the last available XL, without unauthorized substitutions.

Operational Insights and Cost Tracking

Running the eval suite via bin/console agent:eval provides more than just pass/fail metrics. The output includes detailed cost analysis, tracking expenses per turn, round counts, and cache hit rates. This visibility is critical for scaling, as a change that passes all tests but doubles the inference cost per interaction would otherwise go unnoticed until the billing arrives. The framework also supports multiple trials, using flags like --trials and --min-pass to account for model stochasticity.

Key Takeaways

  • Agent tests must validate actions (tool calls, cart state) rather than exact text matches.
  • A secondary 'judge' model is used only for subjective rubrics, minimizing potential errors.
  • The open-source runner tracks cost per turn and cache efficiency alongside pass rates.
  • Saved runs can be re-graded for free using --replay when rubrics or expectations change.

The Bottom Line

This hybrid eval strategy is the blueprint for serious agentic engineering. Stop guessing if your LLM is working and start verifying its impact on the system state.