[PR #5736] feat: Add context coercion for LangGraph runtime #4620

Closed
opened 2026-02-20 17:50:29 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langchain-ai/langgraph/pull/5736

State: closed
Merged: Yes


Fixes #5735

Implement context coercion functionality for LangGraph runtime to improve API usability.

Key changes:

  • Added _coerce_context function in pregel/main.py
  • Supports coercion for:
    • Pydantic BaseModel
    • Dataclasses
    • TypedDict
  • Comprehensive test coverage added in tests/test_runtime.py
  • Handles edge cases like None context and missing fields

The implementation allows users to pass dictionaries as context, which will be automatically converted to the expected schema type, making the API more flexible and user-friendly.

**Original Pull Request:** https://github.com/langchain-ai/langgraph/pull/5736 **State:** closed **Merged:** Yes --- Fixes #5735 Implement context coercion functionality for LangGraph runtime to improve API usability. Key changes: - Added `_coerce_context` function in `pregel/main.py` - Supports coercion for: - Pydantic BaseModel - Dataclasses - TypedDict - Comprehensive test coverage added in `tests/test_runtime.py` - Handles edge cases like None context and missing fields The implementation allows users to pass dictionaries as context, which will be automatically converted to the expected schema type, making the API more flexible and user-friendly.
yindo added the pull-request label 2026-02-20 17:50:29 -05:00
yindo closed this issue 2026-02-20 17:50:29 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#4620