Fix variable shadowing in Claude Code nesting traces Python example - #5817
Draft
langsmith-fleet[bot] wants to merge 2 commits into
Draft
Fix variable shadowing in Claude Code nesting traces Python example#5817langsmith-fleet[bot] wants to merge 2 commits into
langsmith-fleet[bot] wants to merge 2 commits into
Conversation
Add missing 'import os', and replace the inline **os.environ dict spread with a named claude_env dict that explicitly excludes LANGSMITH_* SDK variables from the subprocess environment. This avoids potential variable shadowing between the outer SDK env vars and the CC_LANGSMITH_* plugin vars used by the subprocess.
langsmith-fleet
Bot
requested review from
Florence Morris (fjmorris) and
Kathryn May (katmayb)
September 2, 2026 00:09
Replace the single env-var approach with two options: - Option 1 (recommended): write plugin config to a temp JSON file and pass it via 'claude --settings <path>'. This fully isolates CC plugin vars from the parent process environment, eliminating variable shadowing between LANGSMITH_* SDK vars and CC_LANGSMITH_* plugin vars. - Option 2 (fallback): pass env vars directly to subprocess, explicitly excluding LANGSMITH_* keys to avoid shadowing. Both Python and TypeScript examples are included for each option.
Contributor
|
Mintlify preview branch generated: Site preview: https://langchain-5e9cc07a-preview-docscl-1788308092-594beb1.mintlify.site Important Preview links may take a few minutes to start working while the deployment finishes. Changed documentation pages (preview deep links): |
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
import osto the Python "Nesting traces under an existing run" example{**os.environ, ...}dict spread with a namedclaude_envdict that explicitly excludesLANGSMITH_*SDK variables from the subprocess environmentLANGSMITH_*SDK env vars (set viaos.environ) and theCC_LANGSMITH_*plugin vars the subprocess usesLinks
Verification
Not run; docs-only copy and code example change.
Reviewers
Requested review from: Kathryn May (@katmayb), Florence Morris (@fjmorris)