DeepSeek V4 sometimes expresses a tool call as its internal DSML markup
instead of filling `tool_calls`, and Qoder's gateway leaks the tag skeleton
rather than converting it. When no structured call arrives the turn used to
end as an empty `stop` and the agent stopped mid-task with no error.
Handle both shapes:
- Filter the delimited form (`||DSML||tool_calls` ...) on the reasoning and
content channels, rebuilding a complete block into a structured call.
- Strip the delimiter-less form the gateway leaves behind
(`<parameter name="command">…</parameter>`, `</invoke>`, `</tool_calls>`,
a stray `</thinking>`) line-wise before the empty-turn guard reads the
message, and make `hasVisibleText` ignore markup-only text. That form used
to land in the *content* channel as a normal reply, so the guard saw
visible text and never fired.
A turn that produces only leaked markup now fails with a retryable error
(matching pi's "ended without" pattern) instead of ending silently.
Qoder's /model/list groups one account catalog by UI scenario (chat,
assistant, quest, qwork, experts, ...). The CLI only read `chat`, so the
picker hid models the IDE exposes elsewhere — GLM-5.3, GLM-5.2 and
DeepSeek-V4-Pro live under experts/qwork.
Register the union of the scenario groups, keeping the first occurrence per
upstream key (chat wins) and excluding byok_* groups, which are
bring-your-own-key providers rather than part of the shared catalog.
Also keep an explicitly enabled `auto` model: live catalogs key `configs` by
the whitespace-stripped display name, so it arrives as `Auto` instead of the
legacy raw `auto` key.
Refresh the lockfile to the 0.4.5 already in package.json.
OMP rewrites @earendil-works/pi-ai/compat to a bundle without
registerApiProvider, which broke static import at install/load.
Probe the export at runtime; stock pi still registers qoder-api for
global streamSimple, while OMP relies on registerProvider(streamSimple).
Pi 0.84+ no longer registers custom APIs from registerProvider.streamSimple,
so a later agent-loop path threw No API provider registered for api: qoder-api.
Older Cosy-Version / cosyVersion values cause the model catalog and
gateway to treat the client as a stale qodercli and return a reduced
list. Align QoderIDEVersion with current CLI 1.1.38.
Leave PAT exchange and userinfo Cosy-Version at 1.0.1: those openapi
endpoints do not use a COSY signature, and I could not verify that
official qodercli 1.1.38 changed them.
Co-authored-by: Simon Shi <simonsmh@users.noreply.github.com>
@earendil-works/pi-coding-agent, pi-ai and the undici they pull in all
declare engines node >=22.19.0, so CI's Node 20 was below the floor: the
newly added test step failed loading pi-coding-agent with
"webidl.util.markAsUncloneable is not a function". Release already
publishes on Node 24.
Co-authored-by: Simon Shi <simonsmh@users.noreply.github.com>
CI linted, typechecked and built but never ran vitest, so the suite could
break on main without anyone noticing.
Co-authored-by: Simon Shi <simonsmh@users.noreply.github.com>
The npm tarball ships only dist/ and README.md, so the pi.extensions
"./src/index.ts" that shipped in 0.3.0 left Pi listing the package as
installed while never loading the provider. main already points at
./dist/index.js (6d9635e), but nothing stopped it regressing again -- it
had already flipped once in 1b110a6.
Assert the entry is ./dist/index.js and, more generally, that every
pi.extensions path falls inside the published files set.
Co-authored-by: Simon Shi <simonsmh@users.noreply.github.com>
auto, efficient and lite carried a 180K contextWindow, so pi showed >100%
context usage and auto-compacted early. Live testing in #13 drove global
lite to 1,000K tokens successfully, so the 180K value was a stale
max_input_tokens floor rather than a real limit.
Introduce DEFAULT_CONTEXT_WINDOW (1M) and use it for the global static
models, including gm51model. Apply it as the catalog fallback too, but only
when /model/list advertises no context_config: models that do advertise a
smaller window (kmodel at 256K, CN GLM-5.2 and MiniMax at 200K) keep it
rather than being inflated to 1M. CN Auto stays at 200K since only global
lite was verified at 1M.
Co-authored-by: Simon Shi <simonsmh@users.noreply.github.com>
Several suites read and write ~/.pi/agent/{auth,qoder-models-cache}.json.
Vitest runs files in parallel, so one file could truncate a file another
was reading, and a run also clobbered the developer's own ~/.pi state.
Give each test file its own HOME.
Isolation exposed a latent coupling in the stream suite: with no resolved
identity on disk, streamQoder fetches /userinfo first and consumes the
single mocked Response, so the chat read failed on a locked stream. The
suite only passed because another file left credentials behind. Stub the
identity so the mock only ever serves the chat request.
Co-authored-by: Simon Shi <simonsmh@users.noreply.github.com>
pi-coding-agent 0.84 no longer exports AuthStorage, so the named import
failed to compile even though the call site already guarded for its
absence. Read it off the module namespace instead, keeping the auth-file
fallback when the export is missing.
Co-authored-by: Simon Shi <simonsmh@users.noreply.github.com>
CI was red at the lint step: an unused providerID parameter in
createQoderOAuth, an unused getCachedCredentials import in stream.ts,
plus unsorted imports and stale formatting in stream.ts and pat.ts.
Co-authored-by: Simon Shi <simonsmh@users.noreply.github.com>
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 picker was fixed to show thinking levels, but the chosen level was never
forwarded: stream.ts only used options.reasoning to toggle the local thinking
parser, so every request let the model default-decide its reasoning effort.
Reverse-engineered @qoder-ai/qodercli (bundle/qodercli.js) to confirm the
request shape: the chat body's `parameters` object carries `reasoning_effort`
("none"|"low"|"medium"|"high"|"xhigh"|"max") and `enable_thinking` (bool)
alongside `max_tokens`. qodercli's Zlr() sets reasoning_effort = zN(req)
(reasoning.enabled===false ? "none" : reasoning.effort) and enable_thinking.
Implementation follows the pi-ai OpenAI provider pattern:
- clampThinkingLevel(model, options.reasoning) clamps the requested level to
what the model advertises via thinkingLevelMap (returns "off" when
unsupported or disabled);
- map the clamped level to the upstream effort name via thinkingLevelMap,
falling back to the pi level name (Qoder effort names already match pi);
- effort-based models (thinking_config.enabled.efforts present, e.g.
qwen3.8-max) get reasoning_effort + enable_thinking=true;
- toggle-only models (qwen3.7-max: enabled/disabled, no efforts) get
enable_thinking=true only — no reasoning_effort, since they accept no level;
- no level / clamped to off: enable_thinking=false to explicitly disable.
Qoder has no "minimal" effort; clampThinkingLevel handles stepping it down
based on the model's thinkingLevelMap (minimal is pinned to null for effort
models, so it clamps to the next supported level).
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.