mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-22 02:03:42 +00:00
fix(ai): correct Google thinking detection and remove unsupported id fields
- isThinkingPart now only checks thought === true, not thoughtSignature - thoughtSignature is for context replay and can appear on any part type - Store thoughtSignature on text blocks as textSignature for proper replay - Remove id from functionCall/functionResponse (unsupported by Vertex/Cloud Code Assist) Refs: https://ai.google.dev/gemini-api/docs/thought-signatures Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
parent
f5e97427ce
commit
4f757fbe23
5 changed files with 33 additions and 22 deletions
|
|
@ -4,12 +4,15 @@ import { isThinkingPart, retainThoughtSignature } from "../src/providers/google-
|
|||
describe("Google thinking detection (thoughtSignature)", () => {
|
||||
it("treats part.thought === true as thinking", () => {
|
||||
expect(isThinkingPart({ thought: true, thoughtSignature: undefined })).toBe(true);
|
||||
expect(isThinkingPart({ thought: true, thoughtSignature: "opaque-signature" })).toBe(true);
|
||||
});
|
||||
|
||||
it("treats a non-empty thoughtSignature as thinking even if thought is missing", () => {
|
||||
// This is the bug: some backends omit `thought: true` but still include `thoughtSignature`
|
||||
expect(isThinkingPart({ thought: undefined, thoughtSignature: "opaque-signature" })).toBe(true);
|
||||
expect(isThinkingPart({ thought: false, thoughtSignature: "opaque-signature" })).toBe(true);
|
||||
it("does not treat thoughtSignature alone as thinking", () => {
|
||||
// Per Google docs, thoughtSignature is for context replay and can appear on any part type.
|
||||
// Only thought === true indicates thinking content.
|
||||
// See: https://ai.google.dev/gemini-api/docs/thought-signatures
|
||||
expect(isThinkingPart({ thought: undefined, thoughtSignature: "opaque-signature" })).toBe(false);
|
||||
expect(isThinkingPart({ thought: false, thoughtSignature: "opaque-signature" })).toBe(false);
|
||||
});
|
||||
|
||||
it("does not treat empty/missing signatures as thinking if thought is not set", () => {
|
||||
|
|
@ -32,6 +35,4 @@ describe("Google thinking detection (thoughtSignature)", () => {
|
|||
const updated = retainThoughtSignature("sig-1", "sig-2");
|
||||
expect(updated).toBe("sig-2");
|
||||
});
|
||||
|
||||
// Note: signature-only parts (empty text + thoughtSignature) are handled by isThinkingPart via thoughtSignature presence.
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue