{"record":{"id":"0fbb0ebd7d7840e8","repo":"microsoft/autogen","slug":"function-call-is-deprecated-and-is-not-supported-b","errorCode":null,"errorMessage":"function_call is deprecated and is not supported by this model client.","messagePattern":"function_call is deprecated and is not supported by this model client\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/models/openai/_openai_client.py","lineNumber":743,"sourceCode":"\n        if self._resolved_model is not None:\n            if self._resolved_model != result.model:\n                warnings.warn(\n                    f\"Resolved model mismatch: {self._resolved_model} != {result.model}. \"\n                    \"Model mapping in autogen_ext.models.openai may be incorrect. \"\n                    f\"Set the model to {result.model} to enhance token/cost estimation and suppress this warning.\",\n                    stacklevel=2,\n                )\n\n        # Limited to a single choice currently.\n        choice: Union[ParsedChoice[Any], ParsedChoice[BaseModel], Choice] = result.choices[0]\n\n        # Detect whether it is a function call or not.\n        # We don't rely on choice.finish_reason as it is not always accurate, depending on the API used.\n        content: Union[str, List[FunctionCall]]\n        thought: str | None = None\n        if choice.message.function_call is not None:\n            raise ValueError(\"function_call is deprecated and is not supported by this model client.\")\n        elif choice.message.tool_calls is not None and len(choice.message.tool_calls) > 0:\n            if choice.finish_reason != \"tool_calls\":\n                warnings.warn(\n                    f\"Finish reason mismatch: {choice.finish_reason} != tool_calls \"\n                    \"when tool_calls are present. Finish reason may not be accurate. \"\n                    \"This may be due to the API used that is not returning the correct finish reason.\",\n                    stacklevel=2,\n                )\n            if choice.message.content is not None and choice.message.content != \"\":\n                # Put the content in the thought field.\n                thought = choice.message.content\n            # NOTE: If OAI response type changes, this will need to be updated\n            content = []\n            for tool_call in choice.message.tool_calls:\n                if not isinstance(tool_call.function.arguments, str):\n                    warnings.warn(\n                        f\"Tool call function arguments field is not a string: {tool_call.function.arguments}.\"\n                        \"This is unexpected and may due to the API used not returning the correct type. \"","sourceCodeStart":725,"sourceCodeEnd":761,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/models/openai/_openai_client.py#L725-L761","documentation":"Thrown by OpenAIChatCompletionClient while parsing a completion response when the returned choice.message.function_call is not None. OpenAI's legacy function_call field predates the tool_calls API and this client only supports the modern tool-calling protocol, so any legacy function call in a response is rejected rather than silently mis-parsed.","triggerScenarios":"The chat completion API (or a compatible endpoint) returns a response using the deprecated function_call field instead of tool_calls. Common with OpenAI-compatible proxies/fine-tunes that emulate the old API, or when a fine-tuned model emits legacy function-call format.","commonSituations":"Using an OpenAI-compatible gateway (vLLM, older LiteLLM, local servers) that maps tool calls to the legacy function_call response shape; older fine-tuned models trained on the legacy function API; Azure deployments pinned to old API versions.","solutions":["Point the client at an API version/endpoint that returns tool_calls instead of function_call","Update the compatible server/proxy (vLLM, LiteLLM, etc.) to a version that emits the modern tool_calls format","If using Azure, set a recent api_version in the client config","As a last resort for legacy endpoints, avoid passing tools so the model never emits function calls"],"exampleFix":"# before\nclient = AzureOpenAIChatCompletionClient(azure_endpoint=..., api_version=\"2023-07-01-preview\", ...)\n\n# after\nclient = AzureOpenAIChatCompletionClient(azure_endpoint=..., api_version=\"2024-06-01\", ...)","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    result = await client.create(messages, tools=tools)\nexcept ValueError as e:\n    if \"function_call is deprecated\" in str(e):\n        raise RuntimeError(\n            \"endpoint returns legacy function_call; upgrade the gateway/api_version\"\n        ) from e\n    raise","preventionTips":["Pin modern api_versions for Azure clients and keep compatible gateways updated","Integration-test one tool-call round-trip against each new endpoint before rollout","Prefer endpoints that emit tool_calls; treat legacy function_call as a hard incompatibility"],"tags":["openai","legacy-api","function-calling","response-parsing"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}