[Bug]: GET /api/assistant/models?executor=<cli> drops the user's saved models, so the composer sends the "default" sentinel as a model name
Component / host
Platform — web / API
Edition
Platform
LoopForge version
ghcr.io/tencent/loopforge:0.4.0 (server reports (devel), linux/arm64). The code paths below were re-checked at eb2e368 and the API gap is still there.
What happened?
The two model-catalog endpoints disagree about a user's saved models, and the composer falls into the gap.
-
For a custom-model agent CLI (
pi,opencode,zcode,dsh,kimi) a user configures API Key + Base URL + several models in 个人配置 and saves them. -
GET /api/assistant/modelsreturns them correctly (verified against a live instance):{"engine":"pi","id":"pi:group/self-use-models","name":"Self-Use-Models"} {"engine":"pi","id":"pi:group/haid-use-models","name":"Haid-Use-Models"} -
But
GET /api/assistant/models?executor=pi— the request the composer makes as soon as its in-memory catalog snapshot has no entry for the selected CLI — returns only the sentinel:{"default":"default","models":[{"id":"default","name":"CLI default","family":"","credits":"","efforts":null}]} -
So the composer's model menu contains a single item,
CLI default. Sending a turn puts the literal stringdefaultin the request, and the CLI forwardsmodel: "default"to the configured Base URL. An OpenAI-compatible gateway that has no model literally nameddefaultanswers 404 and the generation fails:调用 1 · pi default 退出码 0 · http://<gateway> (chat) 404: {"error": {"message": "no model \"default\" ...", "type": "not_found_error"}}
Expected: a CLI selected with saved personal models lists those models; the default sentinel means "run the CLI's own default", so it must never reach the provider as a model name.
Reproduction
docker compose upthe platform, sign in, open 个人配置 → pickpi(oropencode/zcode/dsh/kimi).- Enter an API Key and a Base URL of an OpenAI-compatible gateway, click 获取可用模型, save 2 or more models.
- Open AI 对话 without reloading the page (a catalog snapshot loaded before the save reproduces this; a hard reload hides it).
- Select
Piin the composer and open the model menu → onlyCLI defaultis listed. - In devtools,
GET /api/assistant/models?executor=pireturns only{"id":"default"}. - Send a message → the CLI sends
model: "default"to the gateway → 404, and the run fails withGENERATION_FAILED.
Where it comes from
Two code paths build the same catalog:
internal/httpapi/assistant_models.go:180-215— the?executor=branch delegates toexecutorModelCatalogs(...)and returns the fixed per-CLI catalog only.builtinExecutorModels[<agent CLI>]is empty forpi/opencode/zcode/dsh/kimi, so the response carries nothing but the default entry.internal/httpapi/executor_models.go:213-234(catalogHandlers.executorModels, i.e.GET /api/executor-models) — the same catalogs, but it substitutes the user's saved models viaassistantDiscoveredModelsFor(...)and marksSource: "personal".
So the saved models exist and are reachable through one endpoint, but not the one the composer uses as its fallback:
// chatbot/src/useChat.js:692-698
const listed = engineModels(models, executor);
const usesProviderCatalog = !!executor && !codeBuddy && (!!agyAccountKey || !listed.length);
const catalogToLoad = usesProviderCatalog && !providerCatalog ? agyAccountKey || executor : "";
const executorModels = usesProviderCatalog
? (providerCatalog?.models || []).filter((model) => concreteModel(model, executor))
: listed;
Suggested fix
Either make the ?executor= branch return the same personal models as /api/executor-models (share one builder for both handlers), or have the composer call /api/executor-models for custom-model CLIs. Independently, strip the default sentinel before it reaches a CLI engine so a placeholder can never be sent to a provider as a model name.
Environment
- Platform:
compose.yamldeployment, platform container + MySQL in Docker on macOS (arm64). - Browser: Chromium-based,
zhUI. - CLI:
pi, custom Base URL speaking thechatprotocol against an OpenAI-compatible gateway. - No runner involved: the turn ran on the platform's own CLI execution path.
Thanks for the report. As I understand it, after personal models are saved for a custom-model CLI, the composer request that asks for that executor's catalog only comes back with the default sentinel, and a later turn can send that literal name to the gateway so generation fails.
We've seen this and will review it along with the current issue queue.
我在最新 main(`d2462fa`)上复现了这个问题。
为 Pi 配置自定义 Base URL,并保存两个个人模型后:
```text
GET /api/executor-models
=> 能正常返回保存的个人模型
GET /api/assistant/models?executor=pi
=> 返回空目录;受影响版本中只返回 default
原因是这两个接口使用了不同的模型目录逻辑。/api/executor-models 会读取用户保存的模型,但 composer 使用的 /api/assistant/models?executor=pi 只读取固定的 CLI 目录。Pi、OpenCode 等 CLI 没有内置模型列表,所以个人模型被丢掉了。
最小修复可以是:
- 在
GET /api/assistant/models?executor=<cli>中复用assistantDiscoveredModelsFor(...),返回用户保存的个人模型; - 在调用 CLI 前把
default当作内部 sentinel 处理,不能继续作为真实模型名传给 provider。对于 Pi,目前会生成agentflow/default,最终可能导致网关返回 404。
这样可以直接修复当前的模型菜单问题和后续的 GENERATION_FAILED。