Repository navigation
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
chrikrah
approved these changes
Oct 11, 2026
chrikrah
left a comment
There was a problem hiding this comment.
@dhionson2 approving at 11ac8a0. This fixes #1977, and the new test fails when I put back the old on_llm_error.
$ python -m pytest tests/unit/test_langchain.py -q -p no:cacheprovider # Python 3.14, uv sync --frozen
# head 11ac8a0
24 passed
# head tests, CallbackHandler.py from base bf11ec1
1 failed, 23 passed
FAILED tests/unit/test_langchain.py::test_streamed_llm_error_cleans_only_its_completion_start_time_memo
@hassiebp could you review this one?
This branch has not been deployed
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.
Summary
Fixes #1977.
This PR fixes stale run ID retention in
LangchainCallbackHandlerwhen a streamed LLM execution terminates with an error.Root cause
on_llm_new_token()adds the run ID to_updated_completion_start_time_memoafter recording the first-token timestamp.While
on_llm_end()removes the run ID in itsfinallyblock,on_llm_error()did not perform the same cleanup.This could cause incremental UUID retention when long-lived callback handlers are reused across failed streaming executions.
Changes
finallyblock ofon_llm_error().The change preserves existing public SDK behavior and LangGraph control-flow handling.
Verification
Regression test
Targeted validation
tests/unit/test_langchain.py: 24 passed.git diff --check: passed.Full unit suite on Windows
pydanticand one Windows/POSIX path serialization mismatch.The full suite has not yet been confirmed green on Linux. CI validation is pending.
Scope
This is a minimal, backward-compatible fix limited to the LangChain callback implementation and its regression test.
No dependency, generated API, or public interface changes.

Confidence Score: 5/5
This PR appears safe to merge; no actionable issues were found.Summary
This PR removes a streamed run’s first-token memo entry when
on_llm_errorfinishes.Reviews (1) · Last reviewed commit: "fix(langchain): clean up streaming run m..." · Reviewed by Greptile