kshitijk4poor
9d61408837
refactor: extract 7 helpers from convert_messages_to_anthropic
Split convert_messages_to_anthropic (complexity 79) into 7 focused helpers:
- _convert_assistant_message — assistant msg to content blocks
- _convert_tool_message_to_result — tool msg to tool_result + merge
- _convert_user_message — user msg validation + conversion
- _strip_orphaned_tool_blocks — orphan tool_use + tool_result removal
- _merge_consecutive_roles — role alternation enforcement
- _manage_thinking_signatures — strip/preserve/downgrade by endpoint
- _evict_old_screenshots — keep only 3 most recent images
Main function complexity: 79 → 10 (below C901 threshold).
Zero logic changes — pure extraction. Net -4 lines (refactor itself);
+45/-17 follow-up polish for annotation tightening (List[Dict] →
List[Dict[str, Any]]), restored rationale comments in
_manage_thinking_signatures (third-party endpoint examples, #13848/#16748
issue refs, redacted_thinking 'data'-as-signature note), and "Mutates
``result`` in place." docstring lines on the four mutating helpers.
2026-05-22 04:23:02 -07:00
..
2026-05-17 02:29:41 -07:00
2026-05-21 14:10:34 -07:00
2026-05-20 23:12:45 -07:00
2026-02-21 22:31:43 -08:00
2026-05-11 11:13:25 -07:00
2026-05-21 23:18:37 -07:00
2026-05-20 14:31:22 -07:00
2026-05-22 04:23:02 -07:00
2026-05-15 14:00:01 -07:00
2026-05-19 14:51:21 -07:00
2026-05-18 10:14:38 -07:00
2026-05-21 12:49:21 +05:30
2026-05-17 02:31:18 -07:00
2026-05-17 04:04:15 -07:00
2026-05-17 04:04:15 -07:00
2026-05-20 14:31:22 -07:00
2026-05-20 23:12:45 -07:00
2026-05-16 23:41:09 -07:00
2026-05-18 10:28:20 -07:00
2026-05-13 22:25:16 -07:00
2026-04-20 01:56:41 -07:00
2026-05-20 11:44:10 -07:00
2026-05-21 23:40:16 -07:00
2026-05-19 00:12:41 -07:00
2026-05-18 10:31:40 -07:00
2026-05-15 12:11:32 -07:00
2026-05-21 14:18:02 -07:00
2026-05-10 06:44:53 -07:00
2026-05-15 10:36:38 +05:30
2026-05-21 23:40:16 -07:00
2026-05-20 23:37:37 -07:00
2026-05-14 08:03:56 -07:00
2026-05-11 11:13:20 -07:00
2026-04-28 06:46:45 -07:00
2026-04-28 06:46:45 -07:00
2026-05-20 22:56:55 -07:00
2026-05-10 07:14:14 -07:00
2026-04-21 21:30:10 -07:00
2026-05-13 22:31:28 -07:00
2026-05-20 23:27:10 -07:00
2026-04-20 05:25:49 -07:00
2026-05-16 17:59:32 -07:00
2026-04-28 12:27:36 -07:00
2026-04-30 23:03:54 -07:00
2026-05-11 16:49:13 -07:00
2026-05-18 10:53:08 -07:00
2026-05-05 13:33:49 -07:00
2026-05-16 17:41:09 -07:00
2026-05-17 02:31:18 -07:00
2026-05-13 23:51:15 -07:00
2026-05-16 13:02:19 -07:00
2026-05-08 14:27:40 -07:00
2026-04-29 08:08:36 -07:00
2026-05-10 07:09:28 -07:00
2026-05-12 20:49:20 -07:00
2026-05-16 17:59:32 -07:00
2026-05-19 03:15:18 -07:00
2026-05-12 20:46:04 -07:00
2026-04-13 16:32:04 -07:00
2026-05-19 14:25:10 -07:00
2026-04-08 00:41:36 -07:00
2026-05-19 00:12:41 -07:00
2026-05-18 21:38:05 -07:00
2026-05-18 00:34:29 -07:00
2026-05-18 19:36:04 -07:00
2026-05-21 19:08:38 -07:00
2026-05-16 18:28:17 -07:00
2026-04-09 03:10:30 -07:00
2026-05-18 20:56:44 -07:00
2026-05-05 04:33:38 -07:00
2026-05-04 12:07:17 -07:00
2026-05-19 20:49:11 +01:00
2026-05-19 20:49:11 +01:00
2026-05-19 00:12:12 -07:00
2026-05-13 06:46:23 -07:00
2026-02-21 22:31:43 -08:00
2026-05-12 16:32:57 -07:00
2026-05-13 16:39:41 -07:00
2026-05-13 16:39:41 -07:00
2026-05-13 22:31:28 -07:00
2026-05-13 22:31:28 -07:00