Fix the issue where AI route fallback does not work when using Bedrock. (#2653)

This commit is contained in:
澄潭
2025-07-31 20:16:16 +08:00
committed by GitHub
parent 4acb65cc67
commit 645646fe22
3 changed files with 10 additions and 40 deletions

View File

@@ -97,6 +97,9 @@ func initContext(ctx wrapper.HttpContext) {
value, _ := proxywasm.GetHttpRequestHeader(header)
ctx.SetContext(ctxKey, value)
}
for _, originHeader := range headerToOriginalHeaderMapping {
proxywasm.RemoveHttpRequestHeader(originHeader)
}
}
func saveContextsToHeaders(ctx wrapper.HttpContext) {
@@ -127,6 +130,9 @@ func onHttpRequestHeader(ctx wrapper.HttpContext, pluginConfig config.PluginConf
log.Debugf("[onHttpRequestHeader] provider=%s", activeProvider.GetProviderType())
// Disable the route re-calculation since the plugin may modify some headers related to the chosen route.
ctx.DisableReroute()
initContext(ctx)
rawPath := ctx.Path()
@@ -156,8 +162,6 @@ func onHttpRequestHeader(ctx wrapper.HttpContext, pluginConfig config.PluginConf
}
ctx.SetContext(provider.CtxKeyApiName, apiName)
// Disable the route re-calculation since the plugin may modify some headers related to the chosen route.
ctx.DisableReroute()
// Always remove the Accept-Encoding header to prevent the LLM from sending compressed responses,
// allowing plugins to inspect or modify the response correctly