Skip to content

Fix/tool example to messages output mismatch - #39160

Closed
eslam-ahmed43 wants to merge 2 commits into
langchain-ai:masterfrom
eslam-ahmed43:fix/tool-example-to-messages-output-mismatch
Closed

Fix/tool example to messages output mismatch#39160
eslam-ahmed43 wants to merge 2 commits into
langchain-ai:masterfrom
eslam-ahmed43:fix/tool-example-to-messages-output-mismatch

Conversation

@eslam-ahmed43

Copy link
Copy Markdown

Problem

tool_example_to_messages silently truncates tool outputs when the number of
tool_outputs does not match the number of tool_calls, because of zip(..., strict=False).

A user passing mismatched outputs gets no error and loses data without knowing.

Closes #39138

Solution

Added a length check before the zip that raises a clear ValueError when
tool_outputs is provided but its length does not match tool_calls.

Tests

  • Mismatched lengths raise ValueError with a descriptive message
  • Matched lengths work as before
  • No tool_outputs provided inserts placeholder as before

InMemoryRecordManager.update() was calling get_time() inside the loop
once per key, causing timestamp drift across large batches. This made
list_keys(before=...) miss stale documents during full/incremental
cleanup, resulting in fewer deletions than expected (see langchain-ai#39087).

Fixes langchain-ai#39087
@github-actions

Copy link
Copy Markdown
Contributor

This PR has been automatically closed because you are not assigned to the linked issue.

Opening a PR before assignment is discouraged and is not an indication that it will be accepted. This process exists so maintainers can confirm a change is aligned with the project direction before contributors invest time implementing it. Please:

  1. Comment on the linked issue explaining the approach you would like to take and why — include enough detail for a maintainer to evaluate the design. Do not post a drive-by "please assign me" comment with no substance; those will be ignored.
  2. Wait for a maintainer to approve the approach and assign you. Once assigned, this PR can be reopened automatically.

Maintainers: reopen this PR or remove the missing-issue-link label to bypass this check.

@github-actions github-actions Bot closed this Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core `langchain-core` package issues & PRs external missing-issue-link new-contributor size: S 50-199 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(core): tool_example_to_messages silently truncates mismatched tool outputs

1 participant