Summary
OpenAIBackend._generate_from_intrinsic() raises TypeError: got multiple values for keyword argument 'extra_body' if a caller passes extra_body in model_options.
Root cause
The intrinsic call site passes extra_body as an explicit keyword argument alongside **api_params:
# openai.py ~line 712
chat_response = self._async_client.chat.completions.create(
model=self._model_id,
messages=messages_dicts,
tools=formatted_tools if use_tools else None,
extra_body=extra_body, # explicit kwarg
**api_params, # may also contain extra_body if user passed it
)
_make_backend_specific_and_remove() treats extra_body as a valid Completions.create parameter and passes it through into api_params. When both the explicit kwarg and **api_params contain extra_body, Python raises TypeError at call time.
Standard path fix (reference)
PR #1204 fixed the identical bug in _generate_from_chat_context_standard() by popping extra_body out of backend_specific before spreading, then deep-merging it into extra_params["extra_body"] (preserving chat_template_kwargs separately). The intrinsic path needs the same treatment.
Reproduction
from mellea.backends.openai import OpenAIBackend
from mellea.stdlib.components import Intrinsic
await mfuncs.aact(
Intrinsic("answerability"),
ctx,
backend,
model_options={"extra_body": {"guided_json": {"type": "string"}}},
)
# → TypeError: got multiple values for keyword argument 'extra_body'
Fix shape
Mirror the standard-path fix from PR #1204: pop extra_body from the result of _make_backend_specific_and_remove() before api_params.update(...), then merge it into the existing extra_body dict (deep-merging chat_template_kwargs as the only nested key either side writes).
Flagged by @ajbozarth in the PR #1204 review. Part of #1201.
Summary
OpenAIBackend._generate_from_intrinsic()raisesTypeError: got multiple values for keyword argument 'extra_body'if a caller passesextra_bodyinmodel_options.Root cause
The intrinsic call site passes
extra_bodyas an explicit keyword argument alongside**api_params:_make_backend_specific_and_remove()treatsextra_bodyas a validCompletions.createparameter and passes it through intoapi_params. When both the explicit kwarg and**api_paramscontainextra_body, Python raisesTypeErrorat call time.Standard path fix (reference)
PR #1204 fixed the identical bug in
_generate_from_chat_context_standard()by poppingextra_bodyout ofbackend_specificbefore spreading, then deep-merging it intoextra_params["extra_body"](preservingchat_template_kwargsseparately). The intrinsic path needs the same treatment.Reproduction
Fix shape
Mirror the standard-path fix from PR #1204: pop
extra_bodyfrom the result of_make_backend_specific_and_remove()beforeapi_params.update(...), then merge it into the existingextra_bodydict (deep-mergingchat_template_kwargsas the only nested key either side writes).Flagged by @ajbozarth in the PR #1204 review. Part of #1201.