Skip to content

Fix/tool call accuracy - #2300

Merged
anistark merged 3 commits into
vibrantlabsai:mainfrom
anistark:fix/tool_call_accuracy
Sep 22, 2025
Merged

Fix/tool call accuracy#2300
anistark merged 3 commits into
vibrantlabsai:mainfrom
anistark:fix/tool_call_accuracy

Conversation

@anistark

Copy link
Copy Markdown
Member

Issue Link / Problem Description

sdivye92 and others added 3 commits September 22, 2025 20:03
- equal check between pred_sequence and ref_sequence will check that
  both should be same length
- when equal order of occurence of their elements are same
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Sep 22, 2025
@anistark
anistark merged commit 5df03ee into vibrantlabsai:main Sep 22, 2025
9 checks passed
@anistark
anistark deleted the fix/tool_call_accuracy branch September 22, 2025 15:01
edwiniac pushed a commit to edwiniac/ragas that referenced this pull request Jan 31, 2026
…brantlabsai#2079)

## Problem

ToolCallAccuracy returned scores > 1.0 when predicted tool calls contained
duplicates (e.g., retries, multiple calls to the same tool). The previous
fix (vibrantlabsai#2300) addressed this by using strict sequence matching, but introduced
a regression where ANY length mismatch between predicted and reference tool
calls resulted in a score of 0.0 — even when all reference calls were
correctly made.

## Root Cause

1. `is_sequence_aligned` performed exact equality on full sequences, so
   extra predicted calls (retries) always caused alignment failure → score 0.
2. Positional zip-based scoring couldn't find best matches across tool calls.

## Fix

### Sequence Alignment
- **Strict mode**: Reference names must be a subsequence of predicted names
  (preserves order requirement while tolerating extra/retried calls).
- **Flexible mode**: Uses multiset containment (all reference tool names
  must appear in predicted with sufficient count).

### Scoring
- Replaced positional zip with **greedy best-match**: for each reference
  tool call, finds the predicted call with the highest argument score.
- Each predicted call is consumed after matching (no double-counting).
- Final score clamped to [0.0, 1.0] as a safety net.

### Coverage Penalty
- Only applied when predicted has FEWER calls than reference (missing tools).
- Extra predicted calls no longer penalize the score.

## Test Results

| Scenario | Before (v0.2.15) | Before (main) | After |
|----------|------------------|---------------|-------|
| 3 pred, 1 ref (retries) | 3.0 ❌ | 0.0 ❌ | 1.0 ✅ |
| Exact retry (same args) | >1.0 ❌ | 0.0 ❌ | 1.0 ✅ |
| Perfect match | 1.0 ✅ | 1.0 ✅ | 1.0 ✅ |
| Wrong tool name | 0.0 ✅ | 0.0 ✅ | 0.0 ✅ |
| Fewer pred than ref | 0.0 ✅ | 0.0 ✅ | 0.0 ✅ |

Fixes vibrantlabsai#2079
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants