Skip to content

Cursor LLM gateway config is a no-op: writes settings Cursor never reads #6293

Open

Description

@danbarr

Summary

thv llm setup --client cursor reports success and patches ~/Library/Application Support/Cursor/User/settings.json with:

"cursor.general.openAIBaseURL": "http://localhost:14000/v1",
"cursor.general.openAIAPIKey": "thv-proxy"

(pkg/client/config.go:517-519, via ConfigureLLMGateway in pkg/client/llm_gateway.go). The gateway proxy (thv llm proxy start) starts and responds correctly. But nothing changes in Cursor: Settings → Models → "Override OpenAI Base URL" stays off, and manually switching it on shows the stock default (https://api.openai.com/v1), not the value from settings.json.

Root cause

Checked directly against the installed Cursor client (workbench.desktop.main.js, Cursor 3.15.19). The keys ToolHive writes — openAIBaseURL / openAIAPIKey (with that exact casing, under cursor.general.*) — do not appear anywhere in the bundle. The feature Cursor actually has is openAIBaseUrl (lowercase Url) plus a separate useOpenAIKey boolean, and both are read and written exclusively through Cursor's own internal state store, not the standard VS Code configuration service:

this.reactiveStorageService.applicationUserPersistentStorage.openAIBaseUrl ?? "https://api.openai.com/v1"
...
i.setApplicationUserPersistentStorage("openAIBaseUrl", v)
i.setApplicationUserPersistentStorage("useOpenAIKey", !0)

There is no code path in the bundle that reads cursor.general.openAIBaseURL (or any cursor.general.* key) from settings.json for this feature. So ConfigureLLMGateway for Cursor patches a file/key that the current app never consults — thv llm setup succeeds and reports nothing wrong, but the integration silently does nothing.

I have not yet located where applicationUserPersistentStorage actually persists to disk — a search of ~/Library/Application Support/Cursor/User/globalStorage/state.vscdb's ItemTable for openai/baseurl/apikey-like keys came up empty, so it's under a different key format, a different table, or a different storage file entirely.

Why this needs care, not just a key-name fix

applicationUserPersistentStorage is Cursor's own internal, undocumented storage mechanism — not a stable public API surface the way settings.json is. Even once the correct persistence location is found, writing into it directly is inherently more fragile than the settings.json approach ToolHive uses for every other client, and could silently break again on a future Cursor release. Worth deciding whether:

  1. It's worth reverse-engineering and writing to Cursor's private storage anyway (accepting the fragility), or
  2. Cursor should be marked as unsupported for the LLM gateway proxy-mode integration until/unless Cursor exposes a supported configuration surface for this, or
  3. Some other integration point exists (e.g. a documented settings key for a different mechanism, or an extension-based approach) that hasn't been checked yet.

Impact

Every thv llm setup --client cursor run to date has silently failed to configure Cursor, while reporting success. Given IsClientInstalled/DetectedLLMGatewayClients both consider Cursor supported and configured, this has presumably shipped since Cursor support was added and gone unnoticed.

References

  • pkg/client/config.go:485-521 (Cursor's clientAppConfig, including the LLMGatewayKeys specs)
  • pkg/client/llm_gateway.go:39-89 (ConfigureLLMGateway, the JSON-Pointer patch path used for Cursor)
  • Related: thv llm setup false-negative detection for Cursor/VSCode without shell PATH integration #6292 (Cursor/VSCode detection false negatives) — that issue is about detection; this one is about the actual configuration being applied being ineffective even when detection succeeds.

Activity

  1. added
    needs-triage
    on Aug 12, 2026
  2. stantheman0128 commented on Sep 4, 2026

    @stantheman0128
    Contributor

    I'd like to work on this.

    This is the config write, not the detection miss in #6292 / #6481. After #6492, VS Code goes through chatLanguageModels.json. Cursor still patches cursor.general.openAIBaseURL / openAIAPIKey in settings.json. On this Win11 box that file is %APPDATA%\Cursor\User\settings.json.

    I will wait to be assigned, and I will wait on a call among the three options in the issue (private storage vs mark unsupported vs another public surface). I will not open a PR that writes Cursor's undocumented store unless that is the chosen path.

  3. stantheman0128 commented on Sep 4, 2026

    @stantheman0128
    Contributor

    Follow-up from a Win11 box (Cursor 3.19.7). The Models UI store is not a key named openai/baseurl in ItemTable. It is nested JSON.

    File: %APPDATA%\\Cursor\\User\\globalStorage\\state.vscdb
    Table: ItemTable
    Key: src.vs.platform.reactivestorage.browser.reactiveStorageServiceImpl.persistentStorage.applicationUser

    Fields the UI actually reads: openAIBaseUrl, useOpenAIKey. The API key is not in that blob. It sits under a separate ItemTable key, secret://cursorAuth/openAIKey (VS Code SecretStorage).

    A dummy thv llm setup --client cursor --lazy on this machine wrote the dead cursor.general.openAIBaseURL / openAIAPIKey keys in settings.json and left the sqlite blob on the stock default (https://api.openai.com/v1, useOpenAIKey false). Teardown restored settings.json.

    There is no %APPDATA%\\Cursor\\User\\chatLanguageModels.json here, and the workbench bundle has no chatLanguageModels string. VS Code on the same box does have that file. That public surface is #6492, not Cursor.

    So option 3 looks empty on current Cursor. Option 1 would mean writing that JSON plus SecretStorage while Cursor has the DB open (WAL, ~7GB here). I still will not do that unless this is assigned and that path is the call.

  4. blkt commented on Sep 4, 2026

    @blkt
    Contributor

    Hi @stantheman0128 please be aware that Cursor routes all requests through their remote servers and rejects private addresses like the one set by thv llm setup (docs here). I'm sharing this so that you don't waste time trying to implement this or to get this to work while we figure out internally what to do with it.

  5. removed
    needs-triage
    on Sep 4, 2026
  6. stantheman0128 commented on Sep 4, 2026

    @stantheman0128
    Contributor

    Thanks. I will leave the private-storage write alone and wait on the internal call. The store mapping above can stay for whenever you decide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions