mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 07:31:24 +00:00
feat(agents): add per-agent stream params overrides for cache tuning (#17470) (thanks @rrenamed)
This commit is contained in:
@@ -26,6 +26,7 @@ Docs: https://docs.openclaw.ai
|
|||||||
- Agents/Compaction: pass `agentDir` into manual `/compact` command runs so compaction auth/profile resolution stays scoped to the active agent. (#24133) thanks @Glucksberg.
|
- Agents/Compaction: pass `agentDir` into manual `/compact` command runs so compaction auth/profile resolution stays scoped to the active agent. (#24133) thanks @Glucksberg.
|
||||||
- Agents/Compaction: pass model metadata through the embedded runtime so safeguard summarization can run when `ctx.model` is unavailable, avoiding repeated `"Summary unavailable due to context limits"` fallback summaries. (#3479) Thanks @battman21, @hanxiao and @vincentkoc.
|
- Agents/Compaction: pass model metadata through the embedded runtime so safeguard summarization can run when `ctx.model` is unavailable, avoiding repeated `"Summary unavailable due to context limits"` fallback summaries. (#3479) Thanks @battman21, @hanxiao and @vincentkoc.
|
||||||
- Agents/Compaction: cancel safeguard compaction when summary generation cannot run (missing model/API key or summarization failure), preserving history instead of truncating to fallback `"Summary unavailable"` text. (#10711) Thanks @DukeDeSouth and @vincentkoc.
|
- Agents/Compaction: cancel safeguard compaction when summary generation cannot run (missing model/API key or summarization failure), preserving history instead of truncating to fallback `"Summary unavailable"` text. (#10711) Thanks @DukeDeSouth and @vincentkoc.
|
||||||
|
- Agents/Config: support per-agent `params` overrides merged on top of model defaults (including `cacheRetention`) so mixed-traffic agents can tune cache behavior independently. (#17470, #17112) Thanks @rrenamed.
|
||||||
- Agents/Overflow: detect additional provider context-overflow error shapes (including `input length` + `max_tokens` exceed-context variants) so failures route through compaction/recovery paths instead of leaking raw provider errors to users. (#9951) Thanks @echoVic and @Glucksberg.
|
- Agents/Overflow: detect additional provider context-overflow error shapes (including `input length` + `max_tokens` exceed-context variants) so failures route through compaction/recovery paths instead of leaking raw provider errors to users. (#9951) Thanks @echoVic and @Glucksberg.
|
||||||
- Agents/Overflow: add Chinese context-overflow pattern detection in `isContextOverflowError` so localized provider errors route through overflow recovery paths. (#22855) Thanks @Clawborn.
|
- Agents/Overflow: add Chinese context-overflow pattern detection in `isContextOverflowError` so localized provider errors route through overflow recovery paths. (#22855) Thanks @Clawborn.
|
||||||
- Agents/Failover: treat HTTP 502/503/504 errors as failover-eligible transient timeouts so fallback chains can switch providers/models during upstream outages instead of retrying the same failing target. (#20999) Thanks @taw0002 and @vincentkoc.
|
- Agents/Failover: treat HTTP 502/503/504 errors as failover-eligible transient timeouts so fallback chains can switch providers/models during upstream outages instead of retrying the same failing target. (#20999) Thanks @taw0002 and @vincentkoc.
|
||||||
|
|||||||
@@ -61,6 +61,79 @@ describe("resolveExtraParams", () => {
|
|||||||
|
|
||||||
expect(result).toBeUndefined();
|
expect(result).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("returns per-agent params when agentId matches", () => {
|
||||||
|
const result = resolveExtraParams({
|
||||||
|
cfg: {
|
||||||
|
agents: {
|
||||||
|
list: [
|
||||||
|
{
|
||||||
|
id: "risk-reviewer",
|
||||||
|
params: { cacheRetention: "none" },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
provider: "anthropic",
|
||||||
|
modelId: "claude-opus-4-6",
|
||||||
|
agentId: "risk-reviewer",
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(result).toEqual({ cacheRetention: "none" });
|
||||||
|
});
|
||||||
|
|
||||||
|
it("merges per-agent params over global model defaults", () => {
|
||||||
|
const result = resolveExtraParams({
|
||||||
|
cfg: {
|
||||||
|
agents: {
|
||||||
|
defaults: {
|
||||||
|
models: {
|
||||||
|
"anthropic/claude-opus-4-6": {
|
||||||
|
params: {
|
||||||
|
temperature: 0.5,
|
||||||
|
cacheRetention: "long",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
list: [
|
||||||
|
{
|
||||||
|
id: "risk-reviewer",
|
||||||
|
params: { cacheRetention: "none" },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
provider: "anthropic",
|
||||||
|
modelId: "claude-opus-4-6",
|
||||||
|
agentId: "risk-reviewer",
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(result).toEqual({
|
||||||
|
temperature: 0.5,
|
||||||
|
cacheRetention: "none",
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("ignores per-agent params when agentId does not match", () => {
|
||||||
|
const result = resolveExtraParams({
|
||||||
|
cfg: {
|
||||||
|
agents: {
|
||||||
|
list: [
|
||||||
|
{
|
||||||
|
id: "risk-reviewer",
|
||||||
|
params: { cacheRetention: "none" },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
provider: "anthropic",
|
||||||
|
modelId: "claude-opus-4-6",
|
||||||
|
agentId: "main",
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(result).toBeUndefined();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("applyExtraParamsToAgent", () => {
|
describe("applyExtraParamsToAgent", () => {
|
||||||
|
|||||||
@@ -26,10 +26,21 @@ export function resolveExtraParams(params: {
|
|||||||
cfg: OpenClawConfig | undefined;
|
cfg: OpenClawConfig | undefined;
|
||||||
provider: string;
|
provider: string;
|
||||||
modelId: string;
|
modelId: string;
|
||||||
|
agentId?: string;
|
||||||
}): Record<string, unknown> | undefined {
|
}): Record<string, unknown> | undefined {
|
||||||
const modelKey = `${params.provider}/${params.modelId}`;
|
const modelKey = `${params.provider}/${params.modelId}`;
|
||||||
const modelConfig = params.cfg?.agents?.defaults?.models?.[modelKey];
|
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";
|
type CacheRetention = "none" | "short" | "long";
|
||||||
@@ -496,11 +507,13 @@ export function applyExtraParamsToAgent(
|
|||||||
modelId: string,
|
modelId: string,
|
||||||
extraParamsOverride?: Record<string, unknown>,
|
extraParamsOverride?: Record<string, unknown>,
|
||||||
thinkingLevel?: ThinkLevel,
|
thinkingLevel?: ThinkLevel,
|
||||||
|
agentId?: string,
|
||||||
): void {
|
): void {
|
||||||
const extraParams = resolveExtraParams({
|
const extraParams = resolveExtraParams({
|
||||||
cfg,
|
cfg,
|
||||||
provider,
|
provider,
|
||||||
modelId,
|
modelId,
|
||||||
|
agentId,
|
||||||
});
|
});
|
||||||
const override =
|
const override =
|
||||||
extraParamsOverride && Object.keys(extraParamsOverride).length > 0
|
extraParamsOverride && Object.keys(extraParamsOverride).length > 0
|
||||||
|
|||||||
@@ -736,6 +736,7 @@ export async function runEmbeddedAttempt(
|
|||||||
params.modelId,
|
params.modelId,
|
||||||
params.streamParams,
|
params.streamParams,
|
||||||
params.thinkLevel,
|
params.thinkLevel,
|
||||||
|
sessionAgentId,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (cacheTrace) {
|
if (cacheTrace) {
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ export type AgentConfig = {
|
|||||||
};
|
};
|
||||||
/** Optional per-agent sandbox overrides. */
|
/** Optional per-agent sandbox overrides. */
|
||||||
sandbox?: AgentSandboxConfig;
|
sandbox?: AgentSandboxConfig;
|
||||||
|
/** Optional per-agent stream params (e.g. cacheRetention, temperature). */
|
||||||
|
params?: Record<string, unknown>;
|
||||||
tools?: AgentToolsConfig;
|
tools?: AgentToolsConfig;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user