Repository navigation
fix(langchain): deregister langfuse prompts when a chain run errors - #2030
Open
anishgurjar wants to merge 4 commits into
Open
anishgurjar wants to merge 4 commits into
anishgurjar wants to merge 4 commits into
Conversation
Author
|
|
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.
What does this PR do?
on_chain_endderegisters the run's entry in_prompt_to_parent_run_map, buton_chain_errordoes not. A chain run that errors after a Langfuse prompt was registered for it - a nested run that inherited a registration, or a run whose child prompt chain registered one keyed to it - leaks the entry permanently. In a service that retries failing chains, the map grows without bound.on_chain_errornow deregisters the run in itsfinallyblock, so the cleanup runs even when the error update itself raises. This matches the deregistrationon_chain_endperforms on the success path. Same error-path cleanup class as #1978.Type of change
Verification
Both new tests fail on
main(the registration surviveson_chain_error) and pass with this change.Checklist
code_review.md..env.templateif needed. (not needed)

Confidence Score: 5/5
The PR appears safe to merge.Summary
Removes a failed chain’s prompt registration in
on_chain_error, including when updating the observation raises.Reviews (1) · Last reviewed commit: "style: trim trailing blank line for ruff..." · Reviewed by Greptile