mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-25 23:47:20 +00:00
feat: add agents.defaults.params for global default provider params (#58548)
Allow setting provider params (e.g. cacheRetention) once at the agents.defaults level instead of repeating them per-model. The merge order is now: defaults.params -> defaults.models[key].params -> list[agentId].params. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -82,6 +82,7 @@ export function resolveExtraParams(params: {
|
||||
modelId: string;
|
||||
agentId?: string;
|
||||
}): Record<string, unknown> | undefined {
|
||||
const defaultParams = params.cfg?.agents?.defaults?.params ?? undefined;
|
||||
const modelKey = `${params.provider}/${params.modelId}`;
|
||||
const modelConfig = params.cfg?.agents?.defaults?.models?.[modelKey];
|
||||
const globalParams = modelConfig?.params ? { ...modelConfig.params } : undefined;
|
||||
@@ -90,13 +91,13 @@ export function resolveExtraParams(params: {
|
||||
? params.cfg.agents.list.find((agent) => agent.id === params.agentId)?.params
|
||||
: undefined;
|
||||
|
||||
if (!globalParams && !agentParams) {
|
||||
if (!defaultParams && !globalParams && !agentParams) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const merged = Object.assign({}, globalParams, agentParams);
|
||||
const merged = Object.assign({}, defaultParams, globalParams, agentParams);
|
||||
const resolvedParallelToolCalls = resolveAliasedParamValue(
|
||||
[globalParams, agentParams],
|
||||
[defaultParams, globalParams, agentParams],
|
||||
"parallel_tool_calls",
|
||||
"parallelToolCalls",
|
||||
);
|
||||
|
||||
@@ -118,6 +118,8 @@ export type CliBackendConfig = {
|
||||
};
|
||||
|
||||
export type AgentDefaultsConfig = {
|
||||
/** Global default provider params applied to all models before per-model and per-agent overrides. */
|
||||
params?: Record<string, unknown>;
|
||||
/** Primary model and fallbacks (provider/model). Accepts string or {primary,fallbacks}. */
|
||||
model?: AgentModelConfig;
|
||||
/** Optional image-capable model and fallbacks (provider/model). Accepts string or {primary,fallbacks}. */
|
||||
|
||||
@@ -16,6 +16,8 @@ import {
|
||||
|
||||
export const AgentDefaultsSchema = z
|
||||
.object({
|
||||
/** Global default provider params applied to all models before per-model and per-agent overrides. */
|
||||
params: z.record(z.string(), z.unknown()).optional(),
|
||||
model: AgentModelSchema.optional(),
|
||||
imageModel: AgentModelSchema.optional(),
|
||||
imageGenerationModel: AgentModelSchema.optional(),
|
||||
|
||||
Reference in New Issue
Block a user