Skip to content
Closed
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
11 changes: 4 additions & 7 deletions pkg/bridge/ai/provider/vertexai/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,27 +151,24 @@ func (k *thoughtSignature) SaveExtra(toolCalls []openai.ToolCall) {
}

func (k *thoughtSignature) AttachExtra(req *openai.ChatCompletionRequest) {
toolCallIDsToRemove := make(map[string]struct{})

for i, msg := range req.Messages {
var validToolCalls []openai.ToolCall
for _, toolCall := range msg.ToolCalls {
if extra, ok := k.inner.Get(toolCall.ID); ok {
// k.inner.Remove(toolCall.ID)
toolCall.ExtraContent = extra
validToolCalls = append(validToolCalls, toolCall)
} else {
toolCallIDsToRemove[toolCall.ID] = struct{}{}
}
}
req.Messages[i].ToolCalls = validToolCalls
}

var validMessages []openai.ChatCompletionMessage
for _, msg := range req.Messages {
if msg.Role == openai.ChatMessageRoleTool && len(toolCallIDsToRemove) > 0 {
if _, ok := toolCallIDsToRemove[msg.ToolCallID]; ok {
continue
// gemini-3.1-flash-lite-preview non-stream mode has compact bug
if req.Model == "google/gemini-3.1-flash-lite-preview" && req.Stream == false {
if msg.Role != openai.ChatMessageRoleUser {
msg.Role = "model"
}
}
Comment on lines +169 to +173
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

To improve readability and maintainability, it's a good practice to avoid magic strings. The model name "google/gemini-3.1-flash-lite-preview" and the role "model" should be extracted into package-level constants.

For example:

const (
	modelGeminiFlashLitePreview = "google/gemini-3.1-flash-lite-preview"
	roleModel                   = "model"
)

Then you can use these constants in the if condition. Also, req.Stream == false can be simplified to !req.Stream, which is more idiomatic in Go.

validMessages = append(validMessages, msg)
Expand Down
Loading