fix: refresh model preset settings on resume (#1052)
Co-authored-by: Letta <noreply@letta.com> Co-authored-by: letta-code <248085862+letta-code@users.noreply.github.com> Co-authored-by: jnjpng <jnjpng@users.noreply.github.com>
This commit is contained in:
@@ -878,23 +878,56 @@ export async function handleHeadlessCommand(
|
||||
(!forceNew && !fromAfFile)
|
||||
);
|
||||
|
||||
// If resuming and a model or system prompt was specified, apply those changes
|
||||
if (isResumingAgent && (model || systemPromptPreset)) {
|
||||
// If resuming, always refresh model settings from presets to keep
|
||||
// preset-derived fields in sync, then apply optional command-line
|
||||
// overrides (model/system prompt).
|
||||
if (isResumingAgent) {
|
||||
const { updateAgentLLMConfig } = await import("./agent/modify");
|
||||
|
||||
if (model) {
|
||||
const { resolveModel } = await import("./agent/model");
|
||||
const modelHandle = resolveModel(model);
|
||||
if (!modelHandle) {
|
||||
if (typeof modelHandle !== "string") {
|
||||
console.error(`Error: Invalid model "${model}"`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Always apply model update - different model IDs can share the same
|
||||
// handle but have different settings (e.g., gpt-5.2-medium vs gpt-5.2-xhigh)
|
||||
const { updateAgentLLMConfig } = await import("./agent/modify");
|
||||
const updateArgs = getModelUpdateArgs(model);
|
||||
await updateAgentLLMConfig(agent.id, modelHandle, updateArgs);
|
||||
// Refresh agent state after model update
|
||||
agent = await client.agents.retrieve(agent.id);
|
||||
} else {
|
||||
const { getModelPresetUpdateForAgent } = await import("./agent/model");
|
||||
const presetRefresh = getModelPresetUpdateForAgent(agent);
|
||||
if (presetRefresh) {
|
||||
// Resume preset refresh is intentionally scoped for now.
|
||||
// We only force-refresh max_output_tokens + parallel_tool_calls.
|
||||
// Other preset fields available in models.json (for example:
|
||||
// context_window, reasoning_effort, enable_reasoner,
|
||||
// max_reasoning_tokens, verbosity, temperature,
|
||||
// thinking_budget) are intentionally not auto-applied yet.
|
||||
const resumeRefreshUpdateArgs: Record<string, unknown> = {};
|
||||
if (typeof presetRefresh.updateArgs.max_output_tokens === "number") {
|
||||
resumeRefreshUpdateArgs.max_output_tokens =
|
||||
presetRefresh.updateArgs.max_output_tokens;
|
||||
}
|
||||
if (typeof presetRefresh.updateArgs.parallel_tool_calls === "boolean") {
|
||||
resumeRefreshUpdateArgs.parallel_tool_calls =
|
||||
presetRefresh.updateArgs.parallel_tool_calls;
|
||||
}
|
||||
|
||||
if (Object.keys(resumeRefreshUpdateArgs).length > 0) {
|
||||
await updateAgentLLMConfig(
|
||||
agent.id,
|
||||
presetRefresh.modelHandle,
|
||||
resumeRefreshUpdateArgs,
|
||||
);
|
||||
// Refresh agent state after model update
|
||||
agent = await client.agents.retrieve(agent.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (systemPromptPreset) {
|
||||
|
||||
Reference in New Issue
Block a user