fix: handle overwrite serialization#426
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds support for handling LangGraph's Overwrite type during serialization of runtime outputs. The Overwrite type is a LangGraph wrapper that signals state replacement rather than appending, particularly used in conversational agents. Without this fix, serialization would fail when encountering Overwrite objects.
Changes:
- Added Overwrite serialization handling in
serialize_outputfunction to unwrap and serialize the contained value - Updated dependency versions for uipath, uipath-core, and uipath-runtime packages
- Bumped uipath-langchain version to 0.4.8
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/uipath_langchain/runtime/_serialize.py | Added handling for LangGraph's Overwrite type in the serialize_output function by checking isinstance and recursively serializing the wrapped value |
| pyproject.toml | Updated package version to 0.4.8 and bumped minimum required versions of uipath (2.5.9) and uipath-runtime (0.5.1) dependencies |
| uv.lock | Updated lock file to reflect new package versions and their corresponding hashes |
| # Handle LangGraph types | ||
| if isinstance(output, Overwrite): | ||
| return serialize_output(output.value) |
There was a problem hiding this comment.
The new Overwrite serialization handling is missing test coverage. While the Overwrite type is used in the codebase (e.g., in init_node.py for conversational agents), there are no tests verifying that serialize_output correctly handles Overwrite instances. Consider adding unit tests to verify that when an Overwrite object is passed to serialize_output, it correctly extracts and serializes the wrapped value.
Description
Fix Overwrite serialization in state events
Overwriteis a LangGraph type that bypasses the default reducer and replaces a channel's value directly instead of appending to it. We use it in conversational agents to replace the system message at the start of each turn.The
serialize_outputfunction wasn't handlingOverwriteproperly — it fell through to the generic iterable handler, which failed to convert it and returned the raw object. This causedjson.dumpsto fail downstream.