claude: authenticate gateway model discovery - #362
Conversation
befa707 to
176995c
Compare
|
|
||
|
|
||
| def _launch_gateway(state: dict, binary: str, tool_args: list[str]) -> None: | ||
| from ucode.gateway_proxy import AUTHORIZATION_HEADER, start_proxy |
There was a problem hiding this comment.
can this be at the top of the file instead
| # near-expiry one cached from an earlier CLI call. Raises if auth is dead | ||
| # (surfaced by the caller at launch, before Claude Code starts). | ||
| self._refresh(force=True) | ||
| self._refresh() |
There was a problem hiding this comment.
did you confirm this works with relayed auth? https://docs.google.com/spreadsheets/d/19M0DShshcYS1aiLg49dPidIsujRPyWhC_ZQRcpeT3Kw/edit?gid=0#gid=0
There was a problem hiding this comment.
I tested with relayed auth and it works without any issues.
| token = get_databricks_token(self._workspace, self._profile, force_refresh=force) | ||
| def _refresh(self) -> None: | ||
| """Force-mint a token and record its expiry.""" | ||
| token = get_databricks_token(self._workspace, self._profile, force_refresh=True) |
There was a problem hiding this comment.
why are we changing to always force refresh? this is altering the existing behavior, for ex line 154 in the original code did not force a refresh
There was a problem hiding this comment.
We force refresh because a normal token request may return the same nearly expired cached token. Otherwise the refresh would trigger once the current token errors which could cause some queries to fail.
Summary
Set the gateway URL, mode, and auth token in the process environment before Claude starts.
Claude Code checks these values before settings-based environment variables and
apiKeyHelperresolve. Without them, it skipsGET /anthropic/v1/models.Relayed launches are unchanged.
This PR is independent from #347 and based directly on
main.Testing
pytest tests/test_agent_claude.py(100 passed)This pull request and its description were written by Isaac.