Skip to content

fix(cli): let Claude Code renew a --pkce login's key through lite's apiKeyHelper - #51319

Merged
mateo-berri merged 18 commits into
BerriAI:mainfrom
norkelbyte:litellm_cli_login_renew_keys
Nov 14, 2026
Merged

mateo-berri merged 18 commits into
BerriAI:mainfrom
norkelbyte:litellm_cli_login_renew_keys

Conversation

@norkelbyte

@norkelbyte norkelbyte commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Handwritten 1-3 sentence description

Developers who sign in with lite login --pkce --config-claude had to approve the SSO sign-in again every day, since the login copied its key into Claude Code's settings and Claude Code kept sending it after it expired. That login already stores a refresh token, so now it points Claude Code's apiKeyHelper at lite auth print-token, which renews the key. lite claude then leaves out its own key copy, so an open session renews too

Details

TLDR

Problem this solves:

  • lite login --pkce --config-claude wrote a key that expires in 24h by default
  • claude and open lite claude sessions then got 401 Expired Key until the next sign-in

How it solves it:

  • That login points apiKeyHelper at lite auth print-token, which renews the key, and blanks ANTHROPIC_AUTH_TOKEN so a shell export cannot win
  • lite claude drops its key copy while that helper runs, and sends any other key and its proxy in a private settings file
  • Re-login keeps --pkce for the same proxy
  • A plain login, or no lite found, writes the key as before

User Flow

Before: a developer who signs in through SSO with lite signs in again every day

  1. They run lite login --pkce --config-claude and approve the Okta sign-in
  2. They start claude, and each POST https://litellm-domain/v1/messages answers 200
  3. A day later the next message fails with API Error: 401 Authentication Error - Expired Key, and so does a restarted claude
  4. They sign in through Okta again

After: the same developer signs in once and Claude Code keeps working

  1. The same login now says Claude Code gets the key from lite auth print-token, which renews it
  2. They start claude as before
  3. A day later the open session still answers, and so does a restarted claude
  4. They sign in again only after 14 days without using lite
Decisions and alternatives
  • Bring the helper back only for --pkce logins
  • Raise LITELLM_CLI_JWT_EXPIRATION_HOURS instead
    • Fewer sign-ins but longer-lived keys, and the daily re-login only moves out
  • Have lite claude pass a settings overlay with the helper instead of changing the login
    • Plain claude, the customer's own launch, would still get the static key
  • Name the lite installed beside the Python that ran the login, by absolute path, before one found on PATH
    • Claude Code runs the helper through sh, whose PATH may lack a venv or pipx bin dir
    • A pyenv shim found first on PATH exits 127 in a project pinned to a Python without lite
    • A relative PATH entry would run whatever bin/lite Claude Code's working directory holds
    • Each directory is checked by full path, since Python on Windows searches the working directory first, where a repo could plant lite.exe
    • Moving or removing that lite breaks the helper until the next --config-claude login
  • Fall back to the static key when no lite is found or the store refused the login
    • The helper would have no lite to run or no stored refresh token to renew with
  • Write env.ANTHROPIC_AUTH_TOKEN as an empty string next to the helper
    • A token exported in the shell wins over apiKeyHelper, and the static key in settings used to hide it
    • A shell ANTHROPIC_API_KEY loses to the helper in QA, so the login leaves that one alone
  • lite claude drops its env key only when the helper Claude Code will run is lite's for this proxy and the key came from the stored login
    • Claude Code's settings precedence decides, with a --settings flag counted first
    • A user's own helper keeps today's env key
    • Any lite install's helper for this proxy counts, since every lite reads the same token store
  • Any other key goes in a private --settings file that blanks the helper and sets env.ANTHROPIC_AUTH_TOKEN and env.ANTHROPIC_BASE_URL, when the settings files hold lite's helper or end on the login's empty ANTHROPIC_AUTH_TOKEN
    • That covers --api-key, LITELLM_PROXY_API_KEY, lite's helper for another proxy, a --settings that blanks the helper, and a repo whose project settings set their own helper
    • The login's empty entry hides an exported key, so without the file Claude Code sends the stored login's key or nothing
    • Claude Code keeps only the last --settings, so the file merges the user's own and their keys win
    • The base URL sends a key for another proxy to that proxy, never to the one the login wrote
    • The file is named after the SHA-256 of its contents, cut to 16 hex characters, so two launches share one only when they carry the same settings
    • One shared file let launches started together read each other's key and proxy
    • lite logout and lite unconfigure claude delete the files, since lite hands its process to Claude Code and cannot at exit. Claude Code reads one only at startup, so open sessions keep working
    • Every overlay, --subscription's too, is written to a temp file and renamed into place, so a Claude Code starting at the same time never reads half of one
  • Every print-token hint to sign in again names login --pkce and the proxy
    • It runs as Claude Code's helper, and only a --pkce login renews
    • A proxy without PKCE answers that it does not support lite login --pkce
  • Reuse --pkce on a re-login only when the stored login is for the same proxy
    • Another proxy may offer only plain SSO, so the lite config PKCE default decides there
  • One stored login for every proxy, so after a login to another proxy the helper fails until lite --base-url <first proxy> login --pkce runs again
    • Per-proxy records would change the token store every lite command reads, out of scope here
  • lite claude --subscription blanks any apiKeyHelper, the user's own included
    • It already blanks a user's own ANTHROPIC_AUTH_TOKEN, and either one outranks the claude.ai login
  • lite up and lite configure claude keep writing a static key
    • configure claude takes a long-lived virtual key, which needs no renewal
    • lite up signs in again when the stored key is old, for a session lite down undoes, and is unchanged here
  • The status line keeps reading env only

Affected release

Regression in v1.102.0, where #40330 replaced the helper v1.101.x wrote with the login's static key. A plain lite login --config-claude never renewed

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. uv run pytest tests/unit/<your_test_file>.py -v. Leave the suites (make test-unit-*, make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • Every automated review on my PR's latest commit has finished, and I have addressed or replied to each of its findings before requesting a maintainer review

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

Screenshots / Proof of Fix

Every leg drives Claude Code v2.1.305 in tmux from a fresh HOME against one 2-worker merge-base proxy with real Anthropic, OIDC SSO, and 1h keys, behind a lite shim that exits 127 under a .python-version

Proxy setup

LITELLM_CLI_JWT_EXPIRATION_HOURS=1, plus GENERIC_CLIENT_ID, GENERIC_CLIENT_SECRET, GENERIC_AUTHORIZATION_ENDPOINT, GENERIC_TOKEN_ENDPOINT, GENERIC_USERINFO_ENDPOINT, GENERIC_SCOPE, and PROXY_BASE_URL for SSO, and ANTHROPIC_API_KEY, LITELLM_MASTER_KEY, DATABASE_URL

model_list:
  - model_name: "claude-*"
    litellm_params:
      model: "anthropic/claude-*"
      api_key: os.environ/ANTHROPIC_API_KEY
general_settings:
  master_key: os.environ/LITELLM_MASTER_KEY
  database_url: os.environ/DATABASE_URL

python litellm/proxy/proxy_cli.py --config config.yaml --port 28492 --num_workers 2

A plain lite login on 2 workers fails on base and head alike with CLI login session not found or expired ... configure a Redis cache, so the plain login and base re-login legs ran after a restart that added coordination_redis pointing at a local Redis to general_settings

Every login is lite --base-url http://127.0.0.1:28492 login --pkce --config-claude, approved in the browser, and every prompt is Reply with exactly the word <WORD> and nothing else. in claude --model claude-haiku-5-5

Case Before (7461a99) After (33c2fa7)
Open claude past expiry 401 Expired Key answers
Restarted claude in a repo pinned to another Python 401 Expired Key answers
Open lite claude past expiry 401 Expired Key answers
OS keyring login past expiry 401 Expired Key answers
OS keyring locked answers fails, says to unlock
Stale ANTHROPIC_AUTH_TOKEN in the shell answers answers
lite --api-key <restricted> claude stored login's key billed restricted key billed
lite --base-url <B> --api-key <B key> claude goes to the login's proxy goes to B
Repo with its own apiKeyHelper answers answers
lite claude from another lite install static key apiKeyHelper
lite claude after the refresh token is revoked plain login --pkce login
lite auth print-token with no login Run 'lite login' names --pkce and the proxy
Plain lite login --config-claude static key static key, --pkce hint
lite run by path, not on PATH static key apiKeyHelper
Launch settings file legs ran at 33c2fa7, the rest at 7ec2160

c61a417 adds the proxy URL to the settings file lite claude writes for a key lite's helper would not renew. 33c2fa7 also writes that file under a project helper, names it after its contents, and renames it into place. No other leg writes it, and the --subscription file keeps its name and contents, written the same rename way. d48e951 only changes how the login finds lite, checking each directory by full path, so it keeps the proof on Linux, where a planted ./lite with an empty PATH entry now loses to the venv's. The 1291 CLI tests pass at d48e951 and at fcc6ed0, which only merges main. At 6283ea3 the real lite with Claude Code 2.1.305 writes both launch settings files, lite logout and lite unconfigure claude each delete them, and the 1294 CLI tests pass

Before (7461a99)

  1. At 09:14 UTC the login writes ANTHROPIC_AUTH_TOKEN into Claude Code's settings, /status shows it, and PINEAPPLE answers in claude
  2. At 10:21, past the key's 10:13 expiry, CHERRY in the same session gets 401 Authentication Error - Expired Key
  3. /exit, then claude again in other-repo, and MELON gets the same 401 at 10:23

claude-before-status
claude-before-a
claude-before-b

After (7ec2160)

  1. At 09:14 UTC the same login writes "apiKeyHelper": "<venv>/bin/lite --base-url http://127.0.0.1:28492 auth print-token" and an empty ANTHROPIC_AUTH_TOKEN, /status shows Auth token: apiKeyHelper, and PINEAPPLE answers
  2. At 10:19, past the key's 10:13 expiry, CHERRY in the same session answers ● CHERRY
  3. /exit, then claude again in other-repo, and MELON answers ● MELON. Neither the shim nor other-repo/bin/lite ran

claude-after-status
claude-after-a
claude-after-b

Other cases

Open lite claude past expiry

Same login per leg, then lite --base-url http://127.0.0.1:28492 claude --model claude-haiku-5-5 left open past expiry and sent the CHERRY prompt

  • Before: 401 Authentication Error - Expired Key at 10:21, past the key's 10:13 expiry
  • After: ● CHERRY at 10:19, past the key's 10:13 expiry

lite-before-a
lite-after-a

Login kept in the OS keyring

A gnome-keyring Secret Service on the leg's D-Bus, so keyring picks SecretService and token.json keeps no key, JWT, or refresh token on either side

  • Before: /status shows Auth token: ANTHROPIC_AUTH_TOKEN, PINEAPPLE answers at 08:51, and at 09:58, past the key's 09:51 expiry, CHERRY gets 401 Authentication Error - Expired Key
  • After: three lite auth print-token runs take 2.93, 2.69, and 2.74 s, /status shows Auth token: apiKeyHelper, PINEAPPLE answers at 08:51, and CHERRY answers at 09:57, past the key's 09:51 expiry, with the renewed key in the keyring until 10:56

kr-before-a
kr-after-a

OS keyring locked after the login

Each leg gets its own keyring, locked right after the login, then lite auth print-token and claude with the LEMON prompt

  • Before: print-token exits 1 with Unlock it, or run 'lite login' to start over., and claude answers ● LEMON on the static key from settings
  • After: print-token exits 1 with Unlock it, or run 'lite --base-url http://127.0.0.1:28492 login --pkce' to start over., claude shows Your apiKeyHelper script is failing, and /status shows the same message

lock-before-a
lock-after-a
lock-after-b

claude with a stale token exported in the shell

After the login, ANTHROPIC_AUTH_TOKEN=sk-stale... (a key the proxy does not know) in the environment, then claude --model claude-haiku-5-5 and the KIWI prompt

  • Before: /status shows Auth token: ANTHROPIC_AUTH_TOKEN from settings, and ● KIWI
  • This PR at 6bda378, replayed by removing the empty ANTHROPIC_AUTH_TOKEN from the after login's settings, since that commit wrote the helper alone: /status shows Auth token: ANTHROPIC_AUTH_TOKEN, then ● Please run /login · API Error: 401 Authentication Error, Invalid API key provided.
  • After: /status shows Auth token: apiKeyHelper, and ● KIWI. A stale ANTHROPIC_API_KEY in the shell answers ● LIME too

shell-before
shell-6bda378c64
shell-after
shell-api-key-after

lite --api-key <restricted> claude

After the login, a new key limited to claude-haiku-5-5 from /key/generate, then lite --base-url http://127.0.0.1:28492 --api-key <that key> claude --model claude-haiku-5-5, the PLUM prompt, and curl "http://127.0.0.1:28492/key/info?key=<that key>"

  • Before: ● PLUM, no warning, restricted key spend 0.0, last_active None, so the stored login's key from settings was billed
  • After, at c61a417: ● PLUM, no warning, /status shows this proxy's URL, restricted key spend 0.00110953, last_active 2026-11-12T10:52:33

flags-before-a
flags-after-status
flags-after-a

lite claude --settings '{"apiKeyHelper":""}'

  • Before: ● FIG
  • After, at c61a417: ● FIG, so a --settings that blanks lite's helper still gets the stored login's key through the merged settings file

flags-before-b
flags-after-b

lite --base-url <proxy B> --api-key <B key> claude after a login to proxy A

Proxy B runs on port 28517 with its own master key, which proxy A answers with 401. After the login to A, lite --base-url http://127.0.0.1:28517 --api-key <B key> claude --model claude-haiku-5-5, the BANANA prompt, and a count of POST /v1/messages in each proxy's log

  • Before: /status shows proxy A's URL, and ● BANANA on A's static key, with 2 requests at A and none at B
  • 7ec2160: /status shows proxy A's URL, and A answers the B key with 401, with 8 requests at A and none at B
  • After, at c61a417: /status shows Anthropic base URL: http://127.0.0.1:28517, and ● BANANA, with no request at A and 2 at B

xproxy-before-a
xproxy-7ec2160f34-status
xproxy-7ec2160f34
xproxy-after-status
xproxy-after-a

lite claude in a repo whose project settings set apiKeyHelper

After the login to A, the repo's .claude/settings.json sets apiKeyHelper to a script that prints a key proxy A does not know, then lite claude --model claude-haiku-5-5, /status, and the MANGO prompt

  • Before: /status shows Auth token: ANTHROPIC_AUTH_TOKEN, and ● MANGO answers on the login's static key
  • c61a417: /status shows Auth token: apiKeyHelper, the project helper ran 5 times, and proxy A answered 401 Invalid API key 8 times
  • After, at 33c2fa7: /status shows Auth token: ANTHROPIC_AUTH_TOKEN, ● MANGO answers, and the project helper never ran

projhelper-c61a4179f5
projhelper-after-status
projhelper-after

Two lite --api-key launches started together

After the login to A, two terminals start lite --base-url <proxy B> --api-key <B key> claude and lite --base-url <proxy A> --api-key <A key> claude at the same moment, then /status in each, KIWI in the B session, and LEMON in the A session

  • Before: the login wrote proxy A's URL into the settings, so both /status show A's URL and KIWI goes to A, as in the proxy B case
  • c61a417: both launches write the one litellm-subscription-overlay.json, both /status show proxy A's URL, and the B session's KIWI goes to A on A's key, with no request at B
  • After, at 33c2fa7: two litellm-launch-key-overlay-<hash>.json files, the B session's /status shows B's URL, KIWI goes to B, and LEMON goes to A

twosim-c61a4179f5-b-status
twosim-c61a4179f5-b
twosim-after-b-status
twosim-after-b

lite claude from another lite install

After the head's login, a copy of the same lite entry point at another path runs <leg>/other-install/bin/lite --base-url http://127.0.0.1:28492 claude --model claude-haiku-5-5

  • After: /status shows Auth token: apiKeyHelper with Setting sources: User settings, so no key copy went on the command line, and ● GRAPE

otherlite-after

lite claude after the refresh token is revoked

After the login, the stored key is marked expired and its refresh token swapped for a revoked one, then lite --base-url http://127.0.0.1:28492 claude --model claude-haiku-5-5

  • Before: the same warning, then Opening browser to: http://127.0.0.1:28492/sso/key/generate?..., a plain login that writes a static key
  • After: the same warning, then Opening browser to: http://127.0.0.1:28492/authorize?..., the KIWI prompt answers, and the new login renews

relogin-before
relogin-after

lite auth print-token with no login

After the re-login, a proxy it did not sign in to, then lite --base-url http://127.0.0.1:28492 logout and the same proxy

$ lite --base-url http://127.0.0.1:28493 auth print-token
before: Not authenticated for this server. Run 'lite login'.
after:  Not authenticated for this server. Run 'lite --base-url http://127.0.0.1:28493 login --pkce'.

$ lite --base-url http://127.0.0.1:28492 auth print-token
before: Not authenticated. Run 'lite login'.
after:  Not authenticated. Run 'lite --base-url http://127.0.0.1:28492 login --pkce'.

lite claude --subscription

Base and head after their logins: /status shows Auth token: none, and the prompt gets Not logged in · Please run /login, since the rig has no claude.ai login

Plain lite login --config-claude

On the Redis-backed proxy, both write ANTHROPIC_AUTH_TOKEN, /status shows it, and lite claude answers ● MANGO. The head adds one line

This login's key is stored in the file, so run `lite login --config-claude` again after it expires.
`lite login --pkce --config-claude` instead lets Claude Code renew the key on its own.

lite run by path, not on PATH

PATH=/usr/bin:/bin <venv>/bin/lite --base-url http://127.0.0.1:28492 login --pkce --config-claude

  • Before: static key, This login's key is stored in the file, so run ... again after it expires.
  • After: "apiKeyHelper": "<venv>/bin/lite --base-url http://127.0.0.1:28492 auth print-token", since that lite sits beside the Python that ran the login

Regression checkpoints

Checkpoint lite Writes Past expiry
Before regression v1.101.6 apiKeyHelper answers
After regression (#40330) v1.102.0 static key 401 Expired Key
Before fix 7461a99 static key 401 Expired Key
After fix 7ec2160 apiKeyHelper answers

pip install 'litellm[cli]==1.101.6' and ==1.102.0 in fresh venvs, then the same login, claude, and prompts, run at 3a4e417 on 2026-10-30 on one worker

  • v1.101.6 writes "apiKeyHelper": "<venv>/bin/lite --base-url http://127.0.0.1:31138 auth print-token", /status shows apiKeyHelper, and it answers ● CHERRY past expiry and ● MELON after a restart
  • v1.102.0 writes the key, /status shows ANTHROPIC_AUTH_TOKEN, and it gets 401 ... Expired Key past expiry and after a restart
/live-pr-risk at 33c2fa7

No dependent path breaks. Every case above ran on the merge base and the head with the same 2-worker proxy, client, and steps

Breaking

None observed

Backward incompatible

  • lite claude --subscription now blanks a user's own apiKeyHelper, recorded under Decisions
  • The status line shows no router savings bars after a --pkce --config-claude login, recorded under Caveats
  • A locked OS keychain now fails requests through the helper where the static key kept working, recorded under Caveats
  • merge_claude_settings and configure_claude_settings take a wider credential type, and every caller still passes a static key
  • A --pkce --config-claude login now also writes an empty env.ANTHROPIC_AUTH_TOKEN, which lite unconfigure claude removes with the helper
  • After that login, lite --base-url <other proxy> claude goes to that proxy, where the base sent it to the login's proxy

Regression risk

  • Windows cmd quoting and lite.exe lookup are unit-tested only
  • A real claude.ai login under --subscription was not driven, since the rig has none. Its /status matched on base and head
  • A macOS Keychain was not driven, since the rig has no Mac. A Linux Secret Service keyring was, unlocked and locked

Dependency graph

Dependent State
lite claude (anthropic profile) verified live
lite claude from another lite install verified live
Plain claude with a shell token verified live
lite claude re-login for another proxy tested
lite --api-key ... claude verified live
lite --base-url <other proxy> claude verified live
lite claude under a project apiKeyHelper verified live
Parallel lite --api-key ... claude launches verified live
lite claude --settings ... verified live
lite claude re-login verified live
lite up re-login, --pkce kept only for the same proxy tested
lite codex, lite opencode, lite pi tested, no anthropic env
lite up settings merge tested
lite autoroute settings merge tested
lite configure claude tested
lite unconfigure claude verified live
lite claude --subscription verified live
lite auth print-token, keyring unlocked and locked verified live

Not verified

  • Windows hosts, since none is available
  • A claude.ai subscription login, since the rig has no account
  • A macOS Keychain, since the rig has no Mac

Merge base 7461a99, and the CLI tests pass, 1289 tests

Type

🐛 Bug Fix

Caveats (if any)

Medium

  • Claude Code follows the one login the store holds
    • After a login to another proxy, or lite logout, the helper fails within 5 minutes, where the static key worked until it expired. lite --base-url <first proxy> login --pkce restores it
    • A plain lite login as another user moves open sessions' spend to that user
  • The status line, hooks, and Bash-tool scripts get no key after a --pkce --config-claude login, so the router savings bars are gone
  • Each helper run is a full lite start of 3 to 7 s, at startup and every 5 minutes
  • A locked keychain fails every request where the static key kept working, and says to unlock it or sign in again
  • An --api-key or LITELLM_PROXY_API_KEY key stays in a 0600 file under ~/.claude until lite logout or lite unconfigure claude
  • No macOS Keychain or Windows host was driven, so Windows is unit-tested only

Low

  • Parallel sessions past expiry can race on one renewal, tracked in LIT-10141
  • --api-key still loses to a plain --config-claude login's static key, as on main
  • lite claude ignores a managed-settings apiKeyHelper when it picks the key to send

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR
  • 33c2fa7 passes /live-pr-risk

Note

Medium Risk
Touches credential handling for Claude Code, spend-reset idempotency, and Bedrock request/response mapping; incorrect behavior could affect billing, logging, or provider routing.

Overview
lite login --pkce --config-claude now wires Claude Code through an apiKeyHelper that runs lite auth print-token (with an empty ANTHROPIC_AUTH_TOKEN so shell exports don’t override it), while plain logins still write a static token. lite claude skips injecting ANTHROPIC_AUTH_TOKEN when the configured helper is LiteLLM’s for that proxy and the key came from the stored login; otherwise it may attach a content-addressed --settings overlay with the resolved key and base URL, and lite logout / unconfigure remove those launch overlay files.

Bedrock gains fuller service_tier handling: Converse/Invoke mapping (including reserved and aliases), batch-record validation/drop behavior, Nova invoke headers, and propagating served tier from X-Amzn-Bedrock-Service-Tier on responses and streams. Standard logging tweaks include case-insensitive requested tiers, reserved in known tiers, and prepending top-level system (string or blocks) via ChatCompletionSystemMessage.

The budget reset job is made idempotent across retries with spend_reset_window on end users/customer rows, budget_reset_count on budgets, and window-stamped spend resets keyed off tiers still due on the writer. Auth failures copy spend_logs_metadata from request headers into both metadata buckets for spend logs. MCP connect lets unscoped flows post selected server ids at /authorize/complete, narrows grants, and the dashboard Finish control posts enabled server ids (disabled when none are on).

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

@veria-ai

veria-ai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

PR overview

All previously flagged issues have been addressed. No open security concerns remain on this pull request.

Fixed/addressed: 5 · PR risk: 0/10

Reviews

…sist its absolute path

An explicit --api-key or LITELLM_PROXY_API_KEY is now exported to Claude Code
even when lite's renewing helper is configured, since the helper prints the
stored login's key instead. The helper command also uses the absolute path of
the lite found on PATH, so a relative PATH entry cannot make Claude Code run
another repository's bin/lite
@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@greptile-apps

greptile-apps Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[High impact] The changes appear safe to merge, with no new actionable issue found.

Summary

PKCE logins let Claude Code renew keys through apiKeyHelper. The latest changes delete saved launch-key files during lite logout and lite unconfigure claude.

  • Claude Code can renew keys from PKCE logins.
  • MCP connect flows can grant a chosen set of servers.
  • Budget reset retries skip rows already reset for that window.
  • Bedrock routes map supported service tiers and reject unsupported ones.
  • Logged messages now include system prompts written as content blocks.
  • Auth-failure callbacks receive spend-log metadata from request headers.
  • The semantic MCP filter can use a supplied tool loader.

Reviews (8) · Last reviewed commit: "fix(cli): delete the key files lite clau..." · Reviewed by Greptile

… is set

A --settings that blanks apiKeyHelper now keeps the exported key, and a key passed with --api-key turns lite's helper off for that launch, so Claude Code no longer warns about two credentials or sends the stored login's key beside it

The helper names the lite installed beside the Python that ran the login before one found on PATH, so a pyenv shim no longer fails in projects pinned to another Python

lite claude signs in again with --pkce when the stored login used it, and print-token's hints name the proxy and --pkce
@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

…se --pkce only for the same proxy

The --pkce --config-claude login now writes an empty env.ANTHROPIC_AUTH_TOKEN beside the helper, since a token exported in the shell wins over apiKeyHelper

lite claude sends any other key through a private settings file that blanks the helper and merges the user's own --settings

A re-login keeps --pkce only when the stored login is for the same proxy, else the saved default decides
…the renewing login in print-token hints

lite claude now treats a lite auth print-token helper for this proxy as renewing whichever lite path it names, since every lite reads the same token store

Every print-token hint to sign in again, including an expired key and an unreadable keychain, names lite login --pkce with the proxy

Shorter docstrings
The private settings file lite claude writes for a key that lite's helper would not renew now also sets ANTHROPIC_BASE_URL. Without it, lite --base-url B --api-key <B key> claude after a --pkce --config-claude login to A sent the B key to A, since the login's settings point Claude Code at A
@norkelbyte norkelbyte closed this Nov 13, 2026
@norkelbyte

Copy link
Copy Markdown
Contributor Author

Closed to free an open-PR slot. Branch kept, and it reopens for final CI and bot reviews once ready

@norkelbyte norkelbyte reopened this Nov 14, 2026
@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

* fix(proxy): keep x-litellm-spend-logs-metadata on auth-rejected failure spend logs

Budget, invalid-key and other auth-stage rejections are raised before the
request headers are merged into metadata, so the persisted failure row lost
the caller's spend logs metadata header. The auth failure handler now parses
it with the same pre-call helper and stamps it into the metadata bucket it
already uses for the requester IP and user agent.

* fix(proxy): type the spend logs metadata header parser honestly

The parser takes the request headers as a str mapping and returns the parsed
JSON as object, which is what successful requests already store. The auth
failure path keeps only JSON objects. The precedence regression now also
asserts the caller's request body is left untouched.

* fix(proxy): stamp the auth failure spend logs metadata into the route's bucket

A chat request whose body also carried litellm_metadata got the header in
litellm_metadata, which the failure spend row never reads on chat routes.
The header now goes into the bucket picked by metadata_variable_name_for_request
for the route, and the failure row lifts spend_logs_metadata from that bucket
the same way it already lifts the requester IP and user agent. The regression
tests now assert on the built failure spend row.

* fix(proxy): keep the auth failure spend logs metadata fix inside the auth handler

Restores the failure spend row's lifted fields to main, so failures after auth
on litellm_metadata routes keep their current logging. The auth handler now
writes the parsed header into metadata, which the failure spend row reads on
every route, and into the route's own bucket for callbacks on litellm_metadata
routes.

* fix(proxy): make the spend logs metadata header field read-only and test the real spend writer

The header collector now sets spend_logs_metadata when it is built, so the
field can be ReadOnly with the same stored value. The auth failure tests run
the real DBSpendUpdateWriter and read the queued spend log row from a fake
database client instead of an autospec writer.

* test(proxy): read auth failure spend rows from a real unconnected PrismaClient

Replaces the mocked database client and the class-level queue byte reset.
The test now enqueues into a real PrismaClient's own queue and dequeues
its row in cleanup, which keeps the shared byte counter balanced.

---------

Co-authored-by: Joshua Valluru <326636767+joshua-berri@users.noreply.github.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

ryan-crabbe-berri and others added 3 commits November 13, 2026 16:23
…erriAI#51699)

* fix(logging): keep a content-block system prompt in logged messages

A /v1/messages request whose top-level system prompt is a list of content
blocks never reached the logged messages, because only a plain-text system
prompt was prepended. Accept a non-empty list too, so every logger that reads
messages sees it. Claude on Vertex also normalizes a plain-text system prompt
into blocks, so it was dropped there as well.

Fixes BerriAI#36402

* fix(logging): type the logged system message

* fix(logging): type the system message without a mutable annotation, close the test client
…parameter (BerriAI#50483)

* test(mcp): check the tool dict conversion without patching the MCP handler

* refactor(mcp): let the semantic filter take its MCP tool loader as a parameter

* refactor(mcp): type the semantic filter's default tool loader

Annotate the chosen loader as _OpenAIToolLoader and narrow its return to
FunctionToolParam, so a default that returns raw MCP tools fails the type
check. Drop the unused patch import.
@codspeed

codspeed Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

1 warning

⚠️ 2 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 44 untouched benchmarks


Comparing norkelbyte:litellm_cli_login_renew_keys (6283ea3) with main (01de1a6)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (752eb7c) during the generation of this report, so 01de1a6 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

…ach key its own settings file

A `lite login --pkce --config-claude` leaves an empty ANTHROPIC_AUTH_TOKEN in Claude Code's user settings. When a repo's project settings set their own apiKeyHelper, `lite claude` skipped its private settings file, so the empty token hid the exported key and Claude Code sent the project helper's key. `lite claude` now also writes that file whenever the settings files leave ANTHROPIC_AUTH_TOKEN empty

Every key launch also wrote the one file `--subscription` uses, so two launches started together could read each other's key and proxy. A key launch's file is now named after a hash of its contents, and every overlay is written to a temp file and renamed so a starting Claude Code never reads half of one
@codecov

codecov Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.15385% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
litellm/accounting/projection.py 88.46% 3 Missing ⚠️
litellm/caching/affinity_cache.py 93.33% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

PyExtreme and others added 3 commits November 14, 2026 01:03
BerriAI#51143)

* fix(proxy): keep carried end-user spend when a budget reset is retried

End-user pages commit before the budget window advance. When the advance
failed, the tier stayed due and the next tick replayed every page, so a
rollover-capped row already cut to its carryover (15 -> 5) matched the
under-cap zero and lost it, and spend accrued since the first pass was
zeroed again. Each end-user reset now stamps the tier window it closes
in a new spend_reset_window column and skips rows already stamped with it.

Fixes BerriAI#50898

* fix(proxy): leave never-reset tiers unguarded and test each tier's own window

A tier with no budget_reset_at falls back to the old unguarded reset
instead of stamping created_at, which an admin clearing the reset time
would reuse and silently skip end users. Tests now give tiers distinct
windows and cover a second window closing.

* test(proxy): give the end-user ledger its own fake prisma client

* fix(proxy): pin a reset time on tiers without one before end-user pages commit

* fix(proxy): read the reset-time pin from the writer and skip tiers another sweep advanced

* fix(proxy): keep linked rows of a tier another sweep advanced out of the rollover reset

* fix(proxy): order the end-user reset window migration after upstream's same-timestamp migration

* fix(proxy): reset end users again when an admin moves a tier's reset time back to a closed window

* fix(proxy): clear end-user reset stamps in the same transaction as the tier's reset time

A failed /budget/update used to leave the new reset time written with the
stamps still set, so repeating the request found the time unchanged and
skipped the clear. The update and the clear now commit together, and a
reset time in the future no longer scans the tier's end users

* fix(proxy): name each end-user reset window by the tier's last write

Stamp end-user resets with the tier's updated_at read on the writer instead
of its reset time. A failed window advance leaves updated_at as it was, so the
retry still skips the end users already reset, while the advance or any
/budget/update moves it and opens a new window. That covers a forced reset on
the default end-user tier and drops the stamp clear, so /budget/update is the
one-row update it is on main. The writer read also leaves out a tier another
sweep already advanced, which a lagging read replica still showed as due

* fix(proxy): name end-user reset windows by the tier and its advance count

Tiers advanced in one batch share updated_at, so a customer moved between
them could skip the new tier's reset, and any unrelated tier edit during a
failed advance reopened the window. A budget_reset_count that only the
window advance bumps, prefixed with the tier id, names the window instead.

* fix(proxy): keep carried spend for customer teams and members on a retried reset

Customer team and member pages commit before the window advance like end-user
pages, so they now stamp the window they close and a retry skips them too. A
member runs on its unexpired override when that has its own duration, else on
its template.

The window name now joins the tier id, its creation time, its count of closed
windows and its reset time, so a duration change or a tier recreated under the
same id opens a new window even when the advance failed.

* test(integration): list every budget column and relation in the budget update field check

---------

Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
…luded services matrix (BerriAI#51759)

Co-authored-by: mateo <277851410+mateo-berri@users.noreply.github.com>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
… its helper

On Windows, shutil.which searches the current directory before the directories it is given, so a lite.exe planted in the repo where someone ran `lite login --pkce --config-claude` could become their user-level apiKeyHelper

The login now checks each directory by full path, this Python's scripts directory first and then each PATH entry, skipping empty entries
@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

quietjules and others added 2 commits November 14, 2026 01:33
…ard reserved (BerriAI#50516)

* fix(bedrock): answer 400 for service tiers Bedrock cannot serve, forward reserved

Converse used to drop any service_tier outside default, flex, and priority
with no error, rewrite auto to default, and drop reserved. Now reserved and
standard_only map to Bedrock tiers, auto sends no tier, and any other value
answers 400 unless drop_params is on. Nova batch rows honor the row's
drop_params.

* fix(bedrock): keep a Responses batch row's drop_params and keep it out of passthrough rows

* test(bedrock): annotate service tier test locals as Final and drop the row helper's kwargs

* fix(bedrock): refuse a service tier on Nova batch rows unless drop_params, and honor the deployment's drop_params

* fix(bedrock): map standard and any-case service tiers, and drop tiers from Claude batch rows under the deployment's drop_params

* fix(bedrock): forward the tiers OpenAI-format batch rows take, accept auto on Claude rows, and label tiers in lowercase

* fix(bedrock): mark the service tier block field read-only

* fix(bedrock): read drop_params given as a string on batch rows, and cover the Nova row mapper's drop_params

* test(prometheus): sort the service tier label test imports

* fix(bedrock): send the Invoke route's service tier as a header and name the accepted tiers in the 400

* fix(bedrock): report and bill the tier Bedrock served on Invoke calls and streams, and send the tier header only to Nova

* fix(bedrock): return copies when stamping the served tier, read its header without re-encoding the others, and pin it per stream chunk

The Nova Invoke mapper and the event-stream decoder now return model_copy results instead of writing service_tier in place. One shared reader finds the X-Amzn-Bedrock-Service-Tier response header case-insensitively, so a non-ASCII request id no longer breaks the stream decoder, and the passthrough uses the same reader. Tests now vary the served tier in both directions, check every chunk, and cover a stream with no tier header or an empty one

* test(bedrock): check the served tier on a stream whose headers come as a plain dict with an upper-case name

The non-ASCII request id stream test now also carries X-AMZN-BEDROCK-SERVICE-TIER in a plain dict and asserts every chunk reports that tier, so a case-sensitive header reader or a lookup by the canonical name fails it

* refactor(bedrock): drop the passthrough's own service tier header reader that main re-added

The passthrough already reads the served tier through the shared case-insensitive reader in common_utils, so the httpx.Headers copy main brought back with the embeddings change has no callers and references a constant this branch removed

---------

Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
@CLAassistant

CLAassistant commented Nov 14, 2026 •

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
5 out of 7 committers have signed the CLA.

✅ mateo-berri
✅ PyExtreme
✅ shrey-berri
✅ joshua-berri
✅ ryan-crabbe-berri
❌ devin-ai-integration[bot]
❌ quietjules
You have signed the CLA already but the status is still pending? Let us recheck it.

@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

…figure

lite claude hands its process to Claude Code, so the --settings files holding
its key stayed in the Claude config dir. lite logout and lite unconfigure claude
now delete them, and Claude Code reads one only at startup, so open sessions
keep working
@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 6283ea3. Configure here.

@mateo-berri mateo-berri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@mateo-berri
mateo-berri merged commit dc378de into BerriAI:main Nov 14, 2026
150 of 154 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.

8 participants