Files
openclaw/src/auto-reply/reply/model-runtime-normalization.ts
T
Vito Cappello 47d37ddd54 fix: reduce reply delay when model policy is configured (#114117)
* fix: reuse model selection metadata snapshot

* test: cover concurrent model policy snapshot reuse

---------

Co-authored-by: VACInc <3279061+VACInc@users.noreply.github.com>
Co-authored-by: Peter Steinberger <steipete@gmail.com>
2026-07-26 21:39:19 -04:00

27 lines
1.1 KiB
TypeScript

/** Prepared plugin metadata handoff for runtime model normalization. */
import { normalizeModelRef } from "../../agents/model-selection.js";
import { RUNTIME_MODEL_VISIBILITY_NORMALIZATION } from "../../agents/model-visibility-policy.js";
import type { OpenClawConfig } from "../../config/types.openclaw.js";
import { getCurrentPluginMetadataSnapshot } from "../../plugins/current-plugin-metadata-snapshot.js";
export type RuntimeModelNormalization = NonNullable<Parameters<typeof normalizeModelRef>[2]>;
/** Carries the Gateway-owned metadata snapshot through one model-selection run. */
export function resolveRuntimeNormalization(cfg: OpenClawConfig): RuntimeModelNormalization {
return {
...RUNTIME_MODEL_VISIBILITY_NORMALIZATION,
manifestPlugins: getCurrentPluginMetadataSnapshot({
config: cfg,
allowWorkspaceScopedSnapshot: true,
})?.plugins,
};
}
export function normalizeRuntimeRef(
provider: string,
model: string,
normalization: RuntimeModelNormalization = RUNTIME_MODEL_VISIBILITY_NORMALIZATION,
) {
return normalizeModelRef(provider, model, normalization);
}