Repository navigation
Studio: send custom headers on remote connections - #15097
Conversation
Fixes unslothai#14811 Connections can store extra request headers (Name: value, or JSON) and send them on every upstream call. Values may include {{CHAT_SESSION_ID}} for the open chat. Auth and hop-by-hop names are rejected so a header cannot replace the saved key.
|
The That test pins a rule: when the request carries an explicit API key, the proxy must not load the saved provider record, because the edited target in the request wins over what is stored. The custom headers path now reads the saved provider in that case too. Taking the headers from the request when a key is explicit, and from the saved record only when it isn't, should keep the rule and still send them. |
Do not look up a saved connection when the request already carries an API key.
Keep the reserved-name parser off the first-screen JS. CI was 0.5 KB transfer over the startup budget because that code sat in the eager external-providers module.
Main added a base-URL helper next to the same import. Move ours so the pull request still merges.
An explicit API key must not load the saved connection. Take extra headers from the chat request in that case, and from the stored record only when the request uses the saved key.
|
Two more failures from this PR on its latest push:
|
Add postponed evaluation in providers.py so PEP 604 annotations do not count against the studio import floor. Sync the frontend startup budget with main and raise it for the connections extra-headers editor (unslothai#15097).
Resolve bundle budget conflict for unslothai#15084 and unslothai#15097.
|
@danielhanchen Re the That keeps the "explicit keys must not bind saved metadata" rule while still sending custom headers when the client supplies them. |
|
@danielhanchen Re the other two items on the latest push:
Also cleaned up merge conflict markers in |
|
The latest merge of main into this branch did not land cleanly. The PR now changes 26 files under Taking main's version of everything under |
The last merge of main left older copies of .github/workflows on this branch, including push and pull_request triggers on codeql.yml. Take main's .github tree so workflow-trigger lint matches main. Deferred annotations stay in models/providers.py. The connection header editor fits inside main's current startup bundle budget (6790.3 KB raw, 2046.0 KB transfer, 99 chunks), so that budget is left as main set it.
Resolve conflicts in external_provider stream_chat_completion (keep header template vars with main's docstring) and external-providers.ts (keep extraHeadersFromSaved with main's max-tokens comment).
|
Merged latest |
Hide header values of an owner-shared connection from other accounts, and send saved headers on test/models calls only when the request targets the saved endpoint without its own key. [skip ci]
A non-ASCII or control-character value was saved, then every request to the connection failed with UnicodeEncodeError. [skip ci]
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Trim surrounding whitespace h11 refuses, percent-encode substituted thread ids and model names httpx cannot send, and send the saved OpenAI connection headers on container list/create/delete.
Two connections on one URL and key that route by header no longer share a served context window, chat template or vLLM probe. [skip ci]
…strictly The served context window probe now sees the chat session id, and a JSON headers draft is rejected instead of silently losing entries. [skip ci]
… case-insensitively
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Summary
Fixes #14811
OpenAI-compatible connections (including LiteLLM) can now send extra static headers. In Connections, add one header per line:
JSON objects work too.
{{CHAT_SESSION_ID}}is the open chat/thread id. Reserved names (Authorization,Cookie, hop-by-hop headers, API-key aliases) are rejected so a header cannot replace the saved credential.Test plan
pytest tests/test_provider_extra_headers.py tests/test_providers_db_models.py(7 passed)node --experimental-strip-types --test tests/custom-provider-api-type.test.ts(2 passed)X-LiteLLM-Session-Id: unsloth-{{CHAT_SESSION_ID}}, save, chat, and confirm LiteLLM/proxy logs show the chat idAuthorization: ...is rejected on saveBefore / after
A saved custom connection with two extra headers, opened for editing in Settings > Connections (merge base
be64e0d78vs headdb5ea11c6). After the change the form shows the Extra headers field with the saved values, the API returns them, and a local upstream receivesX-Title: Unslothon the connection check; before, none of these exist.