feat: assorted small changes (#244)

Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
Kian Jones
2025-12-16 17:20:31 -05:00
committed by GitHub
parent 562246d022
commit 322ab19f11
2 changed files with 35 additions and 13 deletions

View File

@@ -259,17 +259,25 @@ export async function handleHeadlessCommand(
// If resuming and a model or system prompt was specified, apply those changes
if (isResumingAgent && (model || specifiedSystem)) {
if (model) {
const { updateAgentLLMConfig } = await import("./agent/modify");
const { resolveModel } = await import("./agent/model");
const modelHandle = resolveModel(model);
if (!modelHandle) {
console.error(`Error: Invalid model "${model}"`);
process.exit(1);
}
const updateArgs = getModelUpdateArgs(model);
await updateAgentLLMConfig(agent.id, modelHandle, updateArgs);
// Refresh agent state after model update
agent = await client.agents.retrieve(agent.id);
// Optimization: Skip update if agent is already using the specified model
const currentModel = agent.llm_config?.model;
const currentEndpointType = agent.llm_config?.model_endpoint_type;
const currentHandle = `${currentEndpointType}/${currentModel}`;
if (currentHandle !== modelHandle) {
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);
}
}
if (specifiedSystem) {

View File

@@ -200,6 +200,13 @@ async function main() {
const fromAfFile = values["from-af"] as string | undefined;
const isHeadless = values.prompt || values.run || !process.stdin.isTTY;
// Fail if an unknown command/argument is passed (and we're not in headless mode where it might be a prompt)
if (command && !isHeadless) {
console.error(`Error: Unknown command or argument "${command}"`);
console.error("Run 'letta --help' for usage information.");
process.exit(1);
}
// --init-blocks only makes sense when creating a brand new agent
if (initBlocksRaw && !forceNew) {
console.error(
@@ -785,19 +792,26 @@ async function main() {
// If resuming and a model or system prompt was specified, apply those changes
if (resuming && (model || system)) {
if (model) {
const { updateAgentLLMConfig } = await import("./agent/modify");
const { getModelUpdateArgs, resolveModel } = await import(
"./agent/model"
);
const { resolveModel } = await import("./agent/model");
const modelHandle = resolveModel(model);
if (!modelHandle) {
console.error(`Error: Invalid model "${model}"`);
process.exit(1);
}
const updateArgs = getModelUpdateArgs(model);
await updateAgentLLMConfig(agent.id, modelHandle, updateArgs);
// Refresh agent state after model update
agent = await client.agents.retrieve(agent.id);
// Optimization: Skip update if agent is already using the specified model
const currentModel = agent.llm_config?.model;
const currentEndpointType = agent.llm_config?.model_endpoint_type;
const currentHandle = `${currentEndpointType}/${currentModel}`;
if (currentHandle !== modelHandle) {
const { updateAgentLLMConfig } = await import("./agent/modify");
const { getModelUpdateArgs } = await import("./agent/model");
const updateArgs = getModelUpdateArgs(model);
await updateAgentLLMConfig(agent.id, modelHandle, updateArgs);
// Refresh agent state after model update
agent = await client.agents.retrieve(agent.id);
}
}
if (system) {