Repository navigation
fix(langchain): record dict-form assistant messages on workflow and agent spans - #881
Merged
lmolkova merged 4 commits intoOct 15, 2026
Conversation
…gent spans to_output_messages kept only AIMessage instances, so role/content dicts and (role, content) tuples returned in a workflow or agent's `messages` were dropped from gen_ai.output.messages, or an earlier AIMessage was reported as the final output instead. Convert entries with convert_to_messages one at a time in a shared helper used for both inputs and outputs, so a single unconvertible entry no longer drops the other convertible ones. Fixes open-telemetry#388 Assisted-by: Claude Opus 5.5
Assisted-by: Claude Opus 5.5
Pull request dashboard statusMerged · refreshed 2026-10-15 22:32 UTC Status above doesn't look right?
|
rads-1996
approved these changes
Oct 12, 2026
Contributor
Author
|
/easycla |
lmolkova
approved these changes
Oct 13, 2026
… entry Try convert_to_messages on the whole list first and only convert entries one at a time when that fails. In the fallback, BaseMessage instances are kept as they are instead of going through convert_to_messages again. Assisted-by: Claude Opus 5.5
lmolkova
enabled auto-merge
October 13, 2026 23:55
lmolkova
disabled auto-merge
October 13, 2026 23:55
lmolkova
enabled auto-merge
October 13, 2026 23:56
Resolve the conflict in test_callback_handler.py by taking main's removal of the hand-driven callback tests (open-telemetry#884) and moving the dict-form workflow and agent output check into test_chain_input_and_output_capture as a dict-assistant case. Assisted-by: Claude Opus 5.5
auto-merge was automatically disabled
October 14, 2026 02:27
Head branch was pushed to by a user without write access
lmolkova
enabled auto-merge
October 15, 2026 22:14
6 of 7 tasks
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.
Description
Fixes the output half of #388. When a workflow's or agent's
messagescontain role/content dicts or(role, content)tuples,gen_ai.output.messageswas dropped, or an earlierAIMessagewas reported as the final output, becauseto_output_messagesonly keptAIMessageinstances.Inputs and outputs now share a
_normalize_messageshelper that converts entries one at a time, so one unconvertible entry no longer drops the other convertible ones. This picks up the review feedback on #417 (closed as stale); thanks @alexliluz.Repro: a
StateGraphwith a plainmessages: listchannel (noadd_messagesreducer) whose node returns{"role": "assistant", "content": "42"}. Onmaintheinvoke_workflowspan has nogen_ai.output.messages; with this change it records the assistant message.Fixes #388
Type of change
How has this been tested?
tox -e py310-test-instrumentation-genai-langchain-oldest(langchain-core 0.3.86): 448 passed, 11 skippedtox -e py310-test-instrumentation-genai-langchain-latest: 494 passed, 4 skippedtox -e py314-test-instrumentation-genai-langchain-latest: 498 passedtox -e precommitandtox -e typecheck(Python 3.14): passmainand pass with this change.Checklist
AI-assisted (Claude Opus 5.5), disclosed with an
Assisted-by:commit trailer. I have reviewed the change and can answer questions about it.