pi-web icon indicating copy to clipboard operation
pi-web copied to clipboard

Model switch / compaction UX needs context, provider-error, and thinking-capability guardrails

Open dust617 opened this issue 4 months ago • 1 comments

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-web 0.8.0
  • Embedded Pi: @earendil-works/pi-coding-agent 0.81.1
  • Windows 11 / Electron wrapper
  • Models: aliyun-token-plan/qwen3.8-max-preview (983,616) and openai-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 model option.

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: 46
  • compaction: 19
  • thinking_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

  1. Model picker shows current/target context windows and warns on a smaller target window.
  2. Add Start new session with this model beside in-place switch.
  3. Honor thinkingLevelMap and prevent unsupported thinking values.
  4. If /compact fails, keep the session intact and offer a clean-session/checkpoint recovery action.
  5. Parse/summarize HTML provider errors; keep raw body as optional details.
  6. Do not infer context overflow solely 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)

dust617 avatar Jul 24 '26 11:07 dust617

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.
  • /compact failures 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.

agegr avatar Jul 29 '26 13:07 agegr