An agent team logs every run of their tool-using agent next to a reference trajectory written by a human: the tool calls an ideal run would make. Turn a batch of those logs into the handful of numbers the team tracks each release.
Implement agent_metrics(runs).
Input: runs, a list of dicts, each with
"calls": the agent's tool calls in order, a list of {"tool": str, "args": dict}"reference": the ideal calls in order, same shape"success": bool, whether the task was completedTwo calls are equal when the tool names are equal and the args dicts are equal.
Output: a dict with these keys, every value a float rounded to 4 decimals:
"completion_rate": fraction of runs with success true."tool_precision": , where is the size of the multiset intersection of the run's calls and its reference calls (order ignored, a call repeated twice can match at most as many times as it appears in both)."tool_recall": ."exact_match_rate": fraction of runs whose call list equals the reference list exactly, order included."efficiency": the mean over successful runs of . A successful run with no calls scores 1.0.0. This covers an empty batch, a batch with no calls at all, and a batch with no successful runs.