chore(closes OPEN-10731): async LangChain callback handler tool call …#644
Merged
viniciusdsmello merged 1 commit intoMay 14, 2026
Conversation
viniciusdsmello
approved these changes
May 14, 2026
Merged
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.
Pull Request
Summary
Fix the LangChain callback handler so
ToolMessage.artifact(returned by@tool(response_format="content_and_artifact")) is captured on the trace instead of being silently dropped. When the artifact is a list of LangChainDocumentinstances, the page-content strings are also promoted to the trace-levelcontextreserved column, matching the existing retriever behavior.Changes
_extract_tool_outputhelper that handles three shapes LangChain may pass toon_tool_end:ToolMessagewith
.content/.artifact, raw(content, artifact)tuple, and plain string (backward-compat)._is_document_listpredicate (non-empty sequence whose elements all havepage_content)._handle_tool_endto store the artifact instep.metadata["artifact"]and, when it's a document list,populate trace-level
context. Stepoutputstays a string so downstream agent loops feedingstep.outputback tothe LLM aren't disturbed.
run_id → tracemap onOpenlayerHandlerMixin(maintained in_start_step/_end_stepon both sync andasync handlers) and a
_find_tracehelper so context promotion works in pure-callback mode (no outertracer.trace()wrapper).
_find_tracelookup into_handle_retriever_endand the_handle_chain_endsource_documentsbranch so those paths also populatecontextin pure-callback mode.tests/test_langchain_callback.pywith 6 cases (plain-string, tuple,ToolMessagewith dictartifact, document-list promotion sync + async, end-to-end metadata serialization).
examples/tracing/langchain/tool_artifact_example.pyreproducing the reporter's scenario.Context
OPEN-10731: Async LangChain callback handler tool call improvements
Testing
Monitoring