fix: cas-langchain internal mapping not including ai/tool messages#575
Merged
fix: cas-langchain internal mapping not including ai/tool messages#575
Conversation
d327d1e to
a66c0c6
Compare
GabrielVasilescu04
approved these changes
Feb 13, 2026
c0d4e87 to
ac71182
Compare
ac71182 to
c417ec4
Compare
mike-deem-uipath
approved these changes
Feb 13, 2026
| if uipath_message.content_parts: | ||
| for uipath_content_part in uipath_message.content_parts: | ||
| data = uipath_content_part.data | ||
| if uipath_content_part.mime_type.startswith("text") and isinstance( |
Contributor
There was a problem hiding this comment.
should be startswith("text/")
| tool_messages: list[ToolMessage] = [] | ||
| if uipath_message.tool_calls: | ||
| for uipath_tool_call in uipath_message.tool_calls: | ||
| # Only keep tool-calls that have finished |
Contributor
There was a problem hiding this comment.
There shouldn't be any unfinished tool calls unless something is wrong with the graph, right? Might want to treat as an error instead of ignoring. Alternately include without a result, as it's actually valid data.
Contributor
Author
There was a problem hiding this comment.
Makes sense. Yeah I'll make it empty content with "error" status for the LangChain ToolMessage.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The CAS messages, when being converted to LangChain messages, were always being converted to
HumanMessage. This means that the input chat-history was only a list ofHumanMessage, losing conversational-context / tool-calls / results. This PR:AIMessageandToolMessageas wellHumanMessageuses content-blocks which can be later extended for file-attachments.Tested end-to-end with:
and the models take in the Langchain messages correctly and perform as expected.
Note: Ideally we pass in content_blocks for
AIMessageas well rather than string content, but when doing so, OpenAI errors unless amsg_prefix is used for content-block IDs. When needed, we can switch to content_blocks but need to work out a common ID strategy across models for the content-block IDs. At the moment there's no use-case for passing in multiple content-blocks just yet (Our CAS Assistant messages wouldn't include other blocks right now, e.g. file-attachments or reasoning).Example:
Input:

Output Before:

Output After:

In json.dumps form