Pluviobyte
0a521f09fb
fix(gemini): close tool_use block before text in messages streaming
...
When the Gemini->Anthropic streaming bridge for the /v1/messages endpoint
receives a functionCall part followed by a text part, the text branch in
handleStreamingResponse opened a new text content block without closing the
already-open tool_use block. The tool block's content_block_stop was only
emitted at end-of-stream, after the text block's content_block_start, so the
Anthropic SSE stream contained overlapping/unterminated content blocks. Clients
that assemble messages by block index (e.g. Claude Code) can drop the tool
input or mis-parse the response.
The functionCall branch already closes an open text block before opening a tool
block, and the chat-completions sibling closes the tool block in its text branch
via closeOpenTool(). This applies the same symmetric handling to the messages
variant: close any open tool_use block (resetting openToolIndex/openToolName/
seenToolJSON) before starting text.
Adds a regression test that replays a tool->text Gemini stream and asserts the
Anthropic content-block lifecycle never overlaps.
2026-05-29 06:47:23 +00:00
..
2026-05-28 01:27:11 +08:00
2026-05-27 23:55:34 +08:00
2026-05-08 03:44:04 +08:00
2026-05-08 03:44:04 +08:00
2026-04-25 14:52:58 +08:00
2026-05-26 11:24:25 -07:00
2026-05-26 20:29:48 +08:00
2026-05-26 20:29:48 +08:00
2026-05-05 03:26:54 +08:00
2026-05-26 13:57:59 +08:00
2026-05-26 13:57:59 +08:00
2026-05-26 13:57:59 +08:00
2026-05-26 13:57:59 +08:00
2026-05-19 15:43:21 +08:00
2026-05-19 15:43:21 +08:00
2026-05-29 10:30:33 +08:00
2026-05-03 20:33:14 +08:00
2026-05-05 06:44:37 -07:00
2026-04-27 17:32:34 +08:00
2026-05-23 10:18:43 +08:00
2026-05-08 03:44:04 +08:00
2026-05-26 10:49:20 +08:00
2026-05-05 06:44:37 -07:00
2026-04-23 16:34:37 +08:00
2026-05-05 03:26:54 +08:00
2026-04-23 16:34:37 +08:00
2026-04-23 16:34:37 +08:00
2026-04-23 16:34:37 +08:00
2026-05-27 18:00:45 +08:00
2026-04-25 20:22:07 +08:00
2026-05-03 22:12:57 +08:00
2026-05-27 09:02:15 +00:00
2026-05-28 00:02:50 +08:00
2026-05-12 16:12:08 +08:00
2026-05-29 09:56:48 +08:00
2026-05-26 20:29:48 +08:00
2026-05-27 18:00:45 +08:00
2026-05-27 18:00:45 +08:00
2026-05-27 18:00:45 +08:00
2026-05-07 09:14:47 +08:00
2026-05-20 13:25:58 +08:00
2026-05-26 10:49:20 +08:00
2026-05-26 10:49:20 +08:00
2026-05-26 10:49:20 +08:00
2026-05-26 10:49:20 +08:00
2026-05-26 10:49:20 +08:00
2026-05-26 10:49:20 +08:00
2026-05-26 10:49:20 +08:00
2026-05-26 10:49:20 +08:00
2026-05-19 15:27:47 +08:00
2026-05-26 10:49:20 +08:00
2026-05-26 10:49:20 +08:00
2026-05-20 13:25:18 +08:00
2026-05-29 09:56:48 +08:00
2026-05-25 14:15:39 +08:00
2026-05-26 10:49:20 +08:00
2026-05-26 10:49:20 +08:00
2026-05-26 10:49:20 +08:00
2026-05-26 10:49:20 +08:00
2026-05-26 10:49:20 +08:00
2026-05-12 15:21:31 +08:00
2026-05-27 09:59:58 +00:00
2026-05-27 09:59:58 +00:00
2026-05-15 01:28:13 +08:00
2026-05-15 01:28:13 +08:00
2026-05-21 11:46:24 +08:00
2026-05-20 21:19:06 +08:00
2026-05-20 21:19:06 +08:00
2026-05-19 22:05:43 +08:00
2026-05-19 22:05:43 +08:00
2026-05-19 22:05:43 +08:00
2026-05-19 22:05:43 +08:00
2026-05-19 22:05:43 +08:00
2026-05-19 22:05:43 +08:00
2026-04-23 00:45:10 +08:00
2026-05-15 13:14:07 +08:00
2026-05-15 13:14:07 +08:00
2026-05-21 11:46:24 +08:00
2026-04-25 20:39:58 -04:00
2026-04-29 16:53:09 +08:00
2026-05-07 00:10:20 +08:00
2026-05-23 10:18:43 +08:00
2026-05-23 10:18:43 +08:00
2026-05-07 09:14:47 +08:00
2026-05-22 14:54:06 +08:00
2026-05-22 14:54:06 +08:00
2026-05-07 14:31:19 +08:00
2026-05-28 20:05:24 +08:00
2026-05-28 20:05:24 +08:00
2026-05-26 10:49:20 +08:00
2026-05-27 23:55:34 +08:00
2026-05-20 13:25:58 +08:00
2026-05-20 13:25:18 +08:00
2026-04-23 21:40:58 +08:00
2026-04-23 21:40:58 +08:00
2026-05-19 19:37:41 +08:00
2026-05-28 00:02:50 +08:00
2026-05-07 18:56:11 +08:00
2026-04-24 23:16:32 +08:00
2026-05-11 21:26:41 +08:00
2026-05-28 00:02:50 +08:00
2026-05-26 20:29:48 +08:00
2026-05-26 20:29:48 +08:00
2026-04-23 21:40:58 +08:00
2026-05-11 21:26:41 +08:00
2026-05-26 20:29:48 +08:00
2026-04-25 22:50:35 +08:00
2026-05-26 10:49:20 +08:00
2026-05-20 18:46:50 +08:00
2026-05-28 00:02:50 +08:00
2026-05-21 11:46:24 +08:00
2026-05-03 17:11:27 +08:00
2026-05-28 00:02:50 +08:00
2026-04-29 15:44:54 +08:00
2026-05-11 21:26:41 +08:00
2026-05-11 17:27:04 +08:00
2026-05-19 19:37:41 +08:00
2026-05-16 00:16:38 +08:00
2026-05-29 06:47:23 +00:00
2026-05-29 06:47:23 +00:00
2026-05-26 20:29:48 +08:00
2026-04-29 16:53:09 +08:00
2026-05-27 18:00:45 +08:00
2026-05-05 03:26:54 +08:00
2026-05-27 18:00:45 +08:00
2026-05-28 00:02:50 +08:00
2026-05-26 13:57:59 +08:00
2026-05-26 13:57:59 +08:00
2026-04-24 23:16:32 +08:00
2026-05-05 03:26:54 +08:00
2026-05-12 15:21:31 +08:00
2026-05-12 15:21:31 +08:00
2026-05-12 15:21:31 +08:00
2026-05-12 16:04:24 +08:00
2026-05-12 15:21:31 +08:00
2026-05-26 20:29:48 +08:00
2026-05-26 20:29:48 +08:00
2026-04-23 00:45:10 +08:00
2026-05-20 16:40:18 +08:00
2026-05-20 16:40:18 +08:00
2026-04-23 12:58:13 +08:00
2026-05-26 20:29:48 +08:00
2026-05-26 20:29:48 +08:00
2026-04-25 14:52:58 +08:00
2026-05-29 08:58:10 +08:00
2026-04-25 14:52:58 +08:00
2026-05-29 08:58:10 +08:00
2026-05-26 13:57:59 +08:00
2026-05-27 23:55:34 +08:00
2026-05-27 23:55:34 +08:00
2026-05-19 15:14:36 +08:00
2026-05-19 15:14:36 +08:00
2026-04-25 14:52:58 +08:00
2026-04-25 14:52:58 +08:00
2026-04-25 14:52:58 +08:00
2026-05-19 09:53:50 +08:00
2026-05-05 19:36:33 +08:00
2026-05-05 19:36:33 +08:00
2026-05-28 19:39:52 +08:00
2026-05-28 19:39:52 +08:00
2026-05-13 11:25:15 +08:00
2026-05-14 16:45:31 +08:00
2026-05-14 16:45:31 +08:00
2026-05-03 17:43:56 +08:00
2026-05-26 21:33:28 +08:00
2026-05-27 22:09:55 +08:00
2026-05-26 21:33:28 +08:00
2026-05-27 22:09:55 +08:00
2026-05-27 22:09:55 +08:00
2026-05-26 10:49:20 +08:00
2026-05-26 13:57:59 +08:00
2026-05-27 22:09:55 +08:00
2026-05-27 23:55:34 +08:00
2026-05-28 01:27:11 +08:00
2026-05-29 10:47:12 +08:00
2026-05-07 00:10:20 +08:00
2026-05-27 22:09:55 +08:00
2026-05-29 08:58:10 +08:00
2026-05-27 22:09:55 +08:00
2026-05-05 19:36:33 +08:00
2026-05-11 12:03:17 +08:00
2026-05-05 19:36:33 +08:00
2026-05-05 19:36:33 +08:00
2026-05-05 19:36:33 +08:00
2026-05-05 19:36:33 +08:00
2026-05-05 03:26:54 +08:00
2026-05-12 09:26:53 +00:00
2026-05-04 11:43:00 +08:00
2026-05-05 19:36:33 +08:00
2026-05-08 11:36:09 +08:00
2026-04-27 00:39:06 +00:00
2026-05-19 15:48:36 +08:00
2026-05-05 03:26:54 +08:00
2026-05-23 10:18:43 +08:00
2026-05-23 10:18:43 +08:00
2026-05-25 10:46:58 +08:00
2026-05-25 10:46:58 +08:00
2026-05-29 08:58:10 +08:00
2026-05-28 01:27:11 +08:00
2026-05-28 01:27:11 +08:00
2026-05-25 10:46:58 +08:00
2026-05-28 01:27:11 +08:00
2026-05-29 01:33:42 +00:00
2026-05-29 10:47:12 +08:00
2026-05-26 10:49:20 +08:00
2026-05-26 20:07:00 +08:00
2026-05-28 01:27:11 +08:00
2026-05-20 13:25:32 +08:00
2026-05-19 19:37:41 +08:00
2026-05-04 13:35:26 +08:00
2026-04-29 15:01:02 +08:00
2026-05-19 19:37:41 +08:00
2026-05-26 17:21:56 +08:00
2026-05-26 17:21:56 +08:00
2026-05-19 19:37:41 +08:00
2026-05-19 19:37:41 +08:00
2026-05-19 19:37:41 +08:00
2026-05-20 13:25:32 +08:00
2026-05-19 19:37:41 +08:00
2026-05-19 19:37:41 +08:00
2026-05-19 19:37:41 +08:00
2026-05-04 13:35:26 +08:00
2026-05-19 19:37:41 +08:00
2026-05-26 17:18:27 +08:00
2026-05-11 11:17:26 +08:00
2026-05-11 11:17:26 +08:00
2026-05-11 11:17:26 +08:00
2026-05-11 11:17:26 +08:00
2026-05-11 11:17:26 +08:00
2026-05-19 18:22:12 +08:00
2026-05-11 11:17:26 +08:00
2026-04-23 19:22:43 +08:00
2026-05-11 11:17:26 +08:00
2026-05-20 11:09:18 +08:00
2026-05-19 16:56:31 +08:00
2026-05-20 16:08:41 +08:00
2026-05-19 16:56:31 +08:00
2026-05-11 11:17:26 +08:00
2026-05-11 11:17:26 +08:00
2026-05-14 11:36:02 +08:00
2026-05-20 11:09:18 +08:00
2026-05-11 11:17:26 +08:00
2026-05-11 11:17:26 +08:00
2026-05-19 16:56:31 +08:00
2026-05-20 11:09:18 +08:00
2026-05-26 10:49:20 +08:00
2026-05-19 20:32:32 +08:00
2026-05-19 20:32:32 +08:00
2026-05-05 20:11:12 +08:00
2026-05-28 20:32:16 +08:00
2026-05-23 10:18:43 +08:00
2026-05-23 10:18:43 +08:00
2026-05-26 20:29:48 +08:00
2026-05-11 16:22:40 +08:00
2026-05-28 20:05:38 +08:00
2026-05-26 20:29:48 +08:00
2026-05-19 15:53:28 +08:00
2026-05-19 15:53:28 +08:00
2026-05-20 16:08:41 +08:00
2026-05-20 16:08:41 +08:00
2026-05-21 21:02:26 +08:00
2026-05-21 21:02:26 +08:00
2026-04-29 22:48:39 +08:00
2026-05-23 10:18:43 +08:00
2026-04-29 22:48:39 +08:00
2026-05-27 23:55:34 +08:00
2026-05-26 10:49:20 +08:00
2026-05-21 21:02:26 +08:00
2026-05-21 21:02:26 +08:00
2026-05-27 23:55:34 +08:00
2026-05-27 23:55:34 +08:00
2026-05-19 19:37:41 +08:00
2026-04-23 21:40:58 +08:00
2026-05-18 21:09:11 +08:00
2026-05-18 21:09:11 +08:00
2026-05-21 14:27:50 +08:00
2026-05-21 14:27:50 +08:00
2026-05-18 21:09:11 +08:00
2026-05-20 09:24:51 +00:00
2026-05-23 10:18:43 +08:00
2026-05-08 11:36:09 +08:00
2026-05-20 13:25:58 +08:00
2026-05-28 17:27:01 +08:00
2026-05-28 17:27:01 +08:00
2026-05-18 19:01:12 +08:00
2026-05-18 19:01:12 +08:00
2026-05-12 15:21:31 +08:00
2026-05-20 15:48:38 +08:00
2026-05-19 15:27:47 +08:00
2026-04-23 16:34:37 +08:00
2026-05-26 10:49:20 +08:00
2026-04-23 16:34:37 +08:00
2026-05-26 10:49:20 +08:00
2026-05-20 13:25:58 +08:00
2026-05-18 21:09:11 +08:00
2026-05-18 21:09:11 +08:00
2026-04-23 16:34:37 +08:00
2026-05-08 14:03:15 +08:00
2026-05-11 11:43:44 +08:00
2026-05-26 10:49:20 +08:00