Skip to content

Use Prime CLI config for v1 eval#1703

Merged
mikasenghaas merged 3 commits into
feat/nano-as-v1from
codex/v1-prime-config
Jun 16, 2026
Merged

Use Prime CLI config for v1 eval#1703
mikasenghaas merged 3 commits into
feat/nano-as-v1from
codex/v1-prime-config

Conversation

@xeophon

@xeophon xeophon commented Jun 16, 2026

Copy link
Copy Markdown
Member

Overview

Make direct v1 uv run eval calls use the active Prime CLI inference settings when the default Prime client is selected.

Details

  • Fall back to ~/.prime/config.json for the API key and inference URL when matching environment variables are absent.
  • Apply the configured Prime team ID as the billing header.
  • Preserve explicit client settings and environment variables as higher-precedence overrides.

Note

Medium Risk
Changes credential resolution and team billing headers for Prime inference; wrong fallbacks could mis-route billing or send requests without a valid key.

Overview
Direct uv run eval with the default Prime client now picks up the same inference URL, API key, and team billing as prime eval, by falling back to ~/.prime/config.json when env vars are missing.

BaseClientConfig replaces add_prime_team_id with apply_prime_config: only when api_key_var is PRIME_API_KEY, it resolves base_url from PRIME_INFERENCE_URL → CLI inference_url → default, and sets X-Prime-Team-ID from PRIME_TEAM_ID or CLI team_id only if the host is Prime inference. Explicit base_url in config still wins.

resolve_client loads the API key from the Prime CLI config when PRIME_API_KEY is unset and the endpoint is Prime-hosted, instead of defaulting straight to "EMPTY".

Reviewed by Cursor Bugbot for commit 4ff7fe1. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Use Prime CLI config as fallback for base URL, team ID, and API key in v1 eval

  • BaseClientConfig.apply_prime_config (in config.py) now sets base_url from PRIME_INFERENCE_URL env var or CLI config when not explicitly provided, and injects the X-Prime-Team-ID header from PRIME_TEAM_ID env var or CLI config for pinference.ai hosts.
  • resolve_client falls back to the Prime CLI config api_key for pinference.ai hosts when the expected env var is unset, reducing cases where 'EMPTY' is used as the key.
  • Behavioral Change: clients targeting pinference.ai that previously required explicit env vars will now silently pick up values from the local Prime CLI config if those vars are absent.

Macroscope summarized 4ff7fe1.

@macroscopeapp

macroscopeapp Bot commented Jun 16, 2026

Copy link
Copy Markdown

Approvability

Verdict: Needs human review

Changes authentication credential resolution logic with potential to send Prime API keys to unintended endpoints. Two unresolved review comments identify security concerns around credential handling that warrant human review.

You can customize Macroscope's approvability policy. Learn more.

@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: 04b33e8247

ℹ️ 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 verifiers/v1/clients/config.py Outdated
Comment on lines +84 to +85
if not api_key and config.api_key_var == "PRIME_API_KEY":
api_key = load_prime_config().get("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 Avoid using Prime CLI keys for explicit endpoints

When a user sets only --client.base-url to a non-Prime endpoint while logged in to Prime, this branch still pulls the Prime API key from ~/.prime/config.json because api_key_var remains the default. That sends a live Prime bearer token to whichever custom URL was explicitly configured; previously these runs used EMPTY unless PRIME_API_KEY was set in the environment. Gate the Prime CLI fallback on the default/Prime base URL, or require an explicit opt-in, so custom endpoints do not receive Prime credentials.

Useful? React with 👍 / 👎.

@cursor cursor 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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e1d8226. Configure here.

Comment thread verifiers/v1/clients/config.py

@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: e1d8226ce4

ℹ️ 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 verifiers/v1/clients/config.py Outdated
Comment on lines +95 to +96
if config.base_url.rstrip("/") == prime_base_url.rstrip("/"):
api_key = prime_config.get("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 Allow CLI credentials on explicit Prime URLs

When a user overrides the endpoint back to the built-in Prime URL while their active PRIME_INFERENCE_URL or CLI inference_url points somewhere else, this exact-match gate prevents the Prime CLI api_key fallback and the client sends EMPTY instead. For example, a logged-in user with PRIME_INFERENCE_URL set to a staging router who runs one eval with --client.base-url https://api.pinference.ai/api/v1 will get auth failures unless they also export PRIME_API_KEY, even though the change is meant to preserve explicit endpoint overrides while still using Prime login credentials.

Useful? React with 👍 / 👎.

@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: 4ff7fe1c3b

ℹ️ 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 on lines +48 to +49
if "base_url" not in self.model_fields_set:
self.base_url = prime_base_url

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 Preserve subclass endpoint defaults

model_fields_set only contains values supplied by the caller, not defaults declared on a BaseClientConfig subclass. With an environment config such as class StagingJudge(BaseClientConfig): base_url = "https://staging.pinference.ai/api/v1" that intentionally keeps api_key_var="PRIME_API_KEY", this branch treats the subclass default as missing and overwrites it with the active Prime/default URL, so the environment silently calls the wrong endpoint unless every caller explicitly passes base_url.

Useful? React with 👍 / 👎.

Comment on lines +93 to +99
host = urlparse(config.base_url).hostname or ""
if (
not api_key
and config.api_key_var == "PRIME_API_KEY"
and (host == PRIME_INFERENCE_HOST or host.endswith(f".{PRIME_INFERENCE_HOST}"))
):
api_key = load_prime_config().get("api_key")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

arfh, i hate this custom logic here. getting auth smell. how come no other provider requires this?

@mikasenghaas mikasenghaas merged commit 68aac71 into feat/nano-as-v1 Jun 16, 2026
5 checks passed
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.

2 participants