Repository navigation
fix: present SDK Claude sessions as the CLI entrypoint - #84
Merged
Merged
Conversation
bb spawns Claude sessions through the Agent SDK, which by default tags its API traffic as `cc_entrypoint=sdk-ts` with a `(external, sdk-ts, agent-sdk/<ver>, client-app/bb/1.0.0)` user-agent. Set `CLAUDE_CODE_ENTRYPOINT=cli` and drop `CLAUDE_AGENT_SDK_CLIENT_APP` so sessions instead report `cc_entrypoint=sdk-cli` with a `(external, sdk-cli, agent-sdk/<ver>)` user-agent — byte-identical to the headless `claude -p` CLI. The spawned binary always adds the `sdk-` prefix and an `agent-sdk/<ver>` user-agent segment because the SDK runs it in stream-json mode, so the interactive `cli` entrypoint is not reachable from the SDK; `sdk-cli` is the closest achievable state. Verified by capturing both CLI and SDK traffic through a logging proxy. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
SawyerHood
force-pushed
the
worktree-sdk-cli-traffic-parity
branch
from
June 11, 2026 00:42
01a7787 to
b34a2b2
Compare
2 tasks done
This was referenced Nov 3, 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.
What
Makes bb's Agent-SDK-spawned Claude sessions present their API traffic like the headless Claude CLI (
claude -p) instead of as a third-party SDK app.In
buildSessionEnv:CLAUDE_CODE_ENTRYPOINT=cli(the SDK only defaults it tosdk-tswhen unset).CLAUDE_AGENT_SDK_CLIENT_APP(also clears any value inherited from a parent SDK process).Effect on the wire
Captured both clients through a logging reverse-proxy (
ANTHROPIC_BASE_URL) under OAuth auth, same prompt/model:cc_entrypointsdk-ts(external, sdk-ts, agent-sdk/<ver>, client-app/bb/1.0.0)sdk-cli(external, sdk-cli, agent-sdk/<ver>)claude -psdk-cli(external, sdk-cli, agent-sdk/<ver>)claudecli(external, cli)After this change the SDK traffic is byte-identical to headless
claude -p. The request shape (system-prompt preset, betas, tools,context_management) already matched the CLI before this change — only these identity markers differed.Honest limitation
True interactive
cliparity is not reachable from the SDK: the spawned binary always adds thesdk-prefix and anagent-sdk/<ver>user-agent segment because the SDK runs it in stream-json mode. Empirically confirmed by tryingCLAUDE_CODE_ENTRYPOINT=cli(→sdk-cli, notcli) and attempting to suppress the version segment (the SDK re-injects it).sdk-cliis the closest achievable state.Testing
pnpm exec turbo run typecheck --filter=@bb/agent-runtime✅pnpm exec turbo run test --filter=@bb/agent-runtime✅ (57 tests). Updated thethread/startenv assertion to checkCLAUDE_CODE_ENTRYPOINT=cliandCLAUDE_AGENT_SDK_CLIENT_APPundefined.cc_entrypoint/user-agent end-to-end with a logging proxy.🤖 Generated with Claude Code