This repository was archived by the owner on Nov 11, 2026. It is now read-only.
Repository navigation
fix(py): finish closed streams and retain async errors - #3482
Open
Stefan Wang (1fanwang) wants to merge 8 commits into
Open
Stefan Wang (1fanwang) wants to merge 8 commits into
Stefan Wang (1fanwang) wants to merge 8 commits into
Conversation
Signed-off-by: 1fanwang <1fannnw@gmail.com>
Signed-off-by: 1fanwang <1fannnw@gmail.com>
Signed-off-by: 1fanwang <1fannnw@gmail.com>
Signed-off-by: 1fanwang <1fannnw@gmail.com>
Signed-off-by: 1fanwang <1fannnw@gmail.com>
Signed-off-by: 1fanwang <1fannnw@gmail.com>
Signed-off-by: 1fanwang <1fannnw@gmail.com>
This brings the branch up to date with upstream main. The only conflict was in test_multipart_retry_matrix.py, where upstream gave its local endpoint fixture a status override per path and a list of requested paths, while this branch had moved that fixture into conftest.py. I kept the shared fixture and gave it the same two capabilities, so the upstream test is unchanged. Signed-off-by: 1fanwang <1fannnw@gmail.com>
Contributor
|
Hey Stefan Wang (@1fanwang), thanks for this PR 🙏 This repo is archived, so it can’t be merged here anymore, the SDKs moved to: If it's still relevant, please reopen it on the right repo ! More context in #3691 |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
Closing a wrapped OpenAI stream releases its HTTP response but can leave the LangSmith run unfinished. Async stream failures can also lose their error, or the trace can record success before a later context error.
The fix records partial output when a stream closes and preserves the exception from the outer async context. Repeated closure does not emit another completion.
Testing Done
Real OpenAI and LangSmith clients exchange server-sent events and trace updates with a local HTTP server. These runs do not call a hosted provider.
The baseline is 3114edf. From the Python SDK directory, use its locked Python 3.12 test environment:
Without the fix:
With the fix, from the same Python SDK directory:
make tests TEST='tests/unit_tests/test_run_helpers.py -k openai_stream_records -n 0 -p no:dotenv --tb=short --log-cli-level=INFO'