from typing import Any
from agents.extensions.models.any_llm_model import AnyLLMModel, _AnyLLMResponsesParamsShim
class FixedAnyLLMModel(AnyLLMModel):
"""
Fixed the issue where AnyLLMModel failed to verify ResponsesParams when calling multiple rounds of tools.
Root cause: Some versions of any-llm's ResponsesParams.input field only accepts str,
However, after multiple rounds of dialogue, input is already list[TResponseInputItem], causing pydantic to report a verification error.
Fix: Override _make_any_llm_responses_params to force the use of the built-in shim class,
Bypassing pydantic verification, the payload is directly transparently transmitted.
"""
@staticmethod
def _make_any_llm_responses_params(payload: dict[str, Any]) -> Any:
return _AnyLLMResponsesParamsShim(**payload)