Skip to content

feat(cli): add lite configure claude and lite unconfigure claude - #40319

Merged
tin-berri merged 1 commit into
litellm_internal_stagingfrom
litellm_lit7355_claude_configure
Sep 10, 2026
Merged

tin-berri merged 1 commit into
litellm_internal_stagingfrom
litellm_lit7355_claude_configure

Conversation

@tin-berri

@tin-berri tin-berri commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • Pointing Claude Code at a LiteLLM proxy with a virtual key needed hand edits to ~/.claude/settings.json
  • lite login --config-claude only works with an SSO login, and nothing undoes it
  • Claude Code requests its own model ids for sub-agents and background helpers, which 400 on a proxy that does not serve them

How it solves it:

  • lite configure claude --api-key KEY patches settings.json in place, turns on gateway model discovery, and records what it changed
  • Without --api-key it uses your lite login through apiKeyHelper, the same path lite login --config-claude takes
  • lite unconfigure claude restores exactly those keys, leaving anything the user changed since; it undoes --config-claude too
  • The undo receipt is one map keyed by dotted path (env.ANTHROPIC_BASE_URL, apiKeyHelper, model, ...): the value each path held before configure took it over, a fingerprint for each path a merge changed, and for a credential the ANTHROPIC_BASE_URL it was captured beside. Ownership moves only by a write: a repeat configure or re-login refreshes a fingerprint only for a path its merge changed and snapshots afresh a path the user changed in between, so whatever a repeat displaces is what comes back and an edit made between two configures is never adopted as ours
  • A credential goes back only next to the ANTHROPIC_BASE_URL it was captured with; otherwise it stays removed, the output names that server, and the receipt is kept owning only those slots, so pointing the URL back and running unconfigure again finishes the job
  • Settings and receipt land through one boundary: commit the staged document or unlink the path, turn any OSError into a ClaudeSettingsError naming the path, and discard the sibling staged file, so no temp file holding a token is left behind and lite login --config-claude never relabels it "Authentication failed"
  • Every command that writes settings.json starts the same way: the lite up / lite autoroute up ownership check, then the credential, then GET /v1/models, all before any login prompt; unconfigure reports only keys whose value it changed, says when the file itself is gone, and the /v1/models hint matches how the listing failed
  • --model (or the interactive lite configure) only picks the model Claude Code starts on; /model keeps listing the gateway's models
  • One credential-aware merge now serves lite up, --config-claude, lite autoroute up and configure
  • Round 10 rebuilt the receipt on dotted paths (one code path for env and top-level keys, both files through one landing helper) and made the undo tests table-driven, taking the diff from 1973 to 1715 insertions, 799 of them under litellm/

User Flow

Before: a developer with a LiteLLM virtual key cannot make a bare claude use the proxy without editing JSON by hand

  1. They run lite claude configure --api-key sk-..., which forwards configure to the claude binary and fails with error: unknown option '--api-key'
  2. They run lite claude -p "hi" instead, which routes that one invocation, but ~/.claude/settings.json is untouched, so the next plain claude says Not logged in · Please run /login
  3. Even inside the wrapper, Claude Code asks the proxy for claude-opus-5, and a proxy without that model group answers 400 Invalid model name passed in model=claude-opus-5; nothing tells them which models the proxy does serve

After: one command wires Claude Code to the proxy, and one command puts it back

  1. They run lite --base-url https://proxy.example.com configure claude --api-key sk-... (or plain lite configure, which asks which agents to wire and which model to start on); the command checks the key against GET /v1/models and prints what it wrote and how to undo it
  2. They start plain claude from any terminal; /model lists the proxy's Claude-named models next to the built-in rows, and every turn lands on POST /v1/messages with whichever model they picked
  3. They run lite unconfigure claude; settings.json is back to what it held before, and the next plain claude is on their previous setup again

Relevant issues

  • Adds lite configure [claude] and lite unconfigure claude (persistent wiring with a virtual key or the stored login, receipt-based undo, interactive picker)
  • Replaces the two settings merges (lite up/--config-claude and lite autoroute) with one credential-aware merge_claude_settings; lite login --config-claude now writes through the receipt so it is undoable
  • Codex and Claude Desktop/Cowork are follow-ups (Codex needs a TOML writer, which the CLI extra does not ship); the interactive picker gains their rows then

Linear ticket

Resolves LIT-7355

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/test_litellm/<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
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review (Greptile reviews automatically once the PR is opened; only comment @greptileai to re-request a review after pushing changes)

Screenshots / Proof of Fix

Shared setup: a proxy from this worktree on http://127.0.0.1:4735 (no database), master key sk-rig-lit7355, serving claude-haiku-4-5, claude-sonnet-4-6, claude-opus-4-7, gpt-5.6-luna (all upstream to a real gateway, real spend) and claude-auto, a complexity auto-router over the three Claude groups. Every claude run below uses a fresh HOME seeded with {"theme": "dark", "model": "claude-opus-5"} in .claude/settings.json, Claude Code v2.1.265, and the worktree's lite

Before (4b9c289)

configure does not exist

  1. lite --base-url http://127.0.0.1:4735 --api-key sk-rig-lit7355 claude configure --api-key sk-rig-lit7355
  2. Output:
    litellm: routing Claude Code through proxy at http://127.0.0.1:4735
    error: unknown option '--api-key'
    

the launcher routes one run and leaves settings.json alone

  1. lite --base-url http://127.0.0.1:4735 --api-key sk-rig-lit7355 claude -p "Reply with exactly: routed ok"
  2. Output:
    litellm: routing Claude Code through proxy at http://127.0.0.1:4735
    API Error: 400 anthropic_messages: Invalid model name passed in model=claude-opus-5. Call `/v1/models` to view available models for your key.
    
  3. ls -la $HOME/.claude/settings.json
    ls: /tmp/lit7355-before.AH2y/.claude/settings.json: No such file or directory
    

bare claude

  1. claude -p "Reply with exactly: routed ok"
  2. Output: Not logged in · Please run /login

unconfigure (re-run on f1d655f)

Same seed ({"theme": "dark", "env": {"ANTHROPIC_API_KEY": "sk-ant-mine"}}), a fresh HOME, and a stub answering GET /v1/models on http://127.0.0.1:4739 with the rig's six ids

  1. lite --base-url http://127.0.0.1:4739 configure claude --api-key sk-rig-lit7355 prints the same five lines as above and writes the same four env keys
  2. lite unconfigure claude
  3. Output (only keys whose value it changed; apiKeyHelper and model were never written, so they are not named):
    Restored in /tmp/lit7355-proof.Cwr4/.claude/settings.json: env.ENABLE_TOOL_SEARCH, env.CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY, env.ANTHROPIC_BASE_URL, env.ANTHROPIC_AUTH_TOKEN, env.ANTHROPIC_API_KEY.
    
  4. cat $HOME/.claude/settings.json
    {
      "theme": "dark",
      "env": {
        "ANTHROPIC_API_KEY": "sk-ant-mine"
      }
    }
  5. ls $HOME/.litellm/ is empty: the receipt is gone with nothing withheld

Type

🆕 New Feature

Caveats (if any)

Medium

  • Codex and Claude Desktop/Cowork are not covered yet; lite configure codex needs a TOML writer, which the CLI extra does not ship
  • Claude Code keeps requesting its own default and sub-agent model ids unless you pick a proxy model, so those ids need to exist on the proxy; lite autoroute up is the mode that pins every tier to one group
  • Claude Code treats an auto-router group name as an unknown model: it prints unrecognized_model, assumes a 200k window, and sends no thinking params for it. Name the group like a model id, or append [1m], to change that; noted in the README
  • A virtual key is written into settings.json (0600), the same shape lite autoroute up already uses; the command says so when the file is a symlink into a dotfiles repo

Low

  • lite up and lite login --config-claude now also drop a stray env.ANTHROPIC_AUTH_TOKEN, since Claude Code prefers it over apiKeyHelper
  • lite login --config-claude now writes through the configure receipt, so lite unconfigure claude undoes it; it keeps a model pinned by lite configure claude --model, never adopts a key the user edited since the first configure, and refuses before logging in while lite up holds the file
  • PiSyncError now carries a kind decided where the /v1/models response is classified; lite pi's "nothing to run" wording moved to its caller
  • lite autoroute up now also sets the discovery env default and the Fable tier key, since it shares the merge
  • CLAUDE_CONFIG_DIR is not honored, matching lite up and lite login --config-claude
  • The receipt keeps the previous value of a credential it removed (0600 inside the 0700 ~/.litellm, less readable than the 0644 settings.json it came from), the same shape as the lite up and lite autoroute up backups and Ramp Router's state file; it never holds the key configure writes, only its fingerprint. Keychain-backed snapshots for all three files are LIT-7437 (Veria, Low)

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

Note

Medium Risk
Changes persist API keys and proxy URLs in user home config with receipt logic; mistakes could leave Claude Code misrouted, though unconfigure and ownership checks limit blast radius.

Overview
Adds lite configure claude and lite unconfigure claude so Claude Code can stay routed through the LiteLLM proxy without hand-editing ~/.claude/settings.json. Configure accepts a long-lived --api-key (written as env.ANTHROPIC_AUTH_TOKEN) or falls back to lite login via apiKeyHelper, validates the key with GET /v1/models, optionally pins a starting model with --model, and records an undo receipt at ~/.litellm/claude_configure_state.json. Unconfigure restores only keys that still match what configure wrote, leaves user edits alone, and withholds credentials when the base URL no longer matches where they were captured.

lite login --config-claude now uses the same configure path (receipt-based undo) and refuses to run while lite up or lite autoroute up hold a settings backup. merge_claude_settings is unified for lite up, configure, and autoroute (static token vs helper, optional tier overrides); wiring also clears stray ANTHROPIC_AUTH_TOKEN so it cannot beat apiKeyHelper. lite autoroute up sets the top-level model and ANTHROPIC_DEFAULT_FABLE_MODEL to autorouter via that shared merge. PiSyncError gains a ListingFailure kind for clearer configure/pi listing errors.

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

@tin-berri
tin-berri requested a review from a team September 8, 2026 23:22
@tin-berri
tin-berri force-pushed the litellm_lit7355_claude_configure branch from 86a658d to bde3c50 Compare September 8, 2026 23:23
@codspeed

codspeed Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing litellm_lit7355_claude_configure (f1d655f) with litellm_internal_staging (6b721de)

Open in CodSpeed

@greptile-apps

greptile-apps Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds persistent Claude Code proxy configuration and receipt-based undo to the lite CLI.

  • Adds interactive and non-interactive lite configure claude flows supporting virtual keys or stored login credentials.
  • Adds lite unconfigure claude, preserving user edits and restoring prior file and env shapes.
  • Consolidates Claude settings merging across login, lite up, and autoroute flows.
  • Extends model discovery, documentation, and unit coverage for the new behavior.

Confidence Score: 4/5

The PR is not yet safe to merge because the outstanding settings/receipt consistency defect can leave undo state inconsistent after a settings commit failure.

The receipt is committed before the staged settings file, and failure of the second os.replace leaves the new receipt installed even though the corresponding settings were not written. tin-berri claimed this was fixed by staging both files first, but staging does not make the two subsequent commits atomic, so the original finding remains unresolved.

Files Needing Attention: litellm/proxy/client/cli/commands/claude_settings.py

Important Files Changed

Filename Overview
litellm/proxy/client/cli/commands/claude_settings.py Centralizes credential-aware settings merging and receipt-based restoration, but the previously reported partial-commit failure remains possible.
litellm/proxy/client/cli/commands/configure.py Implements interactive and explicit Claude configuration commands, credential resolution, model validation, and user-facing output.
litellm/proxy/client/cli/commands/auth.py Routes login --config-claude through the shared, undoable configuration path.
litellm/proxy/client/cli/commands/autoroute/commands.py Reuses the shared Claude settings merge while pinning the autorouter model and tiers.
litellm/proxy/client/cli/README.md Documents configuration, undo behavior, credential handling, model discovery, and autoroute settings.
tests/test_litellm/proxy/client/cli/test_claude_settings.py Adds restoration-shape and staging-failure coverage, though it does not exercise failure of the second commit.

Reviews (2): Last reviewed commit: "feat(cli): add lite configure claude and..." | Re-trigger Greptile

Comment on lines +159 to +161
merged: Final = merge_claude_settings_static_token(
original_settings, base_url, master_key, AUTOROUTER_MODEL_NAME
)

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.

P2 Autoroute Documentation Is Incomplete

The shared merge now writes the top-level model, gateway discovery, and Fable override, but the autoroute documentation omits these settings changes.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in be34b15: the autoroute README paragraph now lists the discovery default and the Fable tier key it shares with the merge.

@veria-ai

veria-ai Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

PR overview

This pull request adds lite configure claude and lite unconfigure claude CLI commands for managing Claude settings and restoring prior configuration state.

Two issues have been addressed, with one credential-handling concern still open. Existing Claude credentials can be copied into a persistent state file, allowing another local process or backup system with access to the user's LiteLLM configuration directory to recover them even after removal from Claude settings. Exploitation depends on pre-existing local or backup access, so the remaining risk is minor but should be resolved by avoiding plaintext credential snapshots.

Open issues (1)

Fixed/addressed: 2 · PR risk: 4/10

@codecov

codecov Bot commented Sep 8, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.06528% with 20 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...tellm/proxy/client/cli/commands/claude_settings.py 94.17% 11 Missing ⚠️
litellm/proxy/client/cli/commands/configure.py 93.16% 8 Missing ⚠️
litellm/proxy/client/cli/commands/up.py 75.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@tin-berri

Copy link
Copy Markdown
Contributor Author

CI is green except osv-scan, which also fails on staging's own last three runs; this branch does not touch the lockfile. @greptileai can you reply here with a score and why that score?

@tin-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@greptile-apps

greptile-apps Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Confidence score: 5/5.

The implementation is well-scoped and the changed behavior is covered by meaningful tests: key/model validation, settings preservation, receipt-based repeat configure/unconfigure, user edits surviving unconfigure, symlink-safe writes, permissions, and conflicts with temporary lite up/autoroute ownership. The shared static-token merge also keeps lite configure claude and lite autoroute up consistent.

The only failing check is osv-scan; since this PR does not modify the lockfile and the same check failed on staging’s previous three runs, I consider it an unrelated CI/infrastructure issue rather than a regression from this change. No merge-blocking issues found.

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

@tin-berri

Copy link
Copy Markdown
Contributor Author

Round 2 pushed as be34b15: every thread above is fixed and answered, CI green except the inherited osv-scan. @greptileai can you reply here with a score and why that score?

@tin-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@greptile-apps

greptile-apps Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Confidence score: 5/5.

Round 2 addresses all previously identified issues: receipt/settings staging preserves the earlier undo state on failed reconfiguration; receipts now preserve null/missing env shapes and the missing-file case; CLI tests mock /v1/models instead of opening sockets; model validation uses one request; autoroute documentation reflects the shared merge; symlinked-key behavior is explicitly surfaced; and the shared credential-aware merge removes stale credential slots across all callers. The added tests cover exact restoration, user edits, repeat configure/unconfigure, permissions, symlinks, and ownership conflicts.

CI is green for the changed code. The remaining osv-scan failure is inherited from staging, the branch does not change the lockfile, and therefore does not indicate a regression from this PR. No merge-blocking issues remain.

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

@tin-berri
tin-berri force-pushed the litellm_lit7355_claude_configure branch from be34b15 to 66696b3 Compare September 9, 2026 00:26
@tin-berri

Copy link
Copy Markdown
Contributor Author

Round 3 pushed as 66696b3: the pinned-model finding is fixed and answered. CI green except the inherited osv-scan; the proxy-infra migration timing test flaked once and passed on rerun. @greptileai can you reply here with a score and why that score?

@tin-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@greptile-apps

greptile-apps Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Confidence score: 5/5.

Round 3 fixes the remaining pinned-model issue: repeating lite configure claude without --model now removes the pin written by an earlier configure, matching the command’s output and preserving the user’s prior setup. The earlier findings are also addressed with transactional receipt/settings staging, exact restoration of missing/null env and missing-file states, mocked model-list requests, single-request validation, complete autoroute documentation, stale-credential cleanup, and coverage for symlinks, permissions, user edits, and ownership conflicts.

The changed-code CI is green. The remaining osv-scan failure is inherited from staging, and the branch does not modify the lockfile. The proxy-infra migration timing failure passed on rerun, so it appears flaky rather than a regression from this PR. No merge-blocking issues remain.

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

@tin-berri
tin-berri force-pushed the litellm_lit7355_claude_configure branch from 66696b3 to 4a6f825 Compare September 9, 2026 00:55
@tin-berri

Copy link
Copy Markdown
Contributor Author

Round 4 pushed as 4a6f825: lite autoroute up now pins autorouter as the starting model too, answered on the thread. osv-scan is the inherited red. @greptileai can you reply here with a score and why that score?

@tin-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@greptile-apps

greptile-apps Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Confidence score: 5/5.

Round 4 addresses the remaining autoroute behavior: lite autoroute up now pins the top-level starting model to autorouter, matching the tier model overrides so the initial Claude Code request follows the same routing path as sub-agents and background helpers.

The prior findings remain addressed: transactional settings/receipt handling, exact restoration of missing/null shapes, selective undo that preserves user edits, credential cleanup, symlink-safe writes, ownership conflict checks, mocked model-list validation, and coverage for repeat configuration and permissions. The changed-code CI is green. osv-scan remains an inherited failure from staging; this PR does not modify the lockfile, so it does not indicate a regression from these changes. No merge-blocking issues remain.

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

@tin-berri

Copy link
Copy Markdown
Contributor Author

@greptile review

@tin-berri
tin-berri force-pushed the litellm_lit7355_claude_configure branch from 4a6f825 to 99be9a0 Compare September 9, 2026 01:29
@tin-berri

Copy link
Copy Markdown
Contributor Author

Round 8 pushed as 9eab2a5: the withheld report now names only credentials unconfigure actually left removed, answered on the thread. CI green except the inherited osv-scan. @greptileai can you reply here with a score and why that score?

@tin-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@greptile-apps

greptile-apps Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Confidence score: 5/5.

Round 8 closes the final review gap: withheld now includes only credential slots that still match configure’s written fingerprints and were actually left removed, while user-modified slots remain solely in kept. The added regression test covers that exact case.

The broader implementation also has coverage for receipt/settings write failures, exact file and env shape restoration, endpoint changes, stale credential conflicts, model pin/re-login behavior, symlink handling, Windows helper quoting, and mocked model discovery. CI is green aside from the inherited osv-scan; I found no remaining correctness or security blockers.

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

@tin-berri
tin-berri force-pushed the litellm_lit7355_claude_configure branch from 9eab2a5 to 438d360 Compare September 9, 2026 20:11
@tin-berri

Copy link
Copy Markdown
Contributor Author

@greptileai can you reply here with score & why

@tin-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@greptile-apps

greptile-apps Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Confidence score: 4/5.

The implementation is substantial and well-covered: it centralizes Claude settings merging, validates credentials and models through /v1/models, records receipt state without duplicating tokens, preserves user edits during reconfiguration, handles missing/null env and settings files, protects temporary lite up/autoroute ownership, and includes focused regression tests. The latest CI status is passing, and the previously identified correctness issues have been addressed in follow-up commits.

I’m not giving 5/5 because this changes several credential and filesystem-state paths with intentionally non-atomic settings/receipt commits and meaningful edge-case complexity, so continued integration coverage is warranted. I found no remaining blocking correctness issue in the latest revision.

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

@tin-berri
tin-berri force-pushed the litellm_lit7355_claude_configure branch from 438d360 to 4bf19b5 Compare September 9, 2026 22:50
@tin-berri

Copy link
Copy Markdown
Contributor Author

Round 9 pushed as 4bf19b53ce. Beyond the one Bugbot finding (repeat configure reclaiming user edits), an adversarial pass on the receipt and the command layer found eight more confirmed issues, fixed as four mechanisms rather than patches:

  • Ownership moves only by a write, on both sides of a key: written_* lists only keys a merge changed, a repeat refreshes a fingerprint only for a key its merge changed, and the snapshot is kept only while a key still holds our value and is retaken otherwise, so whatever a repeat displaces (a model, a user-added ANTHROPIC_API_KEY, a replaced token, a user's own apiKeyHelper) is what unconfigure brings back
  • A credential goes back only beside the ANTHROPIC_BASE_URL it was captured with (credential_endpoints on the receipt, compared with the URL the restored file will hold); withheld ones stay in a kept receipt so a second unconfigure finishes once the URL points back, instead of the receipt deleting the only copy
  • One filesystem boundary: every rename and unlink raises ClaudeSettingsError naming the path and discards the sibling staged file, so no .tmp-* with a token is left behind and login never relabels it "Authentication failed"
  • Preconditions and reporting: the lite up ownership check runs before any login or request in every settings-writing command (including lite login --config-claude), restored is a real before/after diff with a file_removed flag, /v1/models hints are picked by a typed ListingFailure kind, and one STARTING_MODEL_ROLE string replaces the login hint that claimed --model pins every tier

673 CLI tests pass, four delta gates and the recursion detector pass, codecov/patch 93.42%.

@greptileai can you reply here with a score and why that score?

@tin-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@greptile-apps

greptile-apps Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Confidence score: 5/5.

Round 9 resolves the remaining correctness gaps I identified. Receipt ownership is now per-key and write-driven, repeat configure/re-login snapshots and fingerprints user changes correctly, credential restoration is bound to the captured ANTHROPIC_BASE_URL, and withheld credentials remain recoverable through a retained receipt. The staged-file boundary consistently converts filesystem failures to ClaudeSettingsError while cleaning up sibling temp files.

The command layer checks ownership before authentication or model-listing requests, uses typed listing failures for actionable hints, and keeps model pinning scoped to Claude Code’s starting model. The focused regression coverage exercises repeat configuration, credential and endpoint changes, deletion, symlink handling, failure cleanup, and command preconditions. The reported 673 CLI tests, CI status, and coverage are passing, and I found no remaining blocking correctness issues in 4bf19b53ce.

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

Persistently route Claude Code through a LiteLLM proxy with a long-lived virtual key or the stored lite login, turn on gateway model discovery so /model lists the proxy's models, optionally pick the model Claude Code starts on, and record what changed so unconfigure restores only the keys the user has not touched since. lite login --config-claude writes through the same receipt and is undoable too. The two settings merges (lite up / --config-claude and lite autoroute) collapse into one credential-aware merge
@tin-berri
tin-berri force-pushed the litellm_lit7355_claude_configure branch from 4bf19b5 to f1d655f Compare September 10, 2026 00:18
file_existed=file_exists if earlier is None else earlier.file_existed,
env_present=ENV_KEY in current if earlier is None else earlier.env_present,
env_was_object=isinstance(current.get(ENV_KEY), dict) if earlier is None else earlier.env_was_object,
previous=MappingProxyType({path: claim.previous for path, claim in claims.items()}),

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.

Low: Prior credentials persist in the receipt

claim.previous includes the full values of env.ANTHROPIC_API_KEY and env.ANTHROPIC_AUTH_TOKEN, so configuring copies any existing credential into ~/.litellm/claude_configure_state.json. A local process or backup policy with access to that directory can recover the key even after it has been removed from settings.json, and the copy can remain indefinitely when unconfigure retains a receipt for withheld credentials. Store credential snapshots in the OS credential vault behind an opaque receipt reference, rather than serializing them into this JSON file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Answered without a code change here, and filed as LIT-7437 to be done once for every snapshot the CLI keeps, because this receipt is already the narrowest copy in that chain:

  • The receipt is staged with tempfile.mkstemp (0600) inside ~/.litellm, which ensure_private_dir keeps at 0700. The value it snapshots comes from ~/.claude/settings.json, which Claude Code writes at 0644, so the copy is less readable than the original the user already keeps.
  • It holds a previous credential only for the window in which that credential is out of settings.json and unconfigure needs it to put it back. A normal unconfigure removes the receipt; the withheld case names the file and how to drop it.
  • What this configure writes is never in the receipt: written holds sha256 fingerprints, not values. The two older snapshots in the same directory, lite up's claude_settings_backup.json and lite autoroute up's copy, hold the whole settings file including any credential, and Ramp Router's ramp-router-state.json stores both the prior ANTHROPIC_API_KEY and the written ANTHROPIC_AUTH_TOKEN as plaintext under ~/.claude.
  • The CLI's keychain helper (cli_keyring.SecretVault) is a single-slot vault for the login token. Snapshots keyed by settings path and credential slot need a keyed variant, the same fallbacks cli_token_utils has for an unreachable keychain, and an erase on lite down / autoroute down / unconfigure plus an answer for a receipt deleted by hand (a keychain entry would outlive it, which the current message says drops the credential). That is one change across all three files, so it lives in LIT-7437 rather than in this receipt alone.

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.

Thanks for the detail. I can't automatically confirm this is safe to dismiss, so I'm leaving the thread open for a maintainer to make the call.

@tin-berri

Copy link
Copy Markdown
Contributor Author

Round 10 pushed as f1d655f. Beyond answering Bugbot's two findings on 4bf19b53ce in-thread (an OSError escaping the filesystem boundary; the staged receipt discarded then committed when the restored document is empty while a credential is withheld), this round is a size rebuild with no semantic change: the receipt is one map keyed by dotted path (env.ANTHROPIC_BASE_URL, apiKeyHelper, model, ...) instead of parallel env/top-level pairs, so each undo rule is written once; both files land through one helper (_land: commit the staged document or unlink the path, one ClaudeSettingsError on any OSError, sibling staged file discarded); every entry point shares one prelude (_start: ownership check, credential, GET /v1/models, before any login prompt); and the undo tests are a scenario table. 1973 to 1715 insertions, 799 under litellm/. Veria's Low on the receipt holding a removed credential's previous value is answered in-thread and filed as LIT-7437 to be done once for every settings snapshot the CLI keeps. CI green except the inherited osv-scan.

@greptileai can you reply here with a score and why that score?

@tin-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@greptile-apps

greptile-apps Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Confidence score: 5/5.

Round 10 preserves the previously validated behavior while simplifying the implementation: the dotted-path receipt removes duplicated undo logic, _land gives settings and receipt writes the same staged-commit/error-cleanup boundary, and _start keeps ownership checks, credential resolution, and model discovery validation ahead of any login prompt. The table-driven undo scenarios cover repeat configuration, user edits, credential/URL mismatches, missing files, and withheld credentials, while the shared merge keeps lite up, login, autoroute, and configure consistent.

The current commit has no merge-blocking findings. CI for the changed code is green; osv-scan remains the inherited staging failure, and this PR does not modify the lockfile, so it does not indicate a regression from this change.

@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 f1d655f. Configure here.

@tin-berri
tin-berri merged commit 317b29e into litellm_internal_staging Sep 10, 2026
88 of 89 checks passed
@tin-berri
tin-berri deleted the litellm_lit7355_claude_configure branch September 10, 2026 01:02
mateo-berri added a commit that referenced this pull request Sep 10, 2026
…yhelper_conflict

Resolves the conflicts with the lite configure claude work from #40319: every persistent
writer and reader of Claude Code's settings file now resolves it through CLAUDE_CONFIG_DIR,
the lite up backup check only guards the default file, and each settings file keeps its own
undo receipt (the default file keeps ~/.litellm/claude_configure_state.json, any other file
gets ~/.litellm/claude_configure_state/<sha256 of its resolved path>.json).
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