refactor: reuse model-id prefix helper for Gemini guard · openclaw/openclaw@0ec3b79
neeravmakwan
·
2026-04-25
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -14,7 +14,7 @@ import { resolveAgentExecutionContract, resolveSessionAgentIds } from "./agent-s
|
14 | 14 | * bare names. The adversarial review in #64227 flagged this as a quality |
15 | 15 | * gap on completion-gate criterion 1. |
16 | 16 | */ |
17 | | -function stripProviderPrefix(modelId: string): string { |
| 17 | +export function stripProviderPrefix(modelId: string): string { |
18 | 18 | const normalizedModelId = modelId.trim(); |
19 | 19 | const match = /^([^/:]+)[/:](.+)$/.exec(normalizedModelId); |
20 | 20 | return (match?.[2] ?? normalizedModelId).toLowerCase(); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -2,7 +2,10 @@ import type { AgentMessage } from "@mariozechner/pi-agent-core";
|
2 | 2 | import { isSilentReplyPayloadText, SILENT_REPLY_TOKEN } from "../../../auto-reply/tokens.js"; |
3 | 3 | import type { EmbeddedPiExecutionContract } from "../../../config/types.agent-defaults.js"; |
4 | 4 | import { normalizeLowercaseStringOrEmpty } from "../../../shared/string-coerce.js"; |
5 | | -import { isStrictAgenticSupportedProviderModel } from "../../execution-contract.js"; |
| 5 | +import { |
| 6 | +isStrictAgenticSupportedProviderModel, |
| 7 | +stripProviderPrefix, |
| 8 | +} from "../../execution-contract.js"; |
6 | 9 | import { isLikelyMutatingToolName } from "../../tool-mutation.js"; |
7 | 10 | import { assessLastAssistantMessage } from "../thinking.js"; |
8 | 11 | import type { EmbeddedRunLivenessState } from "../types.js"; |
@@ -83,7 +86,7 @@ const GEMINI_INCOMPLETE_TURN_PROVIDER_IDS = new Set([
|
83 | 86 | "google-antigravity", |
84 | 87 | "google-gemini-cli", |
85 | 88 | ]); |
86 | | -const GEMINI_INCOMPLETE_TURN_MODEL_ID_PATTERN = /^gemini(?:[.-]|$)/i; |
| 89 | +const GEMINI_INCOMPLETE_TURN_MODEL_ID_PATTERN = /^gemini(?:[.-]|$)/; |
87 | 90 | const DEFAULT_PLANNING_ONLY_RETRY_LIMIT = 1; |
88 | 91 | const STRICT_AGENTIC_PLANNING_ONLY_RETRY_LIMIT = 2; |
89 | 92 | // Allow one immediate continuation plus one follow-up continuation before |
@@ -407,12 +410,6 @@ function shouldApplyPlanningOnlyRetryGuard(params: {
|
407 | 410 | }); |
408 | 411 | } |
409 | 412 | |
410 | | -function stripProviderPrefix(modelId: string): string { |
411 | | -const normalizedModelId = modelId.trim(); |
412 | | -const match = /^([^/:]+)[/:](.+)$/.exec(normalizedModelId); |
413 | | -return (match?.[2] ?? normalizedModelId).toLowerCase(); |
414 | | -} |
415 | | - |
416 | 413 | function isIncompleteTurnRecoverySupportedProviderModel(params: { |
417 | 414 | provider?: string; |
418 | 415 | modelId?: string; |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。