Skip to content

AnyLLMModel failed ResponsePalms validation during multiple rounds of tool calls #2806

@FlyChary

Description

@FlyChary
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)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions