add more context to ai-gateway jwt#73315
Open
alex-m-brown wants to merge 1 commit into
Open
Conversation
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.
Adds five new claims to the AI Gateway access-token JWT, pulled from the
aichatContextthe client already sends:client_typelevel_id(fromcurrentLevelId)script_idchannel_idlesson_idThese claims let the AI Gateway Worker attach curriculum context (level, lesson, script, channel) to Sentry traces, so we can slice telemetry by lesson and correlate a request back to a specific issuance event. The token interface on the worker side already declared
channel_idandlevel_idas required fields, but they were never actually issued — this fixes the mismatch and adds the other three while we're touching the issuer.Links
context.*attributes on the root Sentry spanTesting story
/ai_gateway/access_tokenwith a realaichatContext, decoded the returned JWT, confirmed all five new claims are populated with the values the client sent.Note: Lesson_id is in the AIchatContext Type, but it isn't currently passed through. we can add this in a follow-up if useful.
can_access_aichat_chat_completion?still gates correctly (no behavior change to the access check — only refactored to a local var).