Repository navigation
Conversation
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
Adds
CC_LANGFUSE_HEADERS_COMMAND: a command whose stdout is a JSON object ofheader name → value, passed to the SDK's
additional_headers. It unblocksself-hosted Langfuse behind an authenticating proxy, where spans are currently
exported into a login page and reported as success. Unset, nothing changes —
additional_headers=Noneis already the SDK default.Closes #97, which has the mechanism and a reproduction.
Change
additional_headers(langfuse/langfuse-python#1248) already reaches both thehttpx client and the
LangfuseSpanProcessor, so one seam covers every requestthe hook makes. A command rather than a static value because the proxy token
rotates; each hook run is a fresh process, so no callable headers are needed.
Precedent: git's
credential.helperandGIT_ASKPASS.Notes for review
capture_output=Truekeeps the helper's stdout out of the hook's own stdout,which Claude Code parses as the hook protocol.
timeout=HEADERS_COMMAND_TIMEOUT(10s): theStophook runs every turn, so awedged helper cannot hold the turn open.
info(), and nothing sensitive is logged: keynames on success, exception type and exit status on failure, because
str()ofa
CalledProcessErrorrepeats the command line.shell=Trueis the same trust level as the hook command itself: user config,not remote input.
Authorizationcan be overridden deliberately.Verification
uv run --group dev pytest→ 294 passed on Python 3.10 and 3.13; ruff clean;echo '{}' | uv run --script hooks/langfuse_hook.pyexits 0.tests/unit/test_additional_headers.pycover the headers reachingthe SDK, the wizard option as a fallback, every failure mode (non-zero exit,
timeout, missing helper, bad JSON, non-object, empty object, no output) being
fail-open, and neither header values nor the command line reaching the log.
additional_headerstraces arrive, without it they silently do not.