fix: show model selector on self-hosted when default model unavailable (#737)
This commit is contained in:
@@ -12,6 +12,7 @@ import { getClient } from "./client";
|
||||
import { getDefaultMemoryBlocks } from "./memory";
|
||||
import {
|
||||
formatAvailableModels,
|
||||
getDefaultModel,
|
||||
getModelUpdateArgs,
|
||||
resolveModel,
|
||||
} from "./model";
|
||||
@@ -120,8 +121,8 @@ export async function createAgent(
|
||||
}
|
||||
modelHandle = resolved;
|
||||
} else {
|
||||
// Use default model
|
||||
modelHandle = "anthropic/claude-sonnet-4-5-20250929";
|
||||
// Use default model from models.json
|
||||
modelHandle = getDefaultModel();
|
||||
}
|
||||
|
||||
const client = await getClient();
|
||||
|
||||
@@ -305,10 +305,6 @@ function ProfileSelectionUI({
|
||||
<Text bold color={colors.selector.title}>
|
||||
Select a model
|
||||
</Text>
|
||||
<Text dimColor>
|
||||
The default model ({defaultModelHandle || "unknown"}) is not
|
||||
available on this server.
|
||||
</Text>
|
||||
|
||||
{showModelSearch && (
|
||||
<Box>
|
||||
|
||||
19
src/index.ts
19
src/index.ts
@@ -1094,6 +1094,9 @@ async function main(): Promise<void> {
|
||||
LETTA_CLOUD_API_URL;
|
||||
const isSelfHosted = !baseURL.includes("api.letta.com");
|
||||
|
||||
// Track whether we need model picker (for skipping ensureDefaultAgents)
|
||||
let needsModelPicker = false;
|
||||
|
||||
if (isSelfHosted) {
|
||||
setSelfHostedBaseUrl(baseURL);
|
||||
try {
|
||||
@@ -1108,6 +1111,7 @@ async function main(): Promise<void> {
|
||||
// Only set if default model isn't available
|
||||
if (!handles.includes(defaultModel)) {
|
||||
setAvailableServerModels(handles);
|
||||
needsModelPicker = true;
|
||||
}
|
||||
} catch {
|
||||
// Ignore errors - will fail naturally during agent creation if needed
|
||||
@@ -1268,10 +1272,15 @@ async function main(): Promise<void> {
|
||||
const wouldShowSelector =
|
||||
!localSettings.lastAgent && !forceNew && !agentIdArg && !fromAfFile;
|
||||
|
||||
if (wouldShowSelector && globalPinned.length === 0) {
|
||||
if (
|
||||
wouldShowSelector &&
|
||||
globalPinned.length === 0 &&
|
||||
!needsModelPicker
|
||||
) {
|
||||
// New user with no pinned agents - create a fresh Memo agent
|
||||
// NOTE: Always creates a new agent (no server-side tag lookup) to avoid
|
||||
// picking up agents created by other users on shared orgs.
|
||||
// Skip if needsModelPicker is true - let user select a model first.
|
||||
const { ensureDefaultAgents } = await import("./agent/defaults");
|
||||
try {
|
||||
const memoAgent = await ensureDefaultAgents(client);
|
||||
@@ -1289,7 +1298,7 @@ async function main(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
// If there's a local LRU, use it directly
|
||||
// If there's a local LRU, use it directly (takes priority over model picker)
|
||||
if (localSettings.lastAgent) {
|
||||
try {
|
||||
await client.agents.retrieve(localSettings.lastAgent);
|
||||
@@ -1303,6 +1312,12 @@ async function main(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
// On self-hosted with unavailable default model, show selector to pick a model
|
||||
if (needsModelPicker) {
|
||||
setLoadingState("selecting_global");
|
||||
return;
|
||||
}
|
||||
|
||||
// Show selector if there are pinned agents to choose from
|
||||
if (wouldShowSelector && globalPinned.length > 0) {
|
||||
setLoadingState("selecting_global");
|
||||
|
||||
Reference in New Issue
Block a user