fix(openrouter): include role in sdk model_construct for min dep compat (#35562)

Fix `_wrap_messages_for_sdk` stripping `role` before `model_construct` —
on `openrouter==0.6.0` (minimum dep), the SDK models don't auto-populate
a default `role`, so `model_dump()` omitted it entirely, causing
`KeyError: 'role'` in pre-release checks.
This commit is contained in:
Mason Daugherty
2026-03-04 16:05:30 -05:00
committed by GitHub
parent 23f3f59081
commit c8f394208b

View File

@@ -969,8 +969,7 @@ def _wrap_messages_for_sdk(
# Unknown role — pass dict through and hope for the best.
wrapped.append(msg)
continue
fields = {k: v for k, v in msg.items() if k != "role"}
wrapped.append(model_cls.model_construct(**fields))
wrapped.append(model_cls.model_construct(**msg))
return wrapped