Files
openclaw/src/config/materialize.ts
Jason 53bd718a1a fix(cli): avoid model warmup for message actions (#76312)
Summary:
- The PR skips eager context-window warmup for `openclaw message`, forwards Discord/Telegram execution-mode de ... reuses caller-owned manifest metadata during config materialization, and adds tests plus a changelog entry.
- Reproducibility: yes. Source inspection on current main shows `openclaw message` is still eligible for eager context-window warmup and the Discord/Telegram wrappers still drop the gateway execution-mode declarations.

Automerge notes:
- PR branch already contained follow-up commit before automerge: fix: type message action routing fallbacks
- PR branch already contained follow-up commit before automerge: docs: credit message latency fix contributor

Validation:
- ClawSweeper review passed for head 9606bb27d5.
- Required merge gates passed before the squash merge.

Prepared head SHA: 9606bb27d5
Review: https://github.com/openclaw/openclaw/pull/76312#issuecomment-4364958708

Co-authored-by: FullerStackDev <263060202+fuller-stack-dev@users.noreply.github.com>
2026-05-03 01:26:00 +00:00

80 lines
2.5 KiB
TypeScript

import type { PluginManifestRegistry } from "../plugins/manifest-registry.js";
import {
applyCompactionDefaults,
applyContextPruningDefaults,
applyAgentDefaults,
applyLoggingDefaults,
applyMessageDefaults,
applyModelDefaults,
applySessionDefaults,
applyTalkConfigNormalization,
} from "./defaults.js";
import { normalizeExecSafeBinProfilesInConfig } from "./normalize-exec-safe-bin.js";
import { normalizeConfigPaths } from "./normalize-paths.js";
import type { OpenClawConfig, ResolvedSourceConfig, RuntimeConfig } from "./types.js";
type ConfigMaterializationMode = "load" | "missing" | "snapshot";
type MaterializationProfile = {
includeCompactionDefaults: boolean;
includeContextPruningDefaults: boolean;
includeLoggingDefaults: boolean;
normalizePaths: boolean;
};
const MATERIALIZATION_PROFILES: Record<ConfigMaterializationMode, MaterializationProfile> = {
load: {
includeCompactionDefaults: true,
includeContextPruningDefaults: true,
includeLoggingDefaults: true,
normalizePaths: true,
},
missing: {
includeCompactionDefaults: true,
includeContextPruningDefaults: true,
includeLoggingDefaults: false,
normalizePaths: false,
},
snapshot: {
includeCompactionDefaults: false,
includeContextPruningDefaults: false,
includeLoggingDefaults: true,
normalizePaths: true,
},
};
export function asResolvedSourceConfig(config: OpenClawConfig): ResolvedSourceConfig {
return config as ResolvedSourceConfig;
}
export function asRuntimeConfig(config: OpenClawConfig): RuntimeConfig {
return config as RuntimeConfig;
}
export function materializeRuntimeConfig(
config: OpenClawConfig,
mode: ConfigMaterializationMode,
options: { manifestRegistry?: Pick<PluginManifestRegistry, "plugins"> } = {},
): RuntimeConfig {
const profile = MATERIALIZATION_PROFILES[mode];
let next = applyMessageDefaults(config);
if (profile.includeLoggingDefaults) {
next = applyLoggingDefaults(next);
}
next = applySessionDefaults(next);
next = applyAgentDefaults(next);
if (profile.includeContextPruningDefaults) {
next = applyContextPruningDefaults(next, { manifestRegistry: options.manifestRegistry });
}
if (profile.includeCompactionDefaults) {
next = applyCompactionDefaults(next);
}
next = applyModelDefaults(next, { manifestRegistry: options.manifestRegistry });
next = applyTalkConfigNormalization(next);
if (profile.normalizePaths) {
normalizeConfigPaths(next);
}
normalizeExecSafeBinProfilesInConfig(next);
return asRuntimeConfig(next);
}