mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-10-15 00:17:27 +00:00
fix(providers): robust Gemini thought_signature detection and history mapping
Improves supportsThoughtSignature with providerType and model normalization. Strengthens collapseToolCallsWithoutSig with TrimSpace and camelCase support to handle 'Thinking=OFF' whitespace signatures and proxy key translations.
This commit is contained in:
1 parent
bc16af3797
commit
9100f981d7
2 files changed
+14
-3
No files matched your search
@@ -259,8 +259,9 @@ func (p *OpenAIProvider) buildRequestBody(model string, req ChatRequest, stream
|
||||
inputMessages := req.Messages
|
||||
|
||||
// Compute provider capability once: does this endpoint support Google's thought_signature?
|
||||
// We check name, apiBase, and the model string (which covers OpenRouter/LiteLLM routing to Gemini).
|
||||
supportsThoughtSignature := strings.Contains(strings.ToLower(p.name), "gemini") ||
|
||||
// We check providerType, name, apiBase, and the model string (robust detection for proxies/OpenRouter).
|
||||
supportsThoughtSignature := strings.Contains(strings.ToLower(p.providerType), "gemini") ||
|
||||
strings.Contains(strings.ToLower(p.name), "gemini") ||
|
||||
strings.Contains(strings.ToLower(p.apiBase), "generativelanguage") ||
|
||||
strings.Contains(strings.ToLower(model), "gemini")
|
||||
|
||||
|
||||
@@ -17,7 +17,17 @@ func collapseToolCallsWithoutSig(msgs []Message) []Message {
|
||||
continue
|
||||
}
|
||||
for _, tc := range m.ToolCalls {
|
||||
if tc.Metadata["thought_signature"] == "" {
|
||||
// If meta is nil or signature is empty/whitespace, collapse the whole message's tool cycle.
|
||||
// Checks both snake_case and camelCase for cross-proxy reliability.
|
||||
sig := ""
|
||||
if tc.Metadata != nil {
|
||||
sig = tc.Metadata["thought_signature"]
|
||||
if sig == "" {
|
||||
sig = tc.Metadata["thoughtSignature"]
|
||||
}
|
||||
}
|
||||
|
||||
if strings.TrimSpace(sig) == "" {
|
||||
for _, tc2 := range m.ToolCalls {
|
||||
collapseIDs[tc2.ID] = true
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user