Enhance tool result conversion by validating toolCallId

- Added checks to ensure toolCallId exists and is a valid string before processing tool results.
- Preserves the original part if toolCallId is missing or invalid, improving robustness in message conversion.
This commit is contained in:
dal 2025-08-24 21:51:13 -06:00
parent 980a786d21
commit 7b9afdbb2f
No known key found for this signature in database
GPG Key ID: 16F4B0E1E9F61122
2 changed files with 12 additions and 0 deletions

View File

@ -167,6 +167,12 @@ function convertToolResultPart(part: unknown): unknown {
}
}
// Ensure toolCallId exists and is valid
// If it's missing or invalid, preserve the original part
if (!rest.toolCallId || typeof rest.toolCallId !== 'string') {
return part;
}
return {
...rest,
output,

View File

@ -166,6 +166,12 @@ function convertToolResultPart(part: unknown): unknown {
}
}
// Ensure toolCallId exists and is valid
// If it's missing or invalid, preserve the original part
if (!rest.toolCallId || typeof rest.toolCallId !== 'string') {
return part;
}
return {
...rest,
output,