Aliyun Model Studio (the upstream behind Qoder's CN catalog) documents
Max Output Length = 131072 for every model we expose, in both normal and
thinking modes (thinking chain alone goes to 262144):
qwen3.8-max/flash, qwen3.7-max/plus/flash — all 131072.
The previous 32768 default (copied from qodercli's conservative 32e3) used
only 1/4 of the supported output budget. That truncates reasoning chains in
thinking mode (where the chain counts against output) and risks cutting long
generations / compaction summaries. qodercli caps its own UI at 65536, still
below the documented ceiling.
- models.ts: introduce MAX_OUTPUT_TOKENS = 131072 as the single source of
truth; all 24 staticModels entries + the lazy-loaded CN entry now reference
it. Remove the dead max_output_tokens field from the CN placeholder entry.
- stream.ts: maxTokens defaults to MAX_OUTPUT_TOKENS; still capped lower by
options.maxTokens (e.g. pi compaction passes 40000).
Verified against the real CN endpoint: max_tokens=131072 returns 200 / stop
(accepted, not rejected); an xhigh reasoning run completes with
finish_reason=stop (not truncated). Field placement + reasoning_effort send
also confirmed working in the same request.
Qoder's /model/list catalog never returns max_output_tokens (the field does
not exist on any entry — only max_input_tokens is present), so the per-model
lookup `entry.max_output_tokens || 32768` was dead code that always fell back
to the 32768 literal.
- models.ts: remove max_output_tokens from QoderModelEntry; maxTokens is now a
flat 32768 (matches qodercli's 32e3 fallback).
- stream.ts: remove the now-unused maxOutputTokens variable and its always-true
branch; maxTokens = 32768, capped lower only by options.maxTokens (e.g. pi
compaction passes 40000). pi-ai's maxTokens setting still has an outlet.
- stream.ts fallback modelConfig: drop the dead max_output_tokens: 32768 field.
qodercli does conditionally send max_tokens (user setting → generation config
→ 32K fallback), but the field is not required by the upstream API. Keeping it
gives pi-ai's options.maxTokens a place to flow through.
The catalog API returns each model's supported thinking efforts
(thinking_config.enabled.efforts, e.g. low/medium/xhigh for qwen3.8), but the
provider never populated Model.thinkingLevelMap, so pi's getSupportedThinkingLevels
hid xhigh/max (they require a non-undefined map entry) and the picker topped out
at "high" even for models that support xhigh.
Parse thinking_config at catalog fetch time and build the map:
- effort-based models (qwen3.8-max/flash, DeepSeek, GLM): each supported
effort maps to its same-named pi level; unsupported levels pin to null
(hidden). xhigh is now exposed. "off" is selectable when the catalog also
advertises a "disabled" option.
- toggle-only models (qwen3.7-max/plus: enabled/disabled, no efforts):
every pi level is exposed and maps to "enabled" so picking any level turns
thinking on; "off" selectable when "disabled" is advertised.
- models without thinking_config (qwen3.7-flash): no map, pi falls back to its
default level set.
Qoder effort keys are already pi level names (low/medium/high/xhigh/max), so
the mapping is by identity — no translation table.
This is display-layer only: it fixes which thinking levels the picker shows.
Sending the chosen effort upstream is a separate change that needs the exact
request field from a qoder-cli capture; the map values ("low"/"xhigh"/
"enabled"/"disabled") are placeholders that will be mapped to the request
shape once confirmed.
max_input_tokens (180K) was only used to seed the context window before
context_config options overrode it. Every live CN model exposes selectable
contexts (200K/400K/1M) whose smallest option already exceeds 180K, so the
seed only ever acted as a redundant floor and was never the final value.
- updateQoderModelsCache: derive contextWindow from the largest
context_config option directly; fall back to 200K when no context_config is
present (was 180K via max_input_tokens).
- staticCnModels: the Auto entry (the no-context fallback) now uses 200K too,
matching the dynamic fallback; its description no longer references the
stale 180K live-catalog note.
The CN model picker used to translate Qoder's internal keys (qfmodel,
qmodel_latest, ...) into hardcoded "friendly" ids (qwen3.6-flash, ...) via a
manual mapping table, with the display label hardcoded alongside. Both
sides rotted independently of upstream: when Qoder upgraded qfmodel to
Qwen3.8-Flash the label stayed "Qwen 3.6 Flash", and new keys (qmodel_38max,
q37fmodel) had no entry so their raw key leaked into the picker as the id.
The catalog API already returns every key with its display_name, so the
mapping table duplicates data the server provides and can only ever be stale.
Rework: use the upstream display_name (whitespace-stripped) directly as the
pi-visible Model.id, and read the request-time upstream key back from the
cached model config at send time. No key<->friendlyId table is needed.
- cosy.ts: remove qoderCNFriendlyModels, getQoderCNDirectModel,
getQoderCNFriendlyModelInfo, toQoderCNFriendlyModel, prettifyQoderCNModelName.
Add toQoderCNModelId(display) = display with whitespace stripped.
- models.ts: updateQoderModelsCache now sets CN model id =
toQoderCNModelId(display_name); the original key is still stored in configs
(keyed by both key and id) and read back via getCachedModelConfig. Simplify
the CN fallback in getCachedModelConfig (drop the stale reasoning set).
staticCnModels ids/names rewritten to the display_name form.
- stream.ts: the upstream key comes from modelConfig.key (the cached entry)
instead of a reverse-lookup table; falls back to model.id for the
international site, which already uses the key as id.
- index.ts: modelsForProvider no longer re-maps CN models through a friendly
transform — the cached/static ids are already the display name.
Trade-off: a renamed/upgraded model changes its id, so a previously saved
default model may no longer resolve after an upstream rename and the user
reselects. This is expected: users should learn about new models. This is
accepted.
Tests updated for the new contract; e2e against the live CN catalog confirms
id=Qwen3.8-Flash resolves to send key=qfmodel with no mapping table.
The custom ctx.ui.custom login menu stole focus from pi's built-in
LoginDialog, so onPrompt never received keystrokes and PAT login
silently failed with 'No API key found'. Drive login via the provided
onPrompt/onAuth/onProgress callbacks instead, and drop login-ui.ts and
the now-unused pi-tui dependency. Also clears remaining lint warnings
by removing any-casts in models/oauth/stream/transform.