[ML-62918] Auto-detect OBO endpoints and forward user token#145
Open
[ML-62918] Auto-detect OBO endpoints and forward user token#145
Conversation
eb21e57 to
0e82c5b
Compare
bbqiu
reviewed
Mar 12, 2026
dhruv0811
commented
Mar 17, 2026
bbqiu
reviewed
Mar 19, 2026
bbqiu
reviewed
Mar 19, 2026
e2e-chatbot-app-next/packages/ai-sdk-providers/src/providers-server.ts
Outdated
Show resolved
Hide resolved
bbqiu
reviewed
Mar 19, 2026
bbqiu
reviewed
Mar 19, 2026
e2e-chatbot-app-next/packages/ai-sdk-providers/src/providers-server.ts
Outdated
Show resolved
Hide resolved
bbqiu
reviewed
Mar 19, 2026
Contributor
bbqiu
left a comment
There was a problem hiding this comment.
overall looks great! just a few nits to address, sorry for the dealy in reviewing
Contributor
Author
bbqiu
reviewed
Mar 20, 2026
Comment on lines
+39
to
+50
| const userToken = req.headers['x-forwarded-access-token'] as string | undefined; | ||
| if (userToken && oboInfo.enabled) { | ||
| const payload = decodeJwtPayload(userToken); | ||
| if (payload) { | ||
| // Databricks OAuth tokens use 'scope' (space-separated string) | ||
| const tokenScopes = typeof payload.scope === 'string' | ||
| ? payload.scope.split(' ') | ||
| : Array.isArray(payload.scp) ? payload.scp as string[] : []; | ||
| // A required scope like "sql.statement-execution" is satisfied by | ||
| // an exact match OR by its parent prefix (e.g. "sql") | ||
| missingScopes = oboInfo.requiredScopes.filter(required => { | ||
| const parent = required.split('.')[0]; |
Contributor
There was a problem hiding this comment.
nit: to make this slightly cleaner, can we make a helper function that goes from oauth token -> scopes
and then we can do the same comparison between present / required scopes
c757dbd to
f9bc45d
Compare
When the serving endpoint has auth_policy.user_auth_policy.api_scopes (OBO-enabled), the chat template now: 1. Detects OBO via the serving-endpoints API response 2. Logs a warning with required scopes for the user to configure 3. Exposes OBO status via GET /api/config 4. Forwards x-forwarded-access-token header to the endpoint Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When the serving endpoint has OBO scopes (auth_policy.user_auth_policy), display an amber badge in the chat header listing the required scopes and linking to the auth docs. Also notes that UC function scopes are not yet supported. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Always include serving.serving-endpoints in required OBO scopes - Detect Supervisor Agents via tile_endpoint_metadata.problem_type - Decode user JWT server-side to check which scopes are present - Only show banner for MISSING scopes (disappears when all configured) - Parent scope matching (e.g. "sql" satisfies "sql.statement-execution") - Full-width red banner with error icon and doc link - Use user's OBO token as Authorization when endpoint supports OBO - Remove debug logging Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Supervisor Agents may require scopes beyond serving.serving-endpoints for their downstream tools (Genie, SQL, etc.). Full scope discovery for SAs is not yet available. Updated banner and log to communicate this limitation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…docs link - Always use user token for Authorization when present (remove cachedOboEnabled) - Keep x-forwarded-access-token header for downstream agent apps - Store isSupervisorAgent in cache to fix broken length === 0 detection - Update docs link to specific OBO section Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
f9bc45d to
e1ca982
Compare
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

Summary
Auto-detect OBO-enabled serving endpoints and surface scope configuration to the user.
This is a followup to #152 which only addressed the Agents on Apps token forwarding. In this PR, we also address apps connected directly to a model serving endpoint.
Detection:
auth_policy.user_auth_policy.api_scopes(custom endpoints) ortile_endpoint_metadata.problem_type === "MULTI_AGENT_SUPERVISOR"(Supervisor Agents)serving.serving-endpointsin required scopes (needed to call the endpoint as the user)Token forwarding:
Authorizationheader with the user'sx-forwarded-access-tokenso the endpoint sees the user's identityx-forwarded-access-tokenthroughstreamTextheaders in the chat routeSmart banner:
sqlsatisfiessql.statement-executionandsql.warehousesGET /api/config→obo.missingScopesNote: UC function scopes are not yet supported in the Apps scope configuration UI.
No scopes enabled on app connected to serving endpoint that requires scopes:

Logs:

After adding partially required scopes (error message updates after checking whats on the token):

After adding ALL required scopes:

Still works for OBO on Agents on Apps:
