黄云龙
9c77046d10
fix(middleware): drop orphan ToolMessages so strict providers don't 400 ( #4080 )
...
* fix(middleware): drop orphan ToolMessages with no matching AIMessage tool_call
The rebuild loop only skipped ToolMessages whose tool_call_id matched a
known AIMessage tool_call (to be re-emitted after it). An orphan ToolMessage
whose tool_call_id has no matching AIMessage tool_calls fell through and was
kept, leaving a dangling tool result that strict providers reject. Drop
orphan ToolMessages as well, logging at debug.
* fix(dangling): demote orphan-drop logs, add tool_call_id=None test
- Update module/class docstrings to mention orphan ToolMessage handling
- Accumulate orphan drop_count and emit a single logger.warning
instead of per-message logger.debug calls
- Simplify early-return logic: return None only when no patching
AND no orphans were dropped
- Add test_tool_call_id_none_orphan_is_dropped — a ToolMessage
with tool_call_id=None is always an orphan and must be dropped
Closes #4080
Co-Authored-By: Claude <noreply@anthropic.com>
* fix(test): use model_construct for None tool_call_id test to bypass pydantic validation
ToolMessage content='ghost' tool_call_id=None fails pydantic validation at
construction. Use model_construct to simulate a corrupt/edge-case payload
without tripping the string-only guard.
Co-Authored-By: Claude <noreply@anthropic.com>
---------
Co-authored-by: Claude <noreply@anthropic.com>
2026-07-14 22:43:47 +08:00
..
2026-07-14 10:43:13 +08:00
2026-07-01 22:49:17 +08:00
2026-07-04 21:31:01 +08:00
2026-06-30 18:58:02 +08:00
2026-06-01 15:50:39 +08:00
2026-07-05 08:45:27 +08:00
2026-06-21 20:56:42 +08:00
2026-06-08 12:35:03 +08:00
2026-06-18 10:15:31 +08:00
2026-06-11 17:53:37 +08:00
2026-07-14 07:51:59 +08:00
2026-05-21 14:44:34 +08:00
2026-07-03 21:52:31 +08:00
2026-06-23 10:39:40 +08:00
2026-06-21 22:16:00 +08:00
2026-07-11 23:05:03 +08:00
2026-05-29 23:05:59 +08:00
2026-06-16 23:20:20 +08:00
2026-07-02 08:28:29 +08:00
2026-06-21 15:47:53 +08:00
2026-06-24 13:57:12 +08:00
2026-07-09 17:21:25 +08:00
2026-07-09 17:21:25 +08:00
2026-07-02 11:00:49 +08:00
2026-07-05 09:54:55 +08:00
2026-07-14 07:37:59 +08:00
2026-06-16 23:04:39 +08:00
2026-06-18 10:15:31 +08:00
2026-07-12 08:54:03 +08:00
2026-07-12 23:40:52 +08:00
2026-06-18 10:45:33 +08:00
2026-07-13 16:14:36 +08:00
2026-07-12 08:15:32 +08:00
2026-07-12 08:15:32 +08:00
2026-07-06 22:34:41 +08:00
2026-07-04 13:54:04 +08:00
2026-07-03 08:01:46 +08:00
2026-07-13 19:26:07 +08:00
2026-06-10 21:36:25 +08:00
2026-07-05 09:40:16 +08:00
2026-07-07 19:55:33 +08:00
2026-07-05 09:54:55 +08:00
2026-07-04 11:27:19 +08:00
2026-06-12 15:24:58 +08:00
2026-07-13 21:13:33 +08:00
2026-07-14 22:43:47 +08:00
2026-06-08 07:59:50 +08:00
2026-07-13 17:57:34 +08:00
2026-06-02 22:43:22 +08:00
2026-06-05 15:21:41 +08:00
2026-07-12 00:17:11 +08:00
2026-07-04 23:09:29 +08:00
2026-06-02 22:43:22 +08:00
2026-07-01 22:49:17 +08:00
2026-07-13 19:26:07 +08:00
2026-07-04 09:21:19 +08:00
2026-05-26 23:30:24 +08:00
2026-07-04 21:31:01 +08:00
2026-07-04 09:21:19 +08:00
2026-06-12 17:16:01 +08:00
2026-06-09 15:29:40 +08:00
2026-06-18 10:15:31 +08:00
2026-06-12 15:24:58 +08:00
2026-06-13 23:27:17 +08:00
2026-07-02 11:00:49 +08:00
2026-07-13 19:26:07 +08:00
2026-07-01 22:49:17 +08:00
2026-07-04 22:56:24 +08:00
2026-07-05 09:54:55 +08:00
2026-07-02 11:33:32 +08:00
2026-07-14 10:43:13 +08:00
2026-07-10 11:01:39 +08:00
2026-07-02 08:24:15 +08:00
2026-07-04 21:31:01 +08:00
2026-07-14 11:57:48 +08:00
2026-05-21 21:18:10 +08:00
2026-07-04 11:27:19 +08:00
2026-07-03 08:49:33 +08:00
2026-06-07 11:24:30 +08:00
2026-07-11 16:05:30 +08:00
2026-07-06 08:00:49 +08:00
2026-07-14 10:43:13 +08:00
2026-07-04 22:56:24 +08:00
2026-07-04 22:56:24 +08:00
2026-07-04 22:56:24 +08:00
2026-07-12 15:51:22 +08:00
2026-07-04 22:56:24 +08:00
2026-07-04 22:56:24 +08:00
2026-07-04 22:56:24 +08:00
2026-07-04 22:56:24 +08:00
2026-07-04 22:56:24 +08:00
2026-07-04 22:56:24 +08:00
2026-07-03 08:49:33 +08:00
2026-07-12 23:33:52 +08:00
2026-06-21 15:55:10 +08:00
2026-07-11 18:40:07 +08:00
2026-07-06 07:21:12 +08:00
2026-07-14 10:43:13 +08:00
2026-07-06 22:34:41 +08:00
2026-07-10 11:08:30 +08:00
2026-06-28 16:10:44 +08:00
2026-07-08 17:10:27 +08:00
2026-07-14 11:04:11 +08:00
2026-07-04 13:54:04 +08:00
2026-06-17 15:29:22 +08:00
2026-05-19 22:11:46 +08:00
2026-06-08 23:25:29 +08:00
2026-07-12 11:51:31 +08:00
2026-06-10 16:11:00 +08:00
2026-07-13 19:26:07 +08:00
2026-07-13 19:26:07 +08:00
2026-07-04 23:09:29 +08:00
2026-07-11 07:54:15 +08:00
2026-07-09 17:21:25 +08:00
2026-07-03 07:51:22 +08:00
2026-07-13 00:01:22 +08:00
2026-07-04 13:54:04 +08:00
2026-07-13 00:01:22 +08:00
2026-07-04 13:54:04 +08:00
2026-07-03 08:01:46 +08:00
2026-07-14 21:45:37 +08:00
2026-07-14 22:40:51 +08:00
2026-07-03 15:39:12 +08:00
2026-07-09 16:26:31 +08:00
2026-07-04 13:54:04 +08:00
2026-07-12 11:59:36 +08:00
2026-07-10 07:54:36 +08:00
2026-07-09 16:26:31 +08:00
2026-07-09 16:26:31 +08:00
2026-07-14 09:49:43 +08:00
2026-07-04 09:40:05 +08:00
2026-06-25 22:57:00 +08:00
2026-07-14 09:49:43 +08:00
2026-07-11 08:54:45 +08:00
2026-07-12 18:22:22 +08:00
2026-07-12 20:41:41 +08:00
2026-06-18 11:45:35 +08:00
2026-07-12 23:00:45 +08:00
2026-07-14 07:40:49 +08:00
2026-07-11 15:28:16 +08:00
2026-07-14 07:40:49 +08:00
2026-07-06 22:34:41 +08:00
2026-07-11 16:05:30 +08:00
2026-07-04 13:54:04 +08:00
2026-07-14 09:32:53 +08:00
2026-07-14 08:58:06 +08:00
2026-07-11 16:05:30 +08:00
2026-07-14 07:37:59 +08:00
2026-06-22 18:55:20 +08:00
2026-06-21 15:47:53 +08:00
2026-05-28 08:20:52 +08:00
2026-07-11 16:05:30 +08:00
2026-07-04 21:44:22 +08:00
2026-05-28 18:24:32 +08:00
2026-06-08 22:04:38 +08:00
2026-06-09 18:01:43 +08:00
2026-06-12 15:24:58 +08:00
2026-06-24 13:57:12 +08:00
2026-07-11 16:05:30 +08:00
2026-06-24 13:57:12 +08:00
2026-07-11 16:05:30 +08:00
2026-06-24 13:57:12 +08:00
2026-06-24 13:57:12 +08:00
2026-07-14 21:41:35 +08:00
2026-06-24 13:57:12 +08:00
2026-06-24 10:57:45 +08:00
2026-05-21 16:22:09 +08:00
2026-07-09 23:25:38 +08:00
2026-07-14 07:51:59 +08:00
2026-07-06 20:57:41 +08:00
2026-07-11 23:20:53 +08:00
2026-06-17 21:11:44 +08:00
2026-07-03 08:01:46 +08:00
2026-07-14 07:51:59 +08:00
2026-06-08 17:32:41 +08:00
2026-06-09 21:58:31 +08:00
2026-07-11 15:58:07 +08:00
2026-07-11 15:58:07 +08:00
2026-07-14 21:37:47 +08:00
2026-06-24 17:47:04 +08:00
2026-07-02 07:43:09 +08:00
2026-07-12 13:03:02 +08:00
2026-07-02 07:43:09 +08:00
2026-07-14 10:43:13 +08:00
2026-07-14 07:37:59 +08:00
2026-05-21 14:48:28 +08:00
2026-07-14 07:37:59 +08:00
2026-07-13 19:26:07 +08:00
2026-06-01 15:50:39 +08:00
2026-06-24 10:24:36 +08:00
2026-07-03 07:46:04 +08:00
2026-05-22 21:20:28 +08:00
2026-05-22 21:20:28 +08:00
2026-05-22 21:20:28 +08:00
2026-06-25 22:43:28 +08:00
2026-06-03 22:02:27 +08:00
2026-07-03 07:51:22 +08:00
2026-06-23 23:13:12 +08:00
2026-07-13 18:34:41 +08:00
2026-06-25 08:06:17 +08:00
2026-07-12 11:32:41 +08:00
2026-07-12 23:42:58 +08:00
2026-07-04 13:54:04 +08:00
2026-06-12 10:20:38 +08:00
2026-07-04 21:51:57 +08:00
2026-07-04 21:51:57 +08:00
2026-07-04 21:51:57 +08:00
2026-07-04 21:51:57 +08:00
2026-07-04 21:51:57 +08:00
2026-07-04 21:51:57 +08:00
2026-07-04 21:51:57 +08:00
2026-07-04 21:51:57 +08:00
2026-06-12 09:45:26 +08:00
2026-06-19 11:23:07 +08:00
2026-06-18 07:36:35 +08:00
2026-06-27 23:30:54 +08:00
2026-07-07 23:09:06 +08:00
2026-06-21 16:08:25 +08:00
2026-06-14 10:40:16 +08:00
2026-07-05 19:55:39 +08:00
2026-06-19 21:57:03 +08:00
2026-07-04 23:09:29 +08:00
2026-07-04 11:27:19 +08:00
2026-07-04 11:27:19 +08:00
2026-07-04 23:09:29 +08:00
2026-07-07 21:44:28 +08:00
2026-07-13 10:40:22 +08:00
2026-05-28 15:48:32 +08:00
2026-07-10 14:05:47 +08:00
2026-07-11 15:58:07 +08:00
2026-07-11 15:58:07 +08:00
2026-07-04 13:54:04 +08:00
2026-07-11 15:58:07 +08:00
2026-07-07 21:44:28 +08:00
2026-07-07 21:44:28 +08:00
2026-07-04 23:09:29 +08:00
2026-07-04 13:54:04 +08:00
2026-07-14 09:55:38 +08:00
2026-06-18 10:09:46 +08:00
2026-07-08 21:58:33 +08:00
2026-07-13 18:38:32 +08:00
2026-07-13 19:33:40 +08:00
2026-06-12 15:24:58 +08:00
2026-07-12 23:04:59 +08:00
2026-07-11 22:46:10 +08:00
2026-06-14 10:30:45 +08:00
2026-06-08 23:17:22 +08:00
2026-07-14 08:14:21 +08:00
2026-07-13 10:40:22 +08:00
2026-07-13 19:26:07 +08:00
2026-07-11 15:41:57 +08:00
2026-07-11 15:41:57 +08:00
2026-07-13 19:26:07 +08:00
2026-06-19 21:42:42 +08:00
2026-07-08 17:10:27 +08:00
2026-07-14 21:51:47 +08:00
2026-07-07 19:55:33 +08:00
2026-07-01 22:30:55 +08:00
2026-06-24 07:28:17 +08:00
2026-07-11 15:41:57 +08:00
2026-05-21 21:18:10 +08:00
2026-06-18 10:15:31 +08:00
2026-07-11 15:53:14 +08:00
2026-07-10 22:13:50 +08:00
2026-06-21 21:43:43 +08:00
2026-07-14 10:43:13 +08:00
2026-06-12 15:24:58 +08:00
2026-07-14 21:37:47 +08:00
2026-07-04 09:21:19 +08:00
2026-06-02 22:43:22 +08:00
2026-07-03 08:49:33 +08:00
2026-05-22 21:42:14 +08:00
2026-07-14 21:37:47 +08:00
2026-07-08 14:41:16 +08:00
2026-06-10 23:26:15 +08:00
2026-07-11 23:15:03 +08:00
2026-06-12 22:48:47 +08:00
2026-07-08 22:26:06 +08:00
2026-07-04 23:14:46 +08:00
2026-06-23 23:37:41 +08:00
2026-05-19 22:11:46 +08:00
2026-07-11 08:29:42 +08:00
2026-07-04 11:27:19 +08:00
2026-07-10 08:07:25 +08:00
2026-07-06 20:57:41 +08:00
2026-07-06 20:57:41 +08:00
2026-07-12 11:24:24 +08:00
2026-07-14 09:49:43 +08:00
2026-07-03 08:01:46 +08:00
2026-07-03 08:01:46 +08:00
2026-07-14 08:58:06 +08:00
2026-07-14 08:58:06 +08:00
2026-07-03 08:01:46 +08:00
2026-07-03 08:49:33 +08:00
2026-06-25 20:10:49 +08:00
2026-06-25 20:10:49 +08:00
2026-07-03 08:49:33 +08:00
2026-06-25 20:10:49 +08:00
2026-06-25 20:10:49 +08:00
2026-06-25 20:10:49 +08:00
2026-06-25 20:10:49 +08:00
2026-06-25 20:10:49 +08:00
2026-06-25 20:10:49 +08:00
2026-06-25 20:10:49 +08:00
2026-06-25 20:10:49 +08:00
2026-06-25 20:10:49 +08:00
2026-06-25 20:10:49 +08:00
2026-07-12 12:13:02 +08:00
2026-07-04 22:56:24 +08:00
2026-07-01 16:43:56 +08:00
2026-07-14 10:43:13 +08:00
2026-07-04 21:31:01 +08:00
2026-07-04 13:54:04 +08:00
2026-07-11 09:18:12 +08:00
2026-07-14 10:43:13 +08:00
2026-06-09 15:29:40 +08:00
2026-06-08 22:04:38 +08:00
2026-07-04 09:21:19 +08:00
2026-07-06 07:21:12 +08:00
2026-07-04 21:35:05 +08:00
2026-07-12 07:52:45 +08:00
2026-07-05 00:07:27 +08:00
2026-07-12 11:51:31 +08:00
2026-07-06 22:24:14 +08:00
2026-06-07 17:47:11 +08:00