feat(llm-gateway): forward priority#277
Open
along-2017 wants to merge 4 commits into
Open
Conversation
📝 WalkthroughWalkthroughThe gateway maps optional priority from NVCF authorization into ChangesResolved priority forwarding
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant LLM API Gateway
participant NVCF Authorization
participant Stargate
Client->>LLM API Gateway: Invocation request
LLM API Gateway->>NVCF Authorization: AuthorizeInvocation
NVCF Authorization-->>LLM API Gateway: Optional resolved Priority
LLM API Gateway->>LLM API Gateway: Store Priority in RequestContext
LLM API Gateway->>Stargate: Proxy with controlled X-Priority
Stargate-->>LLM API Gateway: Upstream response
LLM API Gateway-->>Client: Proxied response
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
🛡️ CodeQL Analysis🚨 Found 2 issue(s) Severity Breakdown:
📋 Top Issues🔗 View full details in Security tab 🕐 Last updated: 2026-07-20 23:06:59 UTC | Commit: 6dddab2 |
along-2017
force-pushed
the
feat/llm-gateway-forward-x-priority
branch
from
July 20, 2026 23:44
6dddab2 to
ed82f7f
Compare
Contributor
|
Please provide a github issue instead of an internal JIRA. |
along-2017
force-pushed
the
feat/llm-gateway-forward-x-priority
branch
from
July 21, 2026 16:36
a9fd75d to
3108a91
Compare
along-2017
marked this pull request as ready for review
July 21, 2026 17:26
FamousDirector
requested changes
Jul 21, 2026
NVCF API now resolves a caller priority at auth time and returns it on AuthLlmInvokeResponse. Carry that value through the gateway and forward it to Stargate as the X-Priority header so Stargate can apply per-priority routing and queue estimation. - Add optional uint32 priority to the AuthLlmInvokeResponse proto and regenerate the generated Go. - Carry the nullable priority on InvocationAuthResponse and copy it onto RequestContext in the invocation auth middleware. - Emit X-Priority on all three LLM paths (chat/completions, responses, and the embeddings/generic proxy) only when a value is resolved. An explicit 0 (highest priority) is forwarded; an unset value omits the header so Stargate applies its own default, matching how the gateway already omits x-routing-method and x-cache-affinity-key. The clone-based proxy path still forwards a client-supplied X-Priority when the gateway resolves none. Rejecting client-supplied X-Priority is handled separately; that change should land with or before this one. Signed-off-by: along <along@nvidia.com>
Close two review gaps, both mutation-verified: a client mapping that turns an unset proto priority into 0 and a proxy that unconditionally emits X-Priority 0 previously passed the whole suite. - Assert AuthorizeInvocation maps an unset proto priority to nil, and add a round-trip case for explicit 0 and the uint32 max as set values. - Assert Proxy omits X-Priority when no priority is resolved, and that a resolved value replaces a client-supplied header from the clone with exactly one value rather than appending. Signed-off-by: along <along@nvidia.com>
Signed-off-by: along <along@nvidia.com>
Address review feedback: the middleware priority tests exercised only /v1/chat/completions. The auth middleware is registered globally and the routing key comes from the request body model field, so propagation is path-independent; make the resolved and unset cases table-driven over /v1/chat/completions, /v1/responses, and /v1/embeddings to pin that for every entry that forwards X-Priority. Signed-off-by: along <along@nvidia.com>
along-2017
force-pushed
the
feat/llm-gateway-forward-x-priority
branch
from
July 21, 2026 21:36
75150e7 to
70321cd
Compare
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.
TL;DR
The gateway now forwards the caller priority that NVCF API resolves during invocation auth to Stargate, as the
X-Priorityheader on all three LLM paths (chat/completions, responses, embeddings/generic proxy). The header is gateway-owned: client-supplied values are stripped on the proxied paths, an explicit 0 (highest priority) is forwarded, and an unset priority omits the header so Stargate applies its own default.Additional Details
optional uint32and stays nullable end to end, so "no priority configured" is never conflated with priority 0.x-routing-method,x-cache-affinity-key): set only when resolved, never defaulted.X-Prioritywith an explicit 400 will be tracked in a separate PR; the strip here makes forwarding safe regardless of merge order.For the Reviewer
Proxyinprovider/stargate.gois the subtle site: it clones inbound client headers, soX-Priorityis deleted right after the clone and set only from the resolved value..pb.gofiles are regenerated from the proto change; reviewllm_gateway.protoinstead.For QA
go build ./...andgo test ./...are green in the gateway module. New tests cover resolved, explicit-zero, unset, and client-supplied-header cases on every path, at the middleware, client-mapping, and header-emission layers; the two highest-risk regressions (unset mapped to 0, proxy emitting 0 unconditionally) were verified by mutation.Issues
Closes #186.
Checklist