fix: align scoped model parameter consumers

This commit is contained in:
Dallin Romney
2026-08-20 19:31:53 -07:00
parent 1e0f1dae2c
commit b1e97b235e
5 changed files with 51 additions and 21 deletions
+2 -2
View File
@@ -593,8 +593,8 @@ describe("openrouter provider hooks", () => {
},
} as never);
expect(contribution?.dynamicSuffix).toContain("Analysis models: google/gemini-3.5-flash.");
expect(contribution?.dynamicSuffix).not.toContain("deepseek/deepseek-v4-pro");
expect(contribution?.dynamicSuffix).toContain("Analysis models: deepseek/deepseek-v4-pro.");
expect(contribution?.dynamicSuffix).not.toContain("google/gemini-3.5-flash");
});
it("reads per-agent Fusion config from the canonical agent roster", async () => {
+16 -17
View File
@@ -149,27 +149,26 @@ function findConfiguredOpenRouterModelParams(
return undefined;
}
function resolveMergedOpenRouterPromptParams(
function resolveFusionExtraBody(
ctx: OpenRouterFusionPromptContext,
): Record<string, unknown> | undefined {
const agentConfig =
ctx.agentId && ctx.config ? resolveAgentConfig(ctx.config, ctx.agentId) : undefined;
const merged = {
...readRecord(ctx.config?.agents?.defaults?.params),
...findConfiguredOpenRouterModelParams(ctx.config?.agents?.defaults?.models, ctx.modelId),
...readRecord(agentConfig?.params),
...findConfiguredOpenRouterModelParams(agentConfig?.models, ctx.modelId),
};
return Object.keys(merged).length > 0 ? merged : undefined;
}
function resolveFusionExtraBody(
ctx: OpenRouterFusionPromptContext,
): Record<string, unknown> | undefined {
const params = resolveMergedOpenRouterPromptParams(ctx);
const rawExtraBody =
params && Object.hasOwn(params, "extra_body") ? params.extra_body : params?.extraBody;
return readRecord(rawExtraBody);
const sources = [
readRecord(ctx.config?.agents?.defaults?.params),
findConfiguredOpenRouterModelParams(ctx.config?.agents?.defaults?.models, ctx.modelId),
readRecord(agentConfig?.params),
findConfiguredOpenRouterModelParams(agentConfig?.models, ctx.modelId),
];
let effective: Record<string, unknown> | undefined;
for (const source of sources) {
const raw = source && Object.hasOwn(source, "extra_body") ? source.extra_body : source?.extraBody;
const candidate = readRecord(raw);
if (candidate) {
effective = candidate;
}
}
return effective;
}
function resolveOpenRouterFusionPromptContribution(
@@ -793,6 +793,7 @@ export async function runPreflightCompactionIfNeeded(params: {
cfg: params.cfg,
provider: params.followupRun.run.provider,
modelId: params.followupRun.run.model ?? params.defaultModel,
agentId: compactionAgentId,
});
const threshold = Math.max(
contextWindowTokens - reserveTokensFloor - softThresholdTokens,
+28
View File
@@ -69,6 +69,34 @@ function buildHostConfig(params: {
}
describe("Responses server compaction host/transport parity", () => {
it("uses the active agent-model compaction threshold", () => {
const modelRef = modelKey("openai", TEST_MODEL_ID);
const cfg: OpenClawConfig = {
agents: {
defaults: {
params: { responsesCompactThreshold: 120_000 },
},
entries: [
{
id: "audit",
models: {
[modelRef]: { params: { responsesCompactThreshold: 175_000 } },
},
},
],
},
};
expect(
resolveResponsesServerCompactionThreshold({
cfg,
provider: "openai",
modelId: TEST_MODEL_ID,
agentId: "audit",
}),
).toBe(175_000);
});
it.each([
{
name: "OpenAI default route without an authored base URL",
+4 -2
View File
@@ -46,6 +46,7 @@ export function resolveResponsesServerCompactionThreshold(params: {
cfg?: OpenClawConfig;
provider?: string;
modelId?: string;
agentId?: string;
}): number | undefined {
const provider = params.provider?.trim();
const modelId = params.modelId?.trim();
@@ -60,12 +61,13 @@ export function resolveResponsesServerCompactionThreshold(params: {
models: providerConfig?.models,
normalizeModelId,
}).get(normalizeModelId(modelId));
const { defaultParams, modelParams } = resolveModelExtraParamSources({
const { paramSources } = resolveModelExtraParamSources({
config: params.cfg,
provider,
modelId,
agentId: params.agentId,
});
const extraParams = { ...defaultParams, ...modelParams };
const extraParams = Object.assign({}, ...paramSources);
if (normalizedProvider === "anthropic") {
return resolveAnthropicServerCompactionPlan(
{