Skip to content

bug(backends): OpenAIBackend intrinsic path raises TypeError when user passes extra_body in model_options #1241

Closed

Description

@planetf1

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.

Activity

  1. added
    bug
    on Jun 9, 2026
  2. added
    p2
    on Jun 18, 2026
  3. self-assigned this
    on Jun 24, 2026
  4. added a commit that references this issue on Jul 31, 2026
    9c7a0e0
  5. planetf1 commented on Aug 5, 2026

    @planetf1
    ContributorAuthor

    I wanted to link a related use-case to this issue.

    The collision fix in PR #1204 (and the equivalent fix needed for the intrinsic path described here) handles the case where a caller passes extra_body in model_options. That's important and we hit it too.

    But there's a second, complementary need: passing extra_body fields at construction time, not per-call — specifically chat_template_kwargs for vLLM Granite models that control thinking tiers (enable_thinking, low_effort). These flags are request-scoped but constant for a given MelleaSession, so construction-time injection is cleaner than per-call.

    AsyncOpenAI doesn't support default_extra_body, so Mellea would need to add its own equivalent on OpenAIBackend. We filed this as a separate feature request at #1453. Flagging here so the two issues can be considered together — the #1241 collision fix and the #1453 construction-time feature are complementary halves of the same problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugp2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions