Commit 9bdf182
committed
feat(google-genai): Support thought signatures for Gemini 3 Pro function calling
Add thought signature support required by Gemini 3 Pro when using function
calling with includeThoughts enabled. Thought signatures preserve reasoning
context during the internal tool execution loop.
Changes from original implementation:
- Attach thought signatures to functionCall parts per Google specification
(not to text parts or separate empty parts)
- Clarify in documentation that validation applies only to the current turn's
function calling loop, not to historical conversation messages
- Add integration tests validating function calls with signatures
Key behaviors:
- Signatures are extracted from model responses and stored in message metadata
- During internal tool execution, signatures are correctly attached to
functionCall parts when sending back function responses
- Handles both parallel and sequential function calls correctly:
- Parallel: only first functionCall gets the signature (per API spec)
- Sequential: each step's first functionCall gets its signature
- Previous turn signatures in conversation history are not validated by the API
See: https://ai.google.dev/gemini-api/docs/thought-signatures
Signed-off-by: Dan Dobrin <dan.dobrin@broadcom.com>
Signed-off-by: Mark Pollack <mark.pollack@broadcom.com>1 parent 2c7b10e commit 9bdf182
File tree
10 files changed
+776
-36
lines changed- auto-configurations/models/spring-ai-autoconfigure-model-google-genai/src/test/java/org/springframework/ai/model/google/genai/autoconfigure/chat
- models/spring-ai-google-genai/src
- main/java/org/springframework/ai/google/genai
- test/java/org/springframework/ai/google/genai
- tool
- spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat
10 files changed
+776
-36
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
134 | 153 | | |
135 | 154 | | |
136 | 155 | | |
| |||
Lines changed: 66 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
281 | 281 | | |
282 | 282 | | |
283 | 283 | | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
284 | 300 | | |
285 | | - | |
| 301 | + | |
286 | 302 | | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
287 | 307 | | |
288 | | - | |
289 | | - | |
290 | | - | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
291 | 312 | | |
292 | 313 | | |
293 | 314 | | |
294 | | - | |
295 | | - | |
296 | | - | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
297 | 324 | | |
| 325 | + | |
298 | 326 | | |
299 | 327 | | |
300 | 328 | | |
| |||
598 | 626 | | |
599 | 627 | | |
600 | 628 | | |
601 | | - | |
602 | | - | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
603 | 645 | | |
604 | 646 | | |
605 | 647 | | |
| |||
710 | 752 | | |
711 | 753 | | |
712 | 754 | | |
713 | | - | |
714 | | - | |
715 | | - | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
716 | 766 | | |
| 767 | + | |
717 | 768 | | |
718 | 769 | | |
719 | 770 | | |
| |||
1062 | 1113 | | |
1063 | 1114 | | |
1064 | 1115 | | |
1065 | | - | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
1066 | 1119 | | |
1067 | 1120 | | |
1068 | 1121 | | |
| |||
Lines changed: 37 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
116 | 129 | | |
117 | 130 | | |
118 | 131 | | |
| |||
206 | 219 | | |
207 | 220 | | |
208 | 221 | | |
| 222 | + | |
209 | 223 | | |
210 | 224 | | |
211 | 225 | | |
| |||
357 | 371 | | |
358 | 372 | | |
359 | 373 | | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
360 | 382 | | |
361 | 383 | | |
362 | 384 | | |
| |||
448 | 470 | | |
449 | 471 | | |
450 | 472 | | |
| 473 | + | |
451 | 474 | | |
452 | 475 | | |
453 | 476 | | |
| |||
460 | 483 | | |
461 | 484 | | |
462 | 485 | | |
463 | | - | |
464 | | - | |
465 | | - | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
466 | 490 | | |
467 | 491 | | |
468 | 492 | | |
469 | 493 | | |
470 | 494 | | |
471 | 495 | | |
472 | 496 | | |
473 | | - | |
474 | | - | |
475 | | - | |
476 | | - | |
477 | | - | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
478 | 502 | | |
479 | 503 | | |
480 | 504 | | |
| |||
602 | 626 | | |
603 | 627 | | |
604 | 628 | | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
605 | 634 | | |
606 | 635 | | |
607 | 636 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | | - | |
| 104 | + | |
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
| |||
Lines changed: 6 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
| 67 | + | |
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | | - | |
| 89 | + | |
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
129 | | - | |
| 129 | + | |
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
| |||
174 | 174 | | |
175 | 175 | | |
176 | 176 | | |
177 | | - | |
178 | | - | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
179 | 180 | | |
180 | 181 | | |
181 | 182 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| |||
0 commit comments