From 0304fe0dc57edee897f8752c4145b8bc6c7ee725 Mon Sep 17 00:00:00 2001 From: OmriShukrun_ <68182831+omriShukrun08@users.noreply.github.com> Date: Mon, 27 Apr 2026 18:51:26 +0300 Subject: [PATCH] fix noma v2 deepcopy crashing in build scan payload - new PR (#26605) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Use auth key name if there are no app id in in headers or in extra_data * use key alias instead of key name * Fix * last priority key alias * Fix * Add tests * [Feat] Day-0 support for GPT-5.5 and GPT-5.5 Pro (#26449) * feat(openai): day-0 support for GPT-5.5 and GPT-5.5 Pro Add pricing + capability entries for the new GPT-5.5 family launched by OpenAI on 2026-04-24: - gpt-5.5 / gpt-5.5-2026-04-23 (chat): $5/$30/$0.50 per 1M input/output/cached input - gpt-5.5-pro / gpt-5.5-pro-2026-04-23 (responses-only): $60/$360/$6 per 1M input/output/cached input Other fees (long-context >272k, flex, batches, priority, cache discounts) follow the same ratios as GPT-5.4, with context window retained at 1.05M input / 128K output. No transformation / classifier code changes are required: OpenAIGPT5Config.is_model_gpt_5_4_plus_model() already matches 5.5+ via numeric version parsing, and model registration is driven from the JSON. The existing responses-API bridge for tools + reasoning_effort (litellm/main.py:970) already covers gpt-5.5-pro. Tests: - GPT5_MODELS regression list now covers gpt-5.5-pro and dated variants - New test_generic_cost_per_token_gpt55_pro cost-calc test - Updated test_generic_cost_per_token_gpt55 for long-context fields * fix(openai): mirror reasoning_effort flags onto gpt-5.5 dated variants gpt-5.5-2026-04-23 and gpt-5.5-pro-2026-04-23 were missing the supports_none_reasoning_effort, supports_xhigh_reasoning_effort, and supports_minimal_reasoning_effort flags that their non-dated counterparts define. Reasoning-effort routing in OpenAIGPT5Config is fully capability-driven from these JSON flags — since an absent flag is treated as False for opt-in levels (xhigh), users pinning to a dated snapshot would silently lose xhigh support and diverge from the base alias on logprobs + flexible temperature handling. Copy the flags onto both dated variants so every dated snapshot inherits the base model's reasoning-effort capability profile. Adds a parametrized regression test that asserts supports_{none,minimal,xhigh}_reasoning_effort parity between each dated variant and its non-dated counterpart, preventing future drift when new snapshots are added. * [Feat] Add azure/gpt-5.5 + azure/gpt-5.5-pro entries (+ dated variants) (#26361) * feat(azure): add azure/gpt-5.5 + azure/gpt-5.5-pro entries (+ dated variants) Azure variants of OpenAI's GPT-5.5 family. Microsoft has not yet shipped GPT-5.5 on Azure OpenAI (latest GA on the Foundry models page is GPT-5.4 as of 2026-04-24), but adding the entries day-0 mirrors the established precedent for azure/gpt-5.4* (which were in the cost map before the Azure rollout) so cost tracking and capability flags work the moment customers deploy. Schema follows the existing azure/gpt-5.4* shape: - Same base/long-context pricing as openai/gpt-5.5*: $5/$30 chat, $60/$360 pro per 1M, with priority tier 2x base - Azure variants drop the flex/batches keys (Azure has no flex tier) but keep priority pricing, matching gpt-5.4* precedent - mode=chat for the thinking model, mode=responses for pro reasoning_effort capability flags mirror the OpenAI variants exactly since Azure proxies the same API contract: minimal rejection on both chat and pro, low/none rejection on pro. Once #26456 (which sets supports_low_reasoning_effort + minimal=false on openai/gpt-5.5*) lands, OpenAI and Azure flag profiles align. Tests pin entry presence + pricing for all four Azure variants and verify the live-API-derived reasoning_effort flags. * test: register supports_low_reasoning_effort in cost-map JSON schema azure/gpt-5.5-pro and azure/gpt-5.5-pro-2026-04-23 added in this branch carry supports_low_reasoning_effort=false. The strict 'additionalProperties: false' schema in test_aaamodel_prices_and_context_window_json_is_valid rejected the new key. Register it alongside the other supports_*_reasoning_effort entries. Note: the runtime side of this flag (code that reads it) lands in #26456. Until that PR merges the flag is inert for both Azure and OpenAI pro entries, but having the schema accept it lets cost-map tests pass on either merge order. * Use sanitize deep copy style to replace deepcopy usage * Added test checking error is not happening anymore * Added warning log when json copy failed * Reduce to one change * Fix spaces --------- Co-authored-by: Ido Lavi Co-authored-by: yuneng-jiang Co-authored-by: Mateo Wang <277851410+mateo-berri@users.noreply.github.com> Co-authored-by: TomAlon --- .../guardrail_hooks/noma/noma_v2.py | 3 +- .../guardrail_hooks/test_noma_v2.py | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/litellm/proxy/guardrails/guardrail_hooks/noma/noma_v2.py b/litellm/proxy/guardrails/guardrail_hooks/noma/noma_v2.py index 071613ad5f9..6aeaac949a9 100644 --- a/litellm/proxy/guardrails/guardrail_hooks/noma/noma_v2.py +++ b/litellm/proxy/guardrails/guardrail_hooks/noma/noma_v2.py @@ -7,7 +7,6 @@ import enum import json import os -from copy import deepcopy from datetime import datetime from typing import TYPE_CHECKING, Any, Literal, Optional, Type, cast from urllib.parse import urlparse @@ -139,7 +138,7 @@ class NomaV2Guardrail(CustomGuardrail): logging_obj: Optional["LiteLLMLoggingObj"], application_id: Optional[str], ) -> dict: - payload_request_data = deepcopy(request_data) + payload_request_data = self._sanitize_payload_for_transport(request_data) if logging_obj is not None: payload_request_data["litellm_logging_obj"] = getattr( logging_obj, "model_call_details", None diff --git a/tests/test_litellm/proxy/guardrails/guardrail_hooks/test_noma_v2.py b/tests/test_litellm/proxy/guardrails/guardrail_hooks/test_noma_v2.py index 7a3566fecbd..b6445a7c90d 100644 --- a/tests/test_litellm/proxy/guardrails/guardrail_hooks/test_noma_v2.py +++ b/tests/test_litellm/proxy/guardrails/guardrail_hooks/test_noma_v2.py @@ -160,6 +160,44 @@ class TestNomaV2Configuration: ) assert request_data["messages"][0]["content"] == "hello" + def test_build_scan_payload_survives_unpicklable_request_data( + self, noma_v2_guardrail + ): + """Regression test for NOM-8044: post_call / during_call / during_mcp_call + used to 500 because request_data contained uvloop.Loop and similar + C-extension objects whose __reduce__ raises, which crashed deepcopy.""" + + class _FakeUvloopObject: + def __reduce__(self): + raise TypeError("no default __reduce__ due to non-trivial __cinit__") + + def __repr__(self) -> str: + return "" + + unpicklable = _FakeUvloopObject() + request_data = { + "metadata": {"headers": {"x-noma-application-id": "header-app"}}, + "messages": [{"role": "user", "content": "hello"}], + "event_loop": unpicklable, + } + + payload = noma_v2_guardrail._build_scan_payload( + inputs={"texts": ["hello"]}, + request_data=request_data, + input_type="response", + logging_obj=None, + application_id="dynamic-app", + ) + + assert isinstance(payload["request_data"], dict) + assert payload["request_data"]["event_loop"] == "" + assert payload["request_data"]["messages"] == [ + {"role": "user", "content": "hello"} + ] + + # Original request_data must not have been mutated by the copy. + assert request_data["event_loop"] is unpicklable + def test_build_scan_payload_passes_model_call_details_as_is( self, noma_v2_guardrail ):