mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-21 10:16:44 +00:00
* fix(agents): classify provider-native failover errors Co-authored-by: Altay <altay@hey.com> * fix(agents): scope provider failover codes * docs(changelog): credit provider failover fix * style(anthropic): format failover classifier * docs(changelog): defer release-owned entry --------- Co-authored-by: Pick-cat <266665499+Pick-cat@users.noreply.github.com> Co-authored-by: Altay <altay@hey.com> Co-authored-by: Peter Steinberger <steipete@gmail.com>
37 lines
1.5 KiB
TypeScript
37 lines
1.5 KiB
TypeScript
// Google provider module implements model/runtime integration.
|
|
import type {
|
|
ProviderDefaultThinkingPolicyContext,
|
|
ProviderThinkingProfile,
|
|
} from "openclaw/plugin-sdk/core";
|
|
import type { ProviderFailoverErrorContext } from "openclaw/plugin-sdk/plugin-entry";
|
|
import { buildProviderReplayFamilyHooks } from "openclaw/plugin-sdk/provider-model-shared";
|
|
import { buildProviderToolCompatFamilyHooks } from "openclaw/plugin-sdk/provider-tools";
|
|
import { resolveGoogleThinkingProfile } from "./provider-policy.js";
|
|
import { createGoogleThinkingStreamWrapper } from "./thinking-api.js";
|
|
|
|
// Google-family gRPC status codes stay with the shared Gemini provider hook.
|
|
function classifyGoogleFailoverCode(code: string | undefined) {
|
|
switch (code?.trim().toUpperCase()) {
|
|
case "UNAVAILABLE":
|
|
return "overloaded" as const;
|
|
case "DEADLINE_EXCEEDED":
|
|
return "timeout" as const;
|
|
case "INTERNAL":
|
|
return "server_error" as const;
|
|
default:
|
|
return undefined;
|
|
}
|
|
}
|
|
|
|
export const GOOGLE_GEMINI_PROVIDER_HOOKS = {
|
|
...buildProviderReplayFamilyHooks({
|
|
family: "google-gemini",
|
|
}),
|
|
...buildProviderToolCompatFamilyHooks("gemini"),
|
|
resolveThinkingProfile: (context: ProviderDefaultThinkingPolicyContext) =>
|
|
resolveGoogleThinkingProfile(context) satisfies ProviderThinkingProfile | undefined,
|
|
wrapStreamFn: createGoogleThinkingStreamWrapper,
|
|
classifyFailoverReason: ({ code }: ProviderFailoverErrorContext) =>
|
|
classifyGoogleFailoverCode(code),
|
|
};
|