fix(agent): run native Claude executable directly - #2552
Merged
charlesvien merged 4 commits intoJun 10, 2026
Conversation
Contributor
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
packages/agent/src/adapters/claude/session/options.test.ts:85-101
**Non-parameterised tests for same function under different inputs**
These two tests exercise the same function (`buildSessionOptions`) with different `CLAUDE_CODE_EXECUTABLE` values and expected `executable` outputs — a classic parameterisation candidate. The team convention is to always prefer `it.each` for this pattern. Writing them as a single `it.each` table also makes it easier to add future cases (e.g. `.mjs`, `.cjs`, `claude.exe`) without duplicating the setup/teardown boilerplate.
Reviews (1): Last reviewed commit: "fix(agent): run native Claude executable..." | Re-trigger Greptile |
Contributor
Author
|
The branch was outdated, you can try again. @charlesvien |
charlesvien
force-pushed
the
posthog-code/fix-claude-native-executable
branch
from
June 10, 2026 06:16
581e068 to
eecc600
Compare
charlesvien
enabled auto-merge (squash)
June 10, 2026 06:25
charlesvien
approved these changes
Jun 10, 2026
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.
Problem
Packaged PostHog Code builds now bundle Claude as a platform-specific native executable via
@anthropic-ai/claude-agent-sdkoptional dependencies.On Linux, for example Fedora,
CLAUDE_CODE_EXECUTABLEpoints to the bundled native binary:text
.vite/build/claude-cli/claude
However, the Claude session options still forced:
executable: "node"
This can cause the SDK to try to run the native binary through Node, effectively:
node /path/to/claude
instead of executing it directly:
/path/to/claude
That breaks because the native Claude binary is not JavaScript.
Changes
Make executable: "node" conditional in Claude session options.
Keep using Node only when CLAUDE_CODE_EXECUTABLE points to the legacy JavaScript CLI, e.g. cli.js.
For native Claude executables like claude or claude.exe, leave executable unset so the SDK can execute the binary directly.
Added tests covering both cases:
native binary path does not force Node
legacy .js CLI path still uses Node
How did you test this?
Automated tests run:
PATH=/home/kenayperez/code/node_modules/.bin:/usr/bin:/usr/local/bin:/home/kenayperez/.local/bin /usr/bin/node /usr/lib/node_modules/pnpm/bin/pnpm.cjs -C packages/agent exec vitest run src/adapters/claude/session/options.test.ts --reporter=verbose
Result:
Test Files 1 passed (1)
Tests 8 passed (8)
Also ran:
PATH=/home/kenayperez/code/node_modules/.bin:/usr/bin:/usr/local/bin:/home/kenayperez/.local/bin /usr/bin/node /usr/lib/node_modules/pnpm/bin/pnpm.cjs --filter @posthog/agent typecheck
Result: exited with code 0.