Skip to content

fix(claude-cli): label Claude CLI turns as opencodex (carries #7837) - #8770

Merged
lidge-jun merged 2 commits into
devfrom
carry/7837-claude-entrypoint
Nov 15, 2026
Merged

lidge-jun merged 2 commits into
devfrom
carry/7837-claude-entrypoint

Conversation

@lidge-jun

@lidge-jun lidge-jun commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

Carries #7837 by @Peteralm (accepted as-is by the owner in the 2026-11-15 backlog review; the branch was idle since 2026-10-31).

claude -p and the Agent SDK identify as sdk-cli / sdk-ts, and those entrypoints use up the Claude subscription's 5-hour window about 1.8x faster than other entrypoints for the same work (anthropics/claude-code#97074; measurements in #7837). The claude-cli adapter now sets CLAUDE_CODE_ENTRYPOINT=opencodex in the CLI child environment (src/adapters/claude-cli/adapter.ts), with #7837's regression test.

The maintainer addition: tests/providers/claude-cli-adapter.test.ts pins the child environment to an exact key set derived from its two owners (baseScopedEnv() and CLAUDE_CLI_QUIET_ENV) plus USER. #7837 failed that test on its own CI; the expected set now names CLAUDE_CODE_ENTRYPOINT as the one deliberate addition. CLAUDE_CODE_ENTRYPOINT is also an agent-driven signal in src/cli/agent-driven.ts, so an ocx started from inside the Claude CLI child is treated as agent-driven — the conservative direction that consent guard wants.

Closes #7837 when merged (it will be closed by hand with a pointer here).

Verification

  • bun test tests/providers/claude-cli-adapter.test.ts: 71 pass / 0 fail. Without the test update (the cherry-picked fix: 5h window claude sub usage limit #7837 commit alone): 70 pass / 1 fail — "carries the account name the CLI resolves its keychain sign-in by, and nothing else new".

NOT RUN: full suite (host under heavy load; PR CI runs gates + test changed), live claude -p window measurement (taken from #7837's report).

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed (no user-facing setting; behavior described in fix: 5h window claude sub usage limit #7837).
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults (adds a non-secret label to the child env; no credential reaches it).

Co-authored-by: Peter [email protected]

Summary by CodeRabbit

  • Chores
    • Claude CLI processes now receive an opencodex entrypoint identifier in their environment.

@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner November 15, 2026 06:35
@lidge-jun lidge-jun added the bug Something isn't working label Nov 15, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T06:37:19.606062Z 24b2ab7 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@lidge-jun lidge-jun mentioned this pull request Nov 15, 2026
2 of 7 tasks
@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The Claude CLI child environment now sets CLAUDE_CODE_ENTRYPOINT to opencodex. Tests verify the value and include the variable in the expected environment keys.

Changes: Claude CLI environment

Layer / File(s) Summary
Set and verify the entrypoint
src/adapters/claude-cli/adapter.ts, tests/providers/claude-cli-adapter.test.ts
buildChildEnv sets CLAUDE_CODE_ENTRYPOINT to opencodex. Tests check its value and include the variable in the expected environment keys.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Feature · Severity of issue fixed: Medium

Merge Risk: Minimal · up to 24b2a

Claude CLI turns are now labeled with the opencodex entrypoint. The change is small, covered by updated tests, and easy to revert, so merge risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: the Claude CLI child process is now labeled as opencodex by setting CLAUDE_CODE_ENTRYPOINT. The raw summary confirms buildChildEnv sets this variable in src/adapters/c…
Linked Issues check Passed Directly linked issue #7837 has two coding requirements. (1) Set CLAUDE_CODE_ENTRYPOINT=opencodex in the Claude CLI child environment in src/adapters/claude-cli/adapter.ts. The whole-PR diff against m…
Out of Scope Changes check Passed The whole-PR diff contains three hunks. The adapter hunk is the one-line requirement from #7837. The new regression test implements requirement (2) of #7837. The change to the exact child-environment …
Full details: Title check

Explanation

The title names the main change: the Claude CLI child process is now labeled as opencodex by setting CLAUDE_CODE_ENTRYPOINT. The raw summary confirms buildChildEnv sets this variable in src/adapters/claude-cli/adapter.ts, and the test file was updated to match. The title is specific and accurate. The reference to carried #7837 is extra context and does not make the title misleading.

Full details: Linked Issues check

Explanation

Directly linked issue #7837 has two coding requirements. (1) Set CLAUDE_CODE_ENTRYPOINT=opencodex in the Claude CLI child environment in src/adapters/claude-cli/adapter.ts. The whole-PR diff against merge base bd712ac adds CLAUDE_CODE_ENTRYPOINT: "opencodex" to the env object built in buildChildEnv, after the spread of baseScopedEnv() and CLAUDE_CLI_QUIET_ENV. This meets the requirement. (2) Add a regression test. The diff of tests/providers/claude-cli-adapter.test.ts adds the test "labels the turn as opencodex rather than the default sdk-cli entrypoint", which asserts buildChildEnv(CLAUDE_CLI_PROFILE, "").CLAUDE_CODE_ENTRYPOINT is "opencodex". This meets the requirement. The issue's non-coding items (manual measurement, docs checkbox, readiness checklist) are not assessed. The PR description says the issue will be closed by hand and is not a coding requirement.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff contains three hunks. The adapter hunk is the one-line requirement from #7837. The new regression test implements requirement (2) of #7837. The change to the exact child-environment key-set assertion is a supporting test update. It adds CLAUDE_CODE_ENTRYPOINT to the expected key list, which is required because the new env key would otherwise fail that assertion. The comment update in the same test explains the addition. No unrelated files or cleanup appear in the diff. Scope is limited to the linked issue. Note: the PR description states that CLAUDE_CODE_ENTRYPOINT is an agent-driven signal in src/cli/agent-driven.ts. I did not inspect that file. This is a claimed side effect, not a change in this PR, so it does not affect the scope verdict.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between bd712ac and 24b2ab7.

Files selected for processing: 2

  • src/adapters/claude-cli/adapter.ts
  • tests/providers/claude-cli-adapter.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 24b2ab7be1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

const env: Record<string, string> = {
...baseScopedEnv(),
...CLAUDE_CLI_QUIET_ENV,
CLAUDE_CODE_ENTRYPOINT: "opencodex",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Update the owning architecture docs with the entrypoint override

This changes the Claude CLI child-environment contract without updating any owning architecture documentation. src/AGENTS.md requires that “every doc listed for an area is updated in the same change that changes the area,” and structure/INDEX.md maps this adapter to documents including structure/providers-and-adapters.md and structure/providers/claude-cli-replay.md. Document the deliberate CLAUDE_CODE_ENTRYPOINT=opencodex override and its rationale in the applicable owning docs so the maintained adapter contract includes this behavior rather than leaving it only in the commit message and test.

AGENTS.md reference: src/AGENTS.md:L11-L11

Useful? React with 👍 / 👎.

@lidge-jun

Copy link
Copy Markdown
Owner Author

Maintainer integration (merge manager; carries #7837, which the owner accepted as-is in the 2026-11-15 backlog review).

@lidge-jun
lidge-jun merged commit 1d10758 into dev Nov 15, 2026
35 of 37 checks passed
@lidge-jun
lidge-jun deleted the carry/7837-claude-entrypoint branch November 15, 2026 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants