-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix(scorers): detect AI SDK v5 tool parts in toolCallAccuracy #1364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| "@voltagent/scorers": patch | ||
| --- | ||
|
|
||
| Fix the code-based `toolCallAccuracy` scorer missing tool calls in AI SDK v5 message parts | ||
|
|
||
| The scorer read tool calls from message `parts` only when a part's `type` was exactly `"tool_call"`. AI SDK v5 encodes a tool call in message parts as `type: "tool-<toolName>"`, so those calls were skipped and the scorer reported the expected tool as not called even when it was. It now recognizes `tool-<name>` parts too, matching how it already reads them from tool-call lists. |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -276,7 +276,11 @@ function extractToolNamesFromParts(parts: unknown[]): string[] { | |||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| const partType = normalizeMessageType(part.type); | ||||||||||||||||||||||||
| if (partType !== "tool_call") { | ||||||||||||||||||||||||
| // AI SDK v5 encodes a tool call in message parts as `type: "tool-<name>"`, | ||||||||||||||||||||||||
| // not `"tool_call"`. Accept those too (extractToolName reads the name from | ||||||||||||||||||||||||
| // the type); tool results and streaming events are still excluded because | ||||||||||||||||||||||||
| // shouldExtractToolNameFromType returns false for them. | ||||||||||||||||||||||||
| if (partType !== "tool_call" && !shouldExtractToolNameFromType(partType)) { | ||||||||||||||||||||||||
| continue; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
Comment on lines
+283
to
286
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: AI SDK v5 dynamic tool parts with Prompt for AI agents
Suggested change
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P1: The stream-event guard
shouldExtractToolNameFromTyperejects valid AI SDK v5tool-<toolName>parts when the tool name collides with excluded prefixes or suffixes (e.g.,input_validator→tool_input_validatormatches thetool_input_prefix,generate_deltamatches the_deltasuffix). This causes false negatives where the scorer silently skips actually-called tools, undermining the fix for AI SDK v5 support.Prompt for AI agents