Conversation
OpenCode 2 rejects plugin modules without a default { id, setup } export and has no config hook for injecting a provider fetch, so the generated ucode-auth.js failed to load and the configured token was never refreshed. Render an OpenCode 2 entrypoint that attaches a fresh bearer through session http.request hooks and retries a 401 once through the retry hook. OpenCode 1.x output is unchanged.
Concurrent requests rejected with the same token each ran `ug auth-token --force-refresh` from the retry hook. Record the Authorization rejected with a 401 in an http.response hook and refresh only when it is still the current token, matching the OpenCode 1.x fetch guard.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The generated OpenCode auth plugin (
ucode-auth.js) now also supports the OpenCode 2 plugin API, so the Databricks token keeps being refreshed on OpenCode 2. The installed OpenCode major version picks the entrypoint. OpenCode 1.x output is unchanged.Why
OpenCode 2 rejects plugin modules without a default
{ id, setup }export, so the existing plugin failed to load:OpenCode 2 also has no
confighook for installing a providerfetch. So once the token written at configure time expired, it was never refreshed.How
render_auth_pluginis split into a shared prelude and a per-version entrypoint. The prelude holds token caching, theug auth-tokencall, and the single-flighted refresh.write_auth_pluginwrites the V2 entrypoint whenagent_version("opencode")reports major version 2 or later. Otherwise, including when the version is unknown, it writes the existing V1 entrypoint.http.requestrefreshes the token when it is missing or about to expire, then setsAuthorization.http.responserecords theAuthorizationthat got a 401.retryretries a 401 once, on the first retry (attempt2), because OpenCode does not retry 401s by default. It refreshes only when the rejected token is still the current one. This matches the V1accessToken === attemptedTokenguard, so concurrent 401s on the same token runug auth-token --force-refreshonly once.plugin/directory, which OpenCode 2 still discovers.Testing
.venv/bin/pytest tests/test_agent_opencode.py: 66 passed.ruff checkandruff format --checkon both changed files, andty check src/ucode/agents/opencode.py: all clean.node --check.attempt3 and later are not retried.tests/test_claude_smart_routing_v2.pyand 3 intests/test_e2e_user_agent.py. The same 5 fail onmain, so they are unrelated to this change.