MCPcopy Create free account
hub / github.com/NVIDIA/NeMo-Relay / _normalize_message

Function _normalize_message

python/tests/test_integration_codecs.py:177–186  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

175
176
177def _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
189def assert_round_trip(codec, payload):

Callers 1

assert_round_tripFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected