Skip to content

Commit c8f3942

Browse files
authored
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.
1 parent 23f3f59 commit c8f3942

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

libs/partners/openrouter/langchain_openrouter/chat_models.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -969,8 +969,7 @@ def _wrap_messages_for_sdk(
969969
# Unknown role — pass dict through and hope for the best.
970970
wrapped.append(msg)
971971
continue
972-
fields = {k: v for k, v in msg.items() if k != "role"}
973-
wrapped.append(model_cls.model_construct(**fields))
972+
wrapped.append(model_cls.model_construct(**msg))
974973
return wrapped
975974

976975

0 commit comments

Comments
 (0)