Check success before efficiency
Evaluate the task outcome alongside the path. A quick wrong answer or a run that stops early is not better because it used fewer calls. Useful questions include:- Did the run finish the requested task using appropriate evidence?
- Were repeated calls needed for progress or recovery?
- Did a wrong tool or parameter cause the agent to revisit earlier work?
- Did it finish within the application’s work limits?
What the repository calls convergence
loopguard.evals.convergence_score() compares positive step counts with the
shortest count in the supplied list. For each run it divides that baseline by
the run’s count, then averages the ratios:
Work through an example
Suppose three comparable, successful runs take 5, 10, and 20 steps. These are illustrative inputs, not measured LoopGuard benchmark results.
The average is approximately
0.58. Run the helper without a model or API key:
0.0 if none remain.
Keep track of missing runs and failures rather than silently dropping them from
your evaluation report.
Use consistent counting
Choose one definition of a step before comparing runs. A tool call and its result can be two LoopGuard events. A saved export can instead store both in one step. Mixing those counts makes the comparison misleading. Group similar tasks and conditions together. A run fetching ten pages should not be judged against a one-page task just because both use a search tool. Also preserve a baseline when comparing versions. The helper recomputes the shortest count for each supplied list:[5, 5] and [20, 20] both score 1.0.
That does not mean the second version is equally efficient. Review raw counts and
task outcomes alongside the relative score.
Step counts do not measure latency, tokens, or cost. Collect those separately if
they matter to the application.
Turn an observed failure into an evaluation case
Your agent may return a good-looking sales summary after querying incomplete data. A LoopGuard report can help expose repeated work, but checking the data source and answer still needs application-specific evaluation. A useful case records the request, relevant input state, observed trace, expected outcome, and the particular failure to prevent. For stuck-run checks, include both healthy repetition and unhealthy repetition in the dataset. The repository already has examples of healthy polling, retry recovery, pagination, empty-result loops, permanent failures, and action/handoff cycles inexamples/v02_labeled_traces.json.
Its expected_decision fields describe policy expectations, not final-answer quality.