Model switch / compaction UX needs context, provider-error, and thinking-capability guardrails
Summary
In a long Pi Web session, switching between providers/models and changing thinking level can leave the UI in a state where prompts and /compact repeatedly fail, while the actual cause is unclear. Pi Web currently exposes raw provider errors and does not guide the user toward a safe new-session handoff.
This report intentionally separates confirmed facts from earlier incorrect assumptions.
Environment
- Pi Web:
@agegr/pi-web0.8.0 - Embedded Pi:
@earendil-works/pi-coding-agent0.81.1 - Windows 11 / Electron wrapper
- Models:
aliyun-token-plan/qwen3.8-max-preview(983,616) andopenai-codex/gpt-5.6-sol(272,000)
Confirmed failure modes
1. Invalid thinking level is selectable for an always-thinking model
After selecting Qwen 3.8 Max Preview and setting thinking to off, the provider returns:
400 invalid_parameter_error: The value of the enable_thinking parameter is restricted to True.
The custom model supports reasoning but cannot disable it. Pi supports thinkingLevelMap: { "off": null }; Pi Web should honor model capability metadata and hide/disable unsupported levels.
2. /compact depends on the currently selected provider/model
When the selected GPT provider was unreachable, /compact failed too. The UI then offered no clear recovery path besides repeatedly retrying the same failing provider. Compaction is an LLM call, not a local truncation operation.
A safe recovery should offer:
- create a new session in the same cwd with the selected model, or
- switch provider and compact only after connectivity is restored, or
- export/checkpoint the session before starting fresh.
3. Raw HTML provider errors are rendered without diagnosis
The GPT provider returned a full HTML error page. Subsequent network isolation showed the affected egress received:
{"error":{"code":"unsupported_country_region_territory","type":"request_forbidden"}}
After changing egress, api.openai.com became reachable (401 without credentials, proving the IP/region gate was passed). Therefore the HTML failures in this incident were primarily a provider/network-region failure, not proof of context overflow or incompatible thinking history.
Pi Web should summarize HTML/non-JSON provider failures as an HTTP/provider/network error and preserve the raw body behind an expandable detail panel.
4. No safe cross-provider switch workflow
The model picker allows an in-place switch from a 983K model to a 272K model without showing:
- current active-context estimate,
- target context window,
- provider/thinking capability differences, or
- a
Start clean session with this modeloption.
This is risky even when the provider is healthy. The safest default for provider-family changes is often a new session in the same cwd after a file/checkpoint handoff.
Corrected session evidence
Structured JSONL parsing (not grep substring counts):
- Session file: 27.3 MB / 3,841 entries
model_change: 46compaction: 19thinking_level_change: 13
Important: JSONL file size is not active LLM context size. Pi retains historical entries on disk after compaction, and Pi Web may render full history (related to #130).
Requested Pi Web behavior
- Model picker shows current/target context windows and warns on a smaller target window.
- Add
Start new session with this modelbeside in-place switch. - Honor
thinkingLevelMapand prevent unsupported thinking values. - If
/compactfails, keep the session intact and offer a clean-session/checkpoint recovery action. - Parse/summarize HTML provider errors; keep raw body as optional details.
- Do not infer
context overflowsolely from a large JSONL file. Use active session-context/token state from Pi.
Related
- agegr/pi-web#130 (full-history UI remains large after compaction)
- earendil-works/pi#7065 and #7067 (original reports; corrections will be added because network failure and grep counts confounded the evidence)
Thanks for the detailed report and, especially, for separating the confirmed behavior from the earlier context-overflow assumptions.
After reviewing this, we are not going to add model/provider-switch guardrails or force a new-session handoff as part of this issue. Switching models/providers remains an explicit user action. Compaction also continues to use the currently selected provider/model; if that request fails, the session remains intact and the actionable behavior is to surface the provider error clearly.
We did implement the narrow error-display fix: 556e2ec39a7063e38f2424fcf4e12b96428e2a32
- Completed assistant responses now show the provider
errorMessage, including responses with no content. - If the provider returned partial output before failing, that output remains visible above the error.
/compactfailures now appear as a wrapping alert above the composer, in the existing retry/compact status area, instead of a single-line tooltip beside the compact button.- Compact errors remain visible until the next compact attempt.
- Provider-returned HTML is rendered as escaped text, so the original diagnostic is visible without executing it.
We intentionally did not add context-window warnings, cross-provider switch protection, an automatic clean-session workflow, or heuristic HTML diagnosis in this change. The broader issue therefore remains closed as not planned, while the concrete error-visibility problem is addressed.