Normalize a message dict for semantic comparison. The Rust AnnotatedLLMRequest type round-trips messages through serde, which may reorder keys and drop ``None`` values (e.g., ``content: None`` on assistant messages with tool_calls). This helper normalizes both sides for semantic equ
(msg)
| 175 | |
| 176 | |
| 177 | def _normalize_message(msg): |
| 178 | """Normalize a message dict for semantic comparison. |
| 179 | |
| 180 | The Rust AnnotatedLLMRequest type round-trips messages through serde, |
| 181 | which may reorder keys and drop ``None`` values (e.g., ``content: None`` |
| 182 | on assistant messages with tool_calls). This helper normalizes both |
| 183 | sides for semantic equivalence. |
| 184 | """ |
| 185 | normalized = {k: v for k, v in msg.items() if v is not None} |
| 186 | return normalized |
| 187 | |
| 188 | |
| 189 | def assert_round_trip(codec, payload): |