feat(agents): add per-agent stream params overrides for cache tuning (#17470) (thanks @rrenamed)

This commit is contained in:
Peter Steinberger
2026-02-23 18:19:08 +00:00
parent be6f0b8c84
commit 160bd61fff
5 changed files with 91 additions and 1 deletions

View File

@@ -26,10 +26,21 @@ export function resolveExtraParams(params: {
cfg: OpenClawConfig | undefined;
provider: string;
modelId: string;
agentId?: string;
}): Record<string, unknown> | undefined {
const modelKey = `${params.provider}/${params.modelId}`;
const modelConfig = params.cfg?.agents?.defaults?.models?.[modelKey];
return modelConfig?.params ? { ...modelConfig.params } : undefined;
const globalParams = modelConfig?.params ? { ...modelConfig.params } : undefined;
const agentParams =
params.agentId && params.cfg?.agents?.list
? params.cfg.agents.list.find((agent) => agent.id === params.agentId)?.params
: undefined;
if (!globalParams && !agentParams) {
return undefined;
}
return Object.assign({}, globalParams, agentParams);
}
type CacheRetention = "none" | "short" | "long";
@@ -496,11 +507,13 @@ export function applyExtraParamsToAgent(
modelId: string,
extraParamsOverride?: Record<string, unknown>,
thinkingLevel?: ThinkLevel,
agentId?: string,
): void {
const extraParams = resolveExtraParams({
cfg,
provider,
modelId,
agentId,
});
const override =
extraParamsOverride && Object.keys(extraParamsOverride).length > 0

View File

@@ -736,6 +736,7 @@ export async function runEmbeddedAttempt(
params.modelId,
params.streamParams,
params.thinkLevel,
sessionAgentId,
);
if (cacheTrace) {