Commit 86e7a15
fix(core): preserve functionCall thoughtSignature when stripping thought parts
Fixes #28604
Root cause: PR #28509 added stripThoughts() to getHistoryTurns() for
Gemini 2.x/modern models when context management is disabled. It
unconditionally drops every history part with thought:true. For turns
where the API attached the required thoughtSignature to that thought
part rather than to the sibling functionCall part, stripping it left
the functionCall with no signature at all. The existing repair
(ensureActiveLoopHasThoughtSignatures) only patches the current active
loop, not older completed turns already sitting in history (e.g. a
prior activate_skill call), so those turns replay on every subsequent
request with a signature-less functionCall and the API rejects them
with 400 INVALID_ARGUMENT "Function call is missing a
thought_signature in functionCall parts."
Fix: stripThoughts() now injects the existing SYNTHETIC_THOUGHT_SIGNATURE
onto a model turn's first functionCall part if stripping removed its
only source of a signature and it doesn't already have one. This
mirrors the equivalent repair pairToolsAndEnforceSignatures() already
performs for the context-management-enabled path in
historyHardening.ts, so both code paths now uphold the same invariant.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>1 parent d55e366 commit 86e7a15
2 files changed
Lines changed: 93 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2387 | 2387 | | |
2388 | 2388 | | |
2389 | 2389 | | |
| 2390 | + | |
| 2391 | + | |
| 2392 | + | |
| 2393 | + | |
| 2394 | + | |
| 2395 | + | |
| 2396 | + | |
| 2397 | + | |
| 2398 | + | |
| 2399 | + | |
| 2400 | + | |
| 2401 | + | |
| 2402 | + | |
| 2403 | + | |
| 2404 | + | |
| 2405 | + | |
| 2406 | + | |
| 2407 | + | |
| 2408 | + | |
| 2409 | + | |
| 2410 | + | |
| 2411 | + | |
| 2412 | + | |
| 2413 | + | |
| 2414 | + | |
| 2415 | + | |
| 2416 | + | |
| 2417 | + | |
| 2418 | + | |
| 2419 | + | |
| 2420 | + | |
| 2421 | + | |
| 2422 | + | |
| 2423 | + | |
| 2424 | + | |
| 2425 | + | |
| 2426 | + | |
| 2427 | + | |
| 2428 | + | |
| 2429 | + | |
| 2430 | + | |
| 2431 | + | |
| 2432 | + | |
| 2433 | + | |
| 2434 | + | |
| 2435 | + | |
| 2436 | + | |
| 2437 | + | |
| 2438 | + | |
| 2439 | + | |
| 2440 | + | |
| 2441 | + | |
| 2442 | + | |
| 2443 | + | |
| 2444 | + | |
| 2445 | + | |
| 2446 | + | |
| 2447 | + | |
| 2448 | + | |
| 2449 | + | |
| 2450 | + | |
| 2451 | + | |
| 2452 | + | |
| 2453 | + | |
| 2454 | + | |
| 2455 | + | |
| 2456 | + | |
| 2457 | + | |
| 2458 | + | |
2390 | 2459 | | |
2391 | 2460 | | |
2392 | 2461 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1533 | 1533 | | |
1534 | 1534 | | |
1535 | 1535 | | |
| 1536 | + | |
| 1537 | + | |
| 1538 | + | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
| 1542 | + | |
| 1543 | + | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
| 1550 | + | |
| 1551 | + | |
| 1552 | + | |
| 1553 | + | |
| 1554 | + | |
| 1555 | + | |
| 1556 | + | |
| 1557 | + | |
| 1558 | + | |
1536 | 1559 | | |
1537 | 1560 | | |
1538 | 1561 | | |
1539 | 1562 | | |
1540 | | - | |
| 1563 | + | |
1541 | 1564 | | |
1542 | 1565 | | |
1543 | 1566 | | |
| |||
0 commit comments