Skip to content

resolveConfig

resolveConfig<T>(ctx, gadgetName, config): T

Defined in: utils/config-resolver.ts:130

Bulk configuration resolution for subagent gadgets.

Takes a map of config keys to their resolution options and returns a fully resolved configuration object.

T extends Record<string, unknown>

ExecutionContext

ExecutionContext from gadget execution

string

Name of the subagent gadget (e.g., “BrowseWeb”)

{ [K in string | number | symbol]: ResolveValueOptions<T[K]> }

Map of config keys to resolution options

T

Fully resolved configuration object

// Before: 27 lines of manual fallback logic
const subagentConfig = ctx.subagentConfig?.Dhalsim ?? {};
const parentModel = ctx.agentConfig?.model;
const model = params.model ?? subagentConfig.model ?? parentModel ?? "sonnet";
const maxIterations = params.maxIterations ?? subagentConfig.maxIterations ?? 15;
const headless = params.headless ?? subagentConfig.headless ?? true;
// After: One function call
const { model, maxIterations, headless } = resolveConfig(ctx, "BrowseWeb", {
model: { runtime: params.model, subagentKey: "model", parentKey: "model", defaultValue: "sonnet", handleInherit: true },
maxIterations: { runtime: params.maxIterations, subagentKey: "maxIterations", defaultValue: 15 },
headless: { runtime: params.headless, subagentKey: "headless", defaultValue: true },
});