Repository navigation
fix(langchain): preserve conversation text, roles and tool history - #6275
Merged
Merged
Conversation
(cherry picked from commit 83702c7) Signed-off-by: Hao Zhe <[email protected]>
(cherry picked from commit cecca47) Signed-off-by: Hao Zhe <[email protected]>
Motivation: OpenVikingChatMessageHistory dropped a completed ToolPart that
stores call id, name, input and output in one part. The part became a
ToolMessage, and restore_openviking_messages() discarded it because no
pending call had registered its id. A session holding only that part
restored as [] (no exception).
Approach: when a completed part has a tool_id and a nonempty tool_input,
openviking_message_to_langchain() also emits the tool call on the AIMessage.
restore_openviking_messages() drops calls whose id is already active from an
earlier pending call, so no duplicate call is added. Result-only parts (no
input) keep the existing orphan handling. A stored empty tool_input ({}) is
treated as no input and is not restored.
Validation (ran in a local venv with the SDK and integration installed):
- pytest integrations/frameworks/langchain/tests/unit: 182 passed, 1 skipped.
- The new test for a combined part fails without the src change and passes
with it.
- ruff check and ruff format --check pass on src and tests.
Not run: a live OpenViking server or Hermes host; only the in-memory client.
Report: volcengine#6242
Signed-off-by: Pujitha Paladugu <[email protected]>
Assisted-by: claude-sonnet-5-5 (via Claude Code)
(cherry picked from commit b468e19)
Signed-off-by: Hao Zhe <[email protected]>
Signed-off-by: Hao Zhe <[email protected]>
Honor explicit empty tool inputs, deduplicate calls within a stored message, and finish existing call results before emitting another assistant turn. Require recorded call identity when reconstructing a completed part; leave result-only orphans unchanged. Extend the public sync/async history contracts for combined, split, and mixed tool records without mutating stored messages. Signed-off-by: Hao Zhe <[email protected]>
Signed-off-by: Hao Zhe <[email protected]>
Signed-off-by: Hao Zhe <[email protected]>
Signed-off-by: Hao Zhe <[email protected]>
Signed-off-by: Hao Zhe <[email protected]>
Signed-off-by: Hao Zhe <[email protected]>
Signed-off-by: Hao Zhe <[email protected]>
t0saki
approved these changes
Oct 19, 2026
This was referenced Oct 19, 2026
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
Preserve conversation information across LangChain capture, recall-query selection and history restoration. This consolidates three contributed fixes and completes their shared message-conversion contracts:
input_text/output_textblocks previously disappeared from recorded text, tool outputs and recall queries. They now retain their text.user/humanare user content;system/developerare excluded from capture. Typed-message precedence and streamed message chunks are preserved.The zero-argument fix includes the owning server and Python SDK serializers: explicit
tool_input={}is retained, while missing/Noneinputs remain omitted. This uses the existing optional field; there is no schema migration, API signature, dependency or release-workflow change. Budgeted previews omit removed tool inputs on the wire, keeping them distinguishable from genuine{}arguments. Already-persisted records whose text, role or tool input was lost cannot be repaired.Human Involvement
Related Issue
Fixes #5806
Fixes #5853
Fixes #6242
Consolidates #5808, #5854 and #6247.
Type of Change
Changes Made
None, preserving the distinction from real{}arguments and leaving durable messages unchanged.Testing
asyncio.timeouton Python 3.10. Existing streaming, cancellation, recording and tool-history tests are included.aeaf57018, and 94 passes with this correction. They include identical split polling calls with unchanged/changed outputs, unfinished follow-up calls, coalesced polling, changed completed outputs/status, duplicate completed records, ID reuse and late results.Message.from_dict(...).to_dict()server serializer. It covers Responses text, role aliases, split zero-argument calls, repeated combined calls, reused IDs across and within user turns, late results after approval messages, identical polling calls with unchanged and changed outputs, changed combined outputs, and error/empty outputs. It passes with the built SDK/adapter wheels, and with released SDK 0.1.15 using the adapter's dictionary payloads. Typed SDK parts need the serializer correction included here.The HTTP fixture is a controlled server boundary, not a deployed OpenViking backend or external model run. Authentication enforcement and performance are not claimed. Test suites emit deprecation and mock-coroutine warnings.
API/CLI CI at
f33464bdefailed in filesystem embedding setup with a Volcengine401 AuthenticationError(The API key format is incorrect,HAS_SECRETS=false). Its LangChain/SDK matrices and other executed PR checks passed. Updated-head CI is reported separately. The branch merges cleanly with mainb15fa86f5; its two newer fixes do not alter any files changed by this PR.Checklist
Screenshots (if applicable)
Not applicable.
Additional Notes
A malformed history that reuses an unresolved call ID with different arguments can still leave an earlier call unresolved. This change preserves recorded data and does not invent results to normalize such histories.
Original authorship is preserved with
git cherry-pick -x:83702c76) and fix(langchain): preserve generic ChatMessage roles #5854 (cecca479): ktz03.b468e195): Pujitha Paladugu.Test relocation, serializer/retention corrections, and the additional role/restoration fixes are separate commits by Hao Zhe. The original PRs have not been closed or modified.