Model dialog doesn't clean up `enabledModels` in settings.json when a connector/models are removed → persistent 'No models match pattern' warnings
Summary
Removing a connector (or its models) in the pi-web model dialog does not clean up the stale entries in the global enabledModels setting (~/.pi/agent/settings.json). After the connector is gone, pi-web keeps showing Warning: No models match pattern "..." (rendered as a Model scope warning banner) for every subsequent session, and the only workaround is manually editing settings.json.
Environment
- pi-web: 0.8.9 (
@agegr/pi-web) - pi-coding-agent: 0.84.2
- macOS
Repro steps
-
Have a connector configured whose models are part of the enabled scope. This persists entries like these into
~/.pi/agent/settings.json:"enabledModels": [ "vercel-ai-gateway/poolside/laguna-s-2.1-free", "vercel-ai-gateway/alibaba/qwen3.7-flash" ] -
In pi-web's model dialog, remove the connector (it disappears from
models.jsonand the catalog). -
Reload / open a session. The UI now shows:
Model scope warning No models match pattern "vercel-ai-gateway/poolside/laguna-s-2.1-free" No models match pattern "vercel-ai-gateway/alibaba/qwen3.7-flash" -
~/.pi/agent/settings.jsonstill contains the two staleenabledModelsentries — the dialog never prunes them.
Root cause
- The model dialog's write path (
PUT /api/models-config) only writes~/.pi/agent/models.json(provider/model config). It sanitizes empty model IDs and normalizescost, but it never touchessettings.json. - pi-web never calls
setEnabledModels— grep of the entire build (server + frontend) shows zero occurrences. The only writer ofenabledModelsis the pi CLI/modelsselector (interactive-mode.js→settingsManager.setEnabledModels(...)), and even that selector deliberately re-injects no-match patterns back into the enabled list (ids.push(diagnostic.pattern)), so it doesn't prune them either. GET /api/modelsreadssettingsManager.getEnabledModels()and feeds the patterns intoresolveModelScopeWithDiagnostics(). Every pattern with no catalog match becomes ano-matchdiagnostic, which is returned asmodelScopeWarningsand rendered as the warning banner.
So: removing a connector in pi-web removes the models from models.json, but the stale enabledModels patterns in settings.json are never pruned, and scope resolution keeps reporting them on every load.
Expected behavior
Removing a connector/models in the model dialog should also prune the corresponding enabledModels entries from settings.json (e.g. by calling settingsManager.setEnabledModels(...) with the filtered list), so no stale-pattern warnings appear afterwards.
Suggested fix (any of these)
- Prune on connector removal: when
PUT /api/models-configsaves the provider list, intersect the existingenabledModelswith the new model set and persist the pruned list. - Prune in scope resolution: in
GET /api/models, dropno-matchpatterns instead of surfacing them as warnings — or filter them out of the enabled set before persisting. - CLI parity: make the
/modelsselector stop re-addingno-matchpatterns, or surface an explicit "remove stale entries" action.
Notes
- Workaround for users today: remove stale entries from
enabledModelsin~/.pi/agent/settings.json. - The same stale-entry problem can be triggered from the CLI (connector removed elsewhere), so a fix in scope resolution (#2) would cover both entry points.
enabledModels is a pi global setting and is not managed by pi-web. I don't think saving models.json should implicitly modify it; stale entries should remain a warning or be cleaned up explicitly by pi itself.
Ok up to you as the maintainer, but I still don't understand the logic of surfacing controls to add and remove providers and models in pi-web and then not cleaning them up when removing them through the same interface. That seems untidy.
Ok up to you as the maintainer, but I still don't understand the logic of surfacing controls to add and remove providers and models in pi-web and then not cleaning them up when removing them through the same interface. That seems untidy.
pi-web has always treated enabledModels as read-only: any changes to it originate outside pi-web, so pi-web should not remove or otherwise modify its entries.