refactor(python): move run-compression init into Client.__init__#2798
Draft
Angus Jelinek (angus-langchain) wants to merge 1 commit into
Draft
refactor(python): move run-compression init into Client.__init__#2798Angus Jelinek (angus-langchain) wants to merge 1 commit into
Angus Jelinek (angus-langchain) wants to merge 1 commit into
Conversation
Compression setup previously ran inside tracing_control_thread_func after the first client.info fetch, which meant runs created before that moment lived in tracing_queue while later runs went to compressed_traces. The server-side zstd_compression_enabled flag is now assumed to be set on every supported deployment (cloud and self-hosted), so the asynchronous gate is no longer needed. Now the compression decision is made synchronously in __init__ using only local signals (ZSTD_AVAILABLE, DISABLE_RUN_COMPRESSION, tracing mode, auto_batch_tracing, and user-provided batch_ingest_config.use_multipart_endpoint). The compression thread starts alongside the main tracing thread, so compressed_traces is either set or None for the lifetime of the client. Tests that asserted raw-bytes multipart payloads either opt out with LANGSMITH_DISABLE_RUN_COMPRESSION or decompress via parse_request_data, which now detects zstd frames and decompresses before parsing. The test_create_run_without_compression_support case is removed — the scenario it covered no longer exists. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
Compression setup previously ran inside
tracing_control_thread_funcafter the firstclient.infofetch. This asynchronous gate meant runs created before the server-flag handshake completed lived intracing_queue, while later runs went tocompressed_traces— a race that required a defensive fix in #2796.The server-side
zstd_compression_enabledflag is now assumed to be set on every supported deployment (cloud and all self-hosted versions), so the asynchronous gate is no longer needed.Changes
compressed_traces,_data_available_event,_futures) is initialized inClient.__init__using only local signals:ZSTD_AVAILABLE,DISABLE_RUN_COMPRESSION, tracing mode,auto_batch_tracing, and user-providedbatch_ingest_config.use_multipart_endpoint.__init__, socompressed_tracesis either set or None for the lifetime of the client — no mid-flight transition._background_thread.py.num_known_refsin the tracing thread is now computed fromclient.compressed_traces is not None.tracing_queuestill exists and handles per-request auth/URL overrides, OTel mode, and the ZSTD-not-installed fallback. The race fix from fix(python): flush both tracing_queue and compressed_traces in flush() #2796 stands as defense in depth.Test changes
parse_request_data(tests/unit_tests/conftest.py) now detects zstd frames and streams-decompresses them, so existing payload assertions keep working without per-test changes.bytesdata) now opt out viaLANGSMITH_DISABLE_RUN_COMPRESSION=truerather than relying on the (now-gone) server-flag behaviour.test_create_run_without_compression_supportis deleted — the server-doesn't-support-compression scenario no longer exists.test_client_gcusesclient.flush()instead ofclient.tracing_queue.join()so it drains both queues.