Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions pkg/agent/conversation.go
Original file line number Diff line number Diff line change
Expand Up @@ -913,8 +913,12 @@ func candidateToShimCandidate(iterator gollm.ChatResponseIterator) (gollm.ChatRe
if text, ok := part.AsText(); ok {
buffer += text
klog.Infof("text is %q", text)
} else {
yield(nil, fmt.Errorf("no text part found in candidate"))
} else if calls, ok := part.AsFunctionCalls(); ok && len(calls) > 0 {
// If we encounter function calls, we should not use the shim
// Instead, pass through the original response
klog.Infof("Warning: there are non-text parts FunctionCall in the response, returning concatenation of all text parts.")
Copy link

Copilot AI Aug 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The log message is misleading. It states 'returning concatenation of all text parts' but the code actually returns the original response without concatenation.

Suggested change
klog.Infof("Warning: there are non-text parts FunctionCall in the response, returning concatenation of all text parts.")
klog.Infof("Warning: there are non-text parts FunctionCall in the response, returning the original response without concatenation.")

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Aug 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammar issue: 'FunctionCall' should be 'function calls' for better readability.

Suggested change
klog.Infof("Warning: there are non-text parts FunctionCall in the response, returning concatenation of all text parts.")
klog.Infof("Warning: there are non-text parts (function calls) in the response, returning concatenation of all text parts.")

Copilot uses AI. Check for mistakes.
// Return the original response without shim conversion
yield(response, nil)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand correctly,
in case of tool-use-shim, the API does not return toolCalls, so we accumulate all the text and then parse the text to convert into toolcall. So the change here will simply return text response to the layer above.

Copy link

Copilot AI Aug 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The accumulated text buffer is discarded when function calls are detected. Consider whether any accumulated text should be preserved or if this is the intended behavior.

Copilot uses AI. Check for mistakes.
return
}
}
Expand Down