refactor: hoist resume model-refresh imports (#1093)
Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
@@ -25,7 +25,12 @@ import { createAgent } from "./agent/create";
|
|||||||
import { handleListMessages } from "./agent/listMessagesHandler";
|
import { handleListMessages } from "./agent/listMessagesHandler";
|
||||||
import { ISOLATED_BLOCK_LABELS } from "./agent/memory";
|
import { ISOLATED_BLOCK_LABELS } from "./agent/memory";
|
||||||
import { getStreamToolContextId, sendMessageStream } from "./agent/message";
|
import { getStreamToolContextId, sendMessageStream } from "./agent/message";
|
||||||
import { getModelUpdateArgs } from "./agent/model";
|
import {
|
||||||
|
getModelPresetUpdateForAgent,
|
||||||
|
getModelUpdateArgs,
|
||||||
|
resolveModel,
|
||||||
|
} from "./agent/model";
|
||||||
|
import { updateAgentLLMConfig, updateAgentSystemPrompt } from "./agent/modify";
|
||||||
import { resolveSkillSourcesSelection } from "./agent/skillSources";
|
import { resolveSkillSourcesSelection } from "./agent/skillSources";
|
||||||
import type { SkillSource } from "./agent/skills";
|
import type { SkillSource } from "./agent/skills";
|
||||||
import { SessionStats } from "./agent/stats";
|
import { SessionStats } from "./agent/stats";
|
||||||
@@ -898,10 +903,7 @@ export async function handleHeadlessCommand(
|
|||||||
// preset-derived fields in sync, then apply optional command-line
|
// preset-derived fields in sync, then apply optional command-line
|
||||||
// overrides (model/system prompt).
|
// overrides (model/system prompt).
|
||||||
if (isResumingAgent) {
|
if (isResumingAgent) {
|
||||||
const { updateAgentLLMConfig } = await import("./agent/modify");
|
|
||||||
|
|
||||||
if (model) {
|
if (model) {
|
||||||
const { resolveModel } = await import("./agent/model");
|
|
||||||
const modelHandle = resolveModel(model);
|
const modelHandle = resolveModel(model);
|
||||||
if (typeof modelHandle !== "string") {
|
if (typeof modelHandle !== "string") {
|
||||||
console.error(`Error: Invalid model "${model}"`);
|
console.error(`Error: Invalid model "${model}"`);
|
||||||
@@ -915,7 +917,6 @@ export async function handleHeadlessCommand(
|
|||||||
// Refresh agent state after model update
|
// Refresh agent state after model update
|
||||||
agent = await client.agents.retrieve(agent.id);
|
agent = await client.agents.retrieve(agent.id);
|
||||||
} else {
|
} else {
|
||||||
const { getModelPresetUpdateForAgent } = await import("./agent/model");
|
|
||||||
const presetRefresh = getModelPresetUpdateForAgent(agent);
|
const presetRefresh = getModelPresetUpdateForAgent(agent);
|
||||||
if (presetRefresh) {
|
if (presetRefresh) {
|
||||||
// Resume preset refresh is intentionally scoped for now.
|
// Resume preset refresh is intentionally scoped for now.
|
||||||
@@ -947,7 +948,6 @@ export async function handleHeadlessCommand(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (systemPromptPreset) {
|
if (systemPromptPreset) {
|
||||||
const { updateAgentSystemPrompt } = await import("./agent/modify");
|
|
||||||
const result = await updateAgentSystemPrompt(
|
const result = await updateAgentSystemPrompt(
|
||||||
agent.id,
|
agent.id,
|
||||||
systemPromptPreset,
|
systemPromptPreset,
|
||||||
|
|||||||
16
src/index.ts
16
src/index.ts
@@ -12,6 +12,12 @@ import {
|
|||||||
import type { AgentProvenance } from "./agent/create";
|
import type { AgentProvenance } from "./agent/create";
|
||||||
import { getLettaCodeHeaders } from "./agent/http-headers";
|
import { getLettaCodeHeaders } from "./agent/http-headers";
|
||||||
import { ISOLATED_BLOCK_LABELS } from "./agent/memory";
|
import { ISOLATED_BLOCK_LABELS } from "./agent/memory";
|
||||||
|
import {
|
||||||
|
getModelPresetUpdateForAgent,
|
||||||
|
getModelUpdateArgs,
|
||||||
|
resolveModel,
|
||||||
|
} from "./agent/model";
|
||||||
|
import { updateAgentLLMConfig, updateAgentSystemPrompt } from "./agent/modify";
|
||||||
import { resolveSkillSourcesSelection } from "./agent/skillSources";
|
import { resolveSkillSourcesSelection } from "./agent/skillSources";
|
||||||
import { LETTA_CLOUD_API_URL } from "./auth/oauth";
|
import { LETTA_CLOUD_API_URL } from "./auth/oauth";
|
||||||
import { ConversationSelector } from "./cli/components/ConversationSelector";
|
import { ConversationSelector } from "./cli/components/ConversationSelector";
|
||||||
@@ -1561,7 +1567,6 @@ async function main(): Promise<void> {
|
|||||||
|
|
||||||
setLoadingState("initializing");
|
setLoadingState("initializing");
|
||||||
const { createAgent } = await import("./agent/create");
|
const { createAgent } = await import("./agent/create");
|
||||||
const { getModelUpdateArgs } = await import("./agent/model");
|
|
||||||
|
|
||||||
let agent: AgentState | null = null;
|
let agent: AgentState | null = null;
|
||||||
|
|
||||||
@@ -1793,12 +1798,7 @@ async function main(): Promise<void> {
|
|||||||
// preset-derived fields in sync, then apply optional command-line
|
// preset-derived fields in sync, then apply optional command-line
|
||||||
// overrides (model/system prompt).
|
// overrides (model/system prompt).
|
||||||
if (resuming) {
|
if (resuming) {
|
||||||
const { updateAgentLLMConfig } = await import("./agent/modify");
|
|
||||||
|
|
||||||
if (model) {
|
if (model) {
|
||||||
const { resolveModel, getModelUpdateArgs } = await import(
|
|
||||||
"./agent/model"
|
|
||||||
);
|
|
||||||
const modelHandle = resolveModel(model);
|
const modelHandle = resolveModel(model);
|
||||||
if (!modelHandle) {
|
if (!modelHandle) {
|
||||||
console.error(`Error: Invalid model "${model}"`);
|
console.error(`Error: Invalid model "${model}"`);
|
||||||
@@ -1812,9 +1812,6 @@ async function main(): Promise<void> {
|
|||||||
// Refresh agent state after model update
|
// Refresh agent state after model update
|
||||||
agent = await client.agents.retrieve(agent.id);
|
agent = await client.agents.retrieve(agent.id);
|
||||||
} else {
|
} else {
|
||||||
const { getModelPresetUpdateForAgent } = await import(
|
|
||||||
"./agent/model"
|
|
||||||
);
|
|
||||||
const presetRefresh = getModelPresetUpdateForAgent(agent);
|
const presetRefresh = getModelPresetUpdateForAgent(agent);
|
||||||
if (presetRefresh) {
|
if (presetRefresh) {
|
||||||
// Resume preset refresh is intentionally scoped for now.
|
// Resume preset refresh is intentionally scoped for now.
|
||||||
@@ -1851,7 +1848,6 @@ async function main(): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (systemPromptPreset) {
|
if (systemPromptPreset) {
|
||||||
const { updateAgentSystemPrompt } = await import("./agent/modify");
|
|
||||||
const result = await updateAgentSystemPrompt(
|
const result = await updateAgentSystemPrompt(
|
||||||
agent.id,
|
agent.id,
|
||||||
systemPromptPreset,
|
systemPromptPreset,
|
||||||
|
|||||||
Reference in New Issue
Block a user