Repository navigation
[ISSUE #7871] Add provider-native AI protocol routing - #7985
Merged
hengyuss merged 1 commit intoOct 23, 2026
Merged
Conversation
Aias00
approved these changes
Oct 22, 2026
Aias00
left a comment
Contributor
There was a problem hiding this comment.
Review: #7985 [ISSUE #7871] Add provider-native AI protocol routing
Verdict: approved. This is the natural follow-up to #7910: it takes the identity case out of the converter registry and makes the client→provider route an explicit, request-scoped value. The tests are the strongest part.
What the change actually does
IdentityAiProtocolConverteris deleted. Identity is no longer something the registry can answer:AiProtocolConverterFactory.getConverterandsupportsno longer special-casesource == target, andfindConverterreturnsOptional.empty()instead of throwing.AiProtocolRouteResolverowns the decision: native passthrough first (nativeProtocols.contains(clientProtocol)→AiProtocolConversion.identity), otherwise a registered directional converter, otherwiseShenyuException.AiProtocolRouteis a record that validates itself in the compact constructor — a converter that claimstargetProtocol() == "native"but returns a conversion whose request protocol is something else is rejected rather than silently sent upstream.AiProxyEngine.preparenow holds aAiProtocolRouteand passesroute.clientProtocol()intoPreparedExchange; the failover path atcopy.setProtocol(primary.clientProtocol())is unaffected.
Verified
- No dangling callers of the removed identity path:
getConverteris referenced only inside the factory and its test after this change (search/codeoverapache/shenyushows onlyAiProtocolConverterFactoryandAiProtocolConverterFactoryTest; thegetConverterhits inshenyu-plugin-jwtare unrelated classes).supportshas no production caller at all — onlyprovider.supports(...)atAiProxyEngine:241— so dropping identity from it is behaviourally free. AiProtocolRouteResolverTestcovers the five cases that matter: native route wins without invoking the converter (assertFalse(invoked.get())), converted route binds the converted request and the reverse response adapter, registration order decides between two viable targets, no route →ShenyuException, and a lying converter →IllegalArgumentExceptionfrom the record.AiProtocolConverterFactoryTestis rewritten in step rather than deleted:testDoesNotTreatIdentityAsRegisteredConversionnow asserts bothsupports(a, a) == falseand thatgetConverter(a, a)throws, which is the contract the resolver depends on.- The starter still wires everything:
aiProtocolRouteResolveris a@Bean @ConditionalOnMissingBean,aiProxyEnginetakes it, andAiProxyPluginConfigurationTestassertshasSingleBean(AiProtocolRouteResolver.class). Note this bean sits in the same plain@ConfigurationI flagged for #7917 — the ordering caveat applies, but it is pre-existing here and not worth widening this PR.
Non-blocking
PreparedExchange.targetProtocolis written but never read.AiProxyEngineusesclientProtocol()at line 117 for failover but nothing consumestargetProtocol()(grep over the head file: lines 252, 273, 274 only). Either drop the component or use it in the log/metric line — right now it is a field that will silently drift.AiProtocolRoutecan throwNullPointerExceptioninstead ofIllegalArgumentException. The compact constructor doesconversion.request().getProtocol(); if a converter returns a conversion with a null request, the failure surfaces as an NPE rather than the validation error this record exists to produce.Objects.requireNonNull(conversion.request(), …)first would keep the contract uniform.AiProtocolConverterFactorygained a stray blank line before the closing brace (the+at the end of the hunk) — harmless, but the diff has no reason to touch that line.- The unsupported-route message still names protocols rather than the provider (
"Unsupported AI protocol route from X to provider protocols [openai-chat]"). Same note I left on #7910; still not blocking, and now the message is built one layer closer to the provider so it would be cheap to includeprovider.name().
13 tasks
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.
Part of #7871.
Summary
Tests
AiProtocolConverterFactoryTestAiProtocolRouteResolverTestAiProxyEngineTestAiProxyEngineOrchestrationTestAiProxyPluginConfigurationTestMake sure that:
./mvnw clean install -Dmaven.javadoc.skip=true.