Skip to content

Read the CLI-written CPK_INTELLIGENCE_API_KEY as the Intelligence key fallback - #802

Open
charan-rathore wants to merge 3 commits into
CopilotKit:mainfrom
charan-rathore:fix/cli-key-fallback-forkbase
Open

charan-rathore wants to merge 3 commits into
CopilotKit:mainfrom
charan-rathore:fix/cli-key-fallback-forkbase

Conversation

@charan-rathore

Copy link
Copy Markdown
Contributor

Closes #800.

The CopilotKit CLI saves the runtime key as CPK_INTELLIGENCE_API_KEY, while the server only read INTELLIGENCE_API_KEY. A deployment that ran the CLI without setup-learning.ts refused to boot with a missing INTELLIGENCE_API_KEY error until the key was copied by hand.

This falls back to CPK_INTELLIGENCE_API_KEY when INTELLIGENCE_API_KEY is unset. The unprefixed variable stays authoritative when both are present, and the existing forwarding (INTELLIGENCE_API_KEY: settings.apiKey) is unchanged.

Tests: two new cases in server/tests/config.test.ts cover the fallback and the precedence. bun test server/tests/config.test.ts scripts/setup-learning.test.ts scripts/start-restart-guard.test.ts passes 177/177, and bunx biome lint --error-on-warnings is clean on both files.

… fallback

The CopilotKit CLI saves the runtime key as CPK_INTELLIGENCE_API_KEY,
while the server only read INTELLIGENCE_API_KEY. A deployment that ran
the CLI without setup-learning.ts refused to boot with a missing
INTELLIGENCE_API_KEY error until the key was copied by hand.

Fall back to CPK_INTELLIGENCE_API_KEY when INTELLIGENCE_API_KEY is
unset, keeping the unprefixed variable authoritative when both are
present.

Closes CopilotKit#800

Signed-off-by: Charan Rathore <180254320+charan-rathore@users.noreply.github.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-17T21:46:03.530943Z 41773cc Manual request
ℹ️ 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.

@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: 841f1d21ce

ℹ️ 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".

Comment thread server/src/config.ts
Comment on lines +955 to +956
optional(environment, "INTELLIGENCE_API_KEY") ??
optional(environment, "CPK_INTELLIGENCE_API_KEY"),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Synchronize the CLI-key setup guidance

When users follow the checked-in setup guidance, .env.example:134 still says that the server cannot see CPK_INTELLIGENCE_API_KEY, while prompt.txt:106-108 still requires copying that value to INTELLIGENCE_API_KEY before startup. This fallback makes both instructions false, so the documented CLI/local-connect workflow continues to require the manual step that this change is intended to remove; update those guidance surfaces alongside the new alias.

Useful? React with 👍 / 👎.

…lback

Signed-off-by: Charan Rathore <180254320+charan-rathore@users.noreply.github.com>
@charan-rathore

Copy link
Copy Markdown
Contributor Author

Good catch on the docs. .env.example and prompt.txt both still taught the manual copy, which the fallback makes unnecessary - updated both in 0341f6e: the CLI-written key now works as written, and INTELLIGENCE_API_KEY stays the way to override it.

@codex 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: 0341f6e0bc

ℹ️ 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".

Comment thread server/src/config.ts
// copies it across, but a deployment that ran only the CLI would otherwise refuse to boot.
apiKey:
optional(environment, "INTELLIGENCE_API_KEY") ??
optional(environment, "CPK_INTELLIGENCE_API_KEY"),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Update the remaining local-connect README guidance

When users follow the README's local Intelligence flow, README.md:140-146 still says OpenBot reads the key only from INTELLIGENCE_API_KEY and requires copying the CLI value before scripts/start.sh. The fallback on this line makes that statement false, so the primary setup page still teaches the manual copy this change removes; update that section along with the other guidance.

Useful? React with 👍 / 👎.

Signed-off-by: Charan Rathore <180254320+charan-rathore@users.noreply.github.com>
@charan-rathore

Copy link
Copy Markdown
Contributor Author

And the README's local-connect section said the same thing - fixed in 41773cc, which was the last remaining spot (swept the repo for other stale mentions).

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 41773cc112

ℹ️ 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".

This branch has not been deployed

No deployments
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.

Wrong key location at startup

1 participant