mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-27 21:42:06 +00:00
fix: preserve bedrock plugin region
This commit is contained in:
@@ -478,6 +478,36 @@ describe("amazon-bedrock provider plugin", () => {
|
||||
expect(result).not.toHaveProperty("temperature");
|
||||
});
|
||||
|
||||
it("uses plugin discovery region when provider URLs do not encode one", async () => {
|
||||
const provider = await registerSingleProviderPlugin(amazonBedrockPlugin);
|
||||
const wrapped = provider.wrapStreamFn?.({
|
||||
provider: "amazon-bedrock",
|
||||
modelId: NON_ANTHROPIC_MODEL,
|
||||
model: {
|
||||
api: "bedrock-converse-stream",
|
||||
provider: "amazon-bedrock",
|
||||
id: NON_ANTHROPIC_MODEL,
|
||||
baseUrl: "https://bedrock-runtime.internal.example",
|
||||
},
|
||||
config: {
|
||||
plugins: {
|
||||
entries: {
|
||||
"amazon-bedrock": {
|
||||
config: { discovery: { region: "eu-central-1" } },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
streamFn: spyStreamFn,
|
||||
} as never);
|
||||
|
||||
const result = wrapped?.(MODEL_DESCRIPTOR, { messages: [] } as never, {}) as
|
||||
| Record<string, unknown>
|
||||
| undefined;
|
||||
|
||||
expectWrappedResultFields(result, { region: "eu-central-1" });
|
||||
});
|
||||
|
||||
it("omits temperature for non-US Bedrock Opus 4.7 regional profiles", async () => {
|
||||
const provider = await registerSingleProviderPlugin(amazonBedrockPlugin);
|
||||
const wrapped = provider.wrapStreamFn?.({
|
||||
|
||||
@@ -493,7 +493,8 @@ export function registerAmazonBedrockPlugin(api: OpenClawPluginApi): void {
|
||||
resolveConfigApiKey: ({ env }) => resolveBedrockConfigApiKey(env),
|
||||
...anthropicByModelReplayHooks,
|
||||
wrapStreamFn: ({ modelId, config, model, streamFn, thinkingLevel, extraParams }) => {
|
||||
const currentGuardrail = resolveCurrentPluginConfig(config)?.guardrail;
|
||||
const currentPluginConfig = resolveCurrentPluginConfig(config);
|
||||
const currentGuardrail = currentPluginConfig?.guardrail;
|
||||
let wrapped =
|
||||
(currentGuardrail?.guardrailIdentifier && currentGuardrail?.guardrailVersion
|
||||
? createGuardrailWrapStreamFn(baseWrapStreamFn, currentGuardrail)({ modelId, streamFn })
|
||||
@@ -506,7 +507,10 @@ export function registerAmazonBedrockPlugin(api: OpenClawPluginApi): void {
|
||||
wrapped = createBedrockServiceTierWrapper(wrapped, serviceTier);
|
||||
}
|
||||
|
||||
const region = resolveBedrockRegion(config) ?? extractRegionFromBaseUrl(model?.baseUrl);
|
||||
const region =
|
||||
resolveBedrockRegion(config) ??
|
||||
extractRegionFromBaseUrl(model?.baseUrl) ??
|
||||
currentPluginConfig?.discovery?.region;
|
||||
const mayNeedCacheInjection =
|
||||
isBedrockAppInferenceProfile(modelId) && !sharedRuntimeWouldInjectCachePoints(modelId);
|
||||
const shouldOmitTemperature = isOpus47BedrockModelRef(modelId);
|
||||
|
||||
Reference in New Issue
Block a user