Skip to content

fix(inference): strip all CLAUDE_CODE_* env vars to prevent subprocess hang#934

Open
rikitikitavi2012-debug wants to merge 9 commits intodanielmiessler:mainfrom
rikitikitavi2012-debug:fix/inference-env-cleanup
Open

fix(inference): strip all CLAUDE_CODE_* env vars to prevent subprocess hang#934
rikitikitavi2012-debug wants to merge 9 commits intodanielmiessler:mainfrom
rikitikitavi2012-debug:fix/inference-env-cleanup

Conversation

@rikitikitavi2012-debug
Copy link
Copy Markdown

Summary

  • Fixes Inference.ts env cleanup incomplete: claude --print hangs inside hooks on Claude Code 2.1.71+ #931Inference.ts only strips CLAUDECODE env var, but Claude Code 2.1.71+ sets additional CLAUDE_CODE_* variables (CLAUDE_CODE_SSE_PORT, CLAUDE_CODE_ENTRYPOINT, etc.) that cause claude --print subprocess to hang silently
  • Replaces single delete env.CLAUDECODE with a prefix-matching loop that strips both CLAUDECODE and any CLAUDE_CODE_* vars
  • Future-proofs against new env vars Claude Code may add in later versions

Test plan

  • Verify claude --print subprocess no longer hangs when invoked from within Claude Code 2.1.71+ hooks
  • Confirm RatingCapture and other inference-dependent hooks produce output again
  • Existing CLAUDECODE stripping still works on older Claude Code versions

🤖 Generated with Claude Code

google-labs-jules bot and others added 9 commits March 3, 2026 11:28
Fix crash where String.prototype.slice splits UTF-16 surrogate pairs (like emojis) causing corrupted JSON output. Added a `safeSlice` utility function that checks if the boundary lands on a high surrogate and gracefully drops the incomplete pair. Replaced all truncation slice calls with `safeSlice` across releases. Also added tests to verify correct emoji truncation logic.

Co-authored-by: rikitikitavi2012-debug <240362902+rikitikitavi2012-debug@users.noreply.github.com>
- Changed unresolved {PRINCIPAL.NAME} variable to 'User'
- Fixed PAI/USER/PROJECTS/README.md path to PAI/USER/TELOS/PROJECTS.md

Fixes danielmiessler#878, danielmiessler#879

Co-authored-by: rikitikitavi2012-debug <240362902+rikitikitavi2012-debug@users.noreply.github.com>
…-refs-3933133749775595210

docs: fix dead references in CONTEXT_ROUTING.md
…surrogate-pairs-7014975337557853207

Fix UTF-16 surrogate pair crash in RatingCapture.hook.ts
Added platform detection using process.platform to handle audio playback.
For macOS, it uses afplay as before. For Linux, it detects and uses aplay or ffplay, and gracefully logs a warning if neither is found without throwing an error. Modified all release versions of server.ts.

Co-authored-by: rikitikitavi2012-debug <240362902+rikitikitavi2012-debug@users.noreply.github.com>
Removed broken/dead links pointing to PAI/DEPLOYMENT.md, PAI/BROWSERAUTOMATION.md, FileBasedMCPs.md, and other unresolvable skill references across the v2, v3, and v4 documentation files.

Co-authored-by: rikitikitavi2012-debug <240362902+rikitikitavi2012-debug@users.noreply.github.com>
…ver-playback-15212498456637421725

fix: support linux audio playback in VoiceServer
…ences-1436366211605020911

fix: remove dead file references from documentation across releases
…s hang

Fixes danielmiessler#931. Claude Code 2.1.71+ sets additional CLAUDE_CODE_* env vars
beyond CLAUDECODE that cause claude --print to hang silently inside hooks.
Strip all matching vars with a prefix loop for future-proofing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inference.ts env cleanup incomplete: claude --print hangs inside hooks on Claude Code 2.1.71+

1 participant