Commit Graph
83 Commits
Author SHA1 Message Date
Cursor AgentandSimon Shi 11249d12c4 Format reorganized provider modules
Co-authored-by: Simon Shi <simonsmh@users.noreply.github.com>
2026-08-31 17:11:43 +00:00
Cursor AgentandSimon Shi 9d88e995ee Refactor provider around fixed regions and friendly model ids
Co-authored-by: Simon Shi <simonsmh@users.noreply.github.com>
2026-08-31 17:11:18 +00:00
Cursor AgentandSimon Shi 63c517002e Fix provider binding test mocks
Co-authored-by: Simon Shi <simonsmh@users.noreply.github.com>
2026-08-31 16:53:00 +00:00
Cursor AgentandSimon Shi 66f950f9c5 Bind Qoder providers to fixed regions
Co-authored-by: Simon Shi <simonsmh@users.noreply.github.com>
2026-08-31 16:51:59 +00:00
Cursor AgentandSimon Shi b1d66d6eb4 fix: unblock live fixture recording
Co-authored-by: Simon Shi <simonsmh@users.noreply.github.com>
2026-08-31 16:33:47 +00:00
Cursor AgentandSimon Shi 72a81d672f test: cover live chat endpoint classification
Co-authored-by: Simon Shi <simonsmh@users.noreply.github.com>
2026-08-31 16:33:24 +00:00
Cursor AgentandSimon Shi 476a466076 style: format stream adapter test
Co-authored-by: Simon Shi <simonsmh@users.noreply.github.com>
2026-08-31 16:32:09 +00:00
Cursor AgentandSimon Shi b4f504094e refactor: centralize regional provider configuration
Co-authored-by: Simon Shi <simonsmh@users.noreply.github.com>
2026-08-31 16:31:54 +00:00
Cursor AgentandSimon Shi 9dc71be404 fix: correct friendly model table typing
Co-authored-by: Simon Shi <simonsmh@users.noreply.github.com>
2026-08-31 16:30:15 +00:00
Cursor AgentandSimon Shi aaac381d76 refactor: use friendly model ids globally
Co-authored-by: Simon Shi <simonsmh@users.noreply.github.com>
2026-08-31 16:29:52 +00:00
Cursor AgentandSimon Shi ca17a95270 test: correct fixture and abort harness
Co-authored-by: Simon Shi <simonsmh@users.noreply.github.com>
2026-08-31 16:28:09 +00:00
Cursor AgentandSimon Shi 3d7df5d1e4 test: cover provider adapter scenarios
Co-authored-by: Simon Shi <simonsmh@users.noreply.github.com>
2026-08-31 16:27:32 +00:00
Cursor AgentandSimon Shi 6d5cdfd171 test: add redacted Qoder protocol recorder and replays
Co-authored-by: Simon Shi <simonsmh@users.noreply.github.com>
2026-08-31 16:14:37 +00:00
Cursor AgentandSimon Shi 1eee02455c fix: bump COSY client identity to qodercli 1.1.38
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>
2026-08-31 16:07:41 +00:00
Cursor AgentandSimon Shi e7b5990e5c ci: build and test on Node 24
@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>
2026-08-31 15:59:37 +00:00
Cursor AgentandSimon Shi 2d9e31ea4a ci: run the test suite
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>
2026-08-31 15:58:00 +00:00
Cursor AgentandSimon Shi 52f7752717 test: guard the published pi.extensions entry (#18, #21)
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>
2026-08-31 15:57:56 +00:00
Cursor AgentandSimon Shi 1e44cde685 fix(models): use the 1M context window Qoder actually supports (#13)
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>
2026-08-31 15:57:49 +00:00
Cursor AgentandSimon Shi 1dd1b0988b test: isolate suites from the real ~/.pi and from each other
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>
2026-08-31 15:57:41 +00:00
Cursor AgentandSimon Shi e98526a8cd fix(types): restore npm run check
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>
2026-08-31 15:57:26 +00:00
Cursor AgentandSimon Shi 70fba627e6 fix(lint): clear biome errors breaking CI on main
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>
2026-08-31 15:57:20 +00:00
Simon ShiandGitHub ab378b44e2 Merge pull request #16 from simonsmh/dependabot/npm_and_yarn/npm_and_yarn-0e29347d1a
build(deps): bump undici from 8.5.0 to 8.9.0 in the npm_and_yarn group across 1 directory
2026-08-31 23:44:05 +08:00
Simon ShiandGitHub 756be0159b Merge pull request #19 from huangxingx/fix/qoder-cn-login-windows-build
fix: qoder-cn chat identity, content normalization, and Windows build
2026-08-31 23:43:49 +08:00
Simon ShiandGitHub 6a0d08c04c Merge branch 'main' into fix/qoder-cn-login-windows-build 2026-08-31 23:43:40 +08:00
Simon ShiandGitHub 3e66ceb1a8 Merge pull request #20 from snufkintomo/fix/done-sentinel-hang-and-orphaned-tool-results
fix: end the stream at [DONE] and drop orphaned tool results
2026-08-31 23:42:52 +08:00
Simon ShiandGitHub d8fc2cb234 Merge pull request #22 from Loongphy/feat/cn-model-id-as-display
fix(cn): track upstream model catalog dynamically, forward reasoning effort, raise output to 128K
2026-08-31 23:42:35 +08:00
Loongphy 76c3b7201b feat: raise max output tokens to 128K (documented upstream ceiling)
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.
2026-08-28 19:36:59 +08:00
Loongphy 112da4deaf refactor: drop dead max_output_tokens, simplify maxTokens to 32K + pi cap
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.
2026-08-28 19:07:16 +08:00
Loongphy 5393c24b7e feat: send reasoning_effort + enable_thinking to Qoder upstream
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).
2026-08-28 18:57:56 +08:00
Loongphy 88cf414a8e feat(cn): map Qoder thinking_config to pi thinkingLevelMap for the picker
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.
2026-08-28 17:27:07 +08:00
Loongphy cc461cd145 refactor: drop redundant max_input_tokens, default context fallback to 200K
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.
2026-08-28 10:11:37 +08:00
Loongphy b462207447 feat(cn): expose upstream display_name as model id, drop key mapping tables
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.
2026-08-28 08:16:36 +08:00
snufkintomo e4c55f4871 fix: end the stream at [DONE] and drop orphaned tool results
Two independent bugs made Qoder turns hang or fail outright.

1. The SSE read loop never terminated on the sentinel. `data: [DONE]`
   broke only the inner line loop, so the outer loop kept awaiting
   reader.read() until the socket closed. Qoder's gateway holds the body
   open after the sentinel, so a reply that had already streamed in full
   produced no `done` event: the agent sat there with the complete answer
   buffered and no error, until something else timed the connection out.

   The sentinel also arrives wrapped in an envelope (`body: "[DONE]"`),
   which likewise only did `continue`, so both forms now end the loop.
   The reader is cancelled once the reply is complete instead of being
   left holding the connection.

2. Aborting a turn produced an invalid request. Assistant messages with
   stopReason error/aborted are skipped, but the tool result that followed
   was still emitted, leaving a `tool` message whose tool_call_id had no
   matching tool_calls entry. Upstreams reject that with "tool must follow
   a message with tool_calls" -- the same failure the null-content
   workaround above it already guards against -- so after one cancelled
   tool call, every later request in that session failed. Tool calls
   belonging to a dropped turn are now recorded and their results dropped
   with them.

Both fixes are covered by regression tests that fail on the current code:
the two stream tests time out at the 8s limit, and the transform tests
produce an orphaned tool message.
2026-08-21 19:12:00 +08:00
xing.huang 443e4ad6a7 fix: qoder-cn chat identity, content normalization, and Windows build
- Resolve the real Qoder identity (userID/email/name/machineID) from the
  job token at request time. OMP keeps login credentials in its own
  agent.db, not in ~/.pi/agent/auth.json, so a cache miss sent uid
  "qoder-user" and Qoder CN rejected it with "Login expired" (105).
- Normalize the system prompt to a plain string. OMP supplies it as a
  single-element content array which Qoder's MessagesInputDto#content
  (String) rejects with 400 "Execution failed: set property" on qwen models.
- Drop the modifyModels hook. OMP (Bun) structuredClones the whole model
  catalog before invoking it, and its bundled catalog is not cloneable,
  which removed qoder from `omp models`.
- Make the build script cross-platform: use esbuild on PATH instead of a
  Unix-style ./node_modules path that fails on Windows cmd.exe.
2026-08-18 12:22:47 +08:00
dependabot[bot]andGitHub b3afbfce2b build(deps): bump undici in the npm_and_yarn group across 1 directory
Bumps the npm_and_yarn group with 1 update in the / directory: [undici](https://github.com/nodejs/undici).


Updates `undici` from 8.5.0 to 8.9.0
- [Release notes](https://github.com/nodejs/undici/releases)
- [Commits](https://github.com/nodejs/undici/compare/v8.5.0...v8.9.0)

---
updated-dependencies:
- dependency-name: undici
  dependency-version: 8.9.0
  dependency-type: indirect
  dependency-group: npm_and_yarn
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-08-08 03:41:21 +00:00
Simon ShiandGitHub 9820845768 Merge pull request #14 from OysterD3/fix/forward-tool-result-images
fix: forward tool-result images, and emit tool calls that arrive with no arguments
2026-08-08 11:40:25 +08:00
Simon ShiandGitHub 24ad0b67f6 Merge pull request #12 from Loongphy/main
fix: pi.extensions path should point to dist/index.js instead of src/index.ts
2026-08-08 11:40:07 +08:00
LoongphyandOyster Lee 6956615f66 fix: pi.extensions path should point to dist/index.js instead of src/index.ts
The "files" field in package.json only includes "dist" and "README.md",
so src/index.ts is not available in the published npm package.

This was introduced in commit 1b110a6 ("fix index") which changed
the path from the correct "./dist/index.js" to "./src/index.ts".
2026-08-03 06:50:04 +08:00
Oyster Lee b4416909f5 fix: emit a tool call that arrives with no arguments
A tool call whose arguments never arrive — a no-argument tool, or a model that
sends id and name and then stops — was accumulated into toolCallsState but
never added to the message, because the content block was only created inside
`if (tc.function?.arguments)`.

The finalizer then checked `toolCallsState.length > 0` and set
stopReason "toolUse" on a message containing no tool call at all. pi's agent
loop continues only on tool calls, so it had nothing to execute and the turn
ended: mid-task, no tool run, no error, nothing in the transcript except the
assistant saying what it was about to do. Observed against a real session where
the model announced "let me consult the advisor" four times in a row and the
run then stopped dead; its final message on disk is stopReason "toolUse" with a
single text block and no toolCall.

Two changes:

  - open the block as soon as the call is identifiable (id or name), and keep
    its id/name in step if they arrive in a later delta, since the finalizer
    only rewrites `arguments`;
  - guard the stopReason on blocks that actually reached the message rather
    than on the state array being non-empty, so a genuinely malformed stream
    reports "stop" instead of an unactionable "toolUse".

Tests: no-argument call, identity arriving after the block is open, and a
malformed delta that must not claim toolUse.
2026-08-03 06:50:04 +08:00
Oyster Lee a9a3521b9b fix: forward images returned by tool calls to the model
A tool result can carry images. pi's `read` tool returns a text note plus an
`image` block for png/jpg/gif/webp/bmp, and screenshot tools do the same.

transformMessagesForQoder() built the `tool` message with getContentText(),
which maps every non-text block to "". The images were dropped silently: the
TUI rendered the picture, the model received only "Read image file [image/png]"
and answered that it could not see images — then fell back to scraping the DOM.
Nothing reported a problem, and the model catalogue advertises input
["text", "image"], so the capability check upstream of this had no reason to
warn either.

The OpenAI-shaped `tool` role has nowhere to put them: its content is a plain
string. So the images now follow as a separate user message, using the same
image_url part the user branch already builds, with a short label so the model
does not read a bare image as something the human just sent.

Tool results without images are unchanged and still produce exactly one
message.
2026-08-03 06:20:10 +08:00
Loongphy 6d9635e52c fix: pi.extensions path should point to dist/index.js instead of src/index.ts
The "files" field in package.json only includes "dist" and "README.md",
so src/index.ts is not available in the published npm package.

This was introduced in commit 1b110a6 ("fix index") which changed
the path from the correct "./dist/index.js" to "./src/index.ts".
2026-07-31 06:37:45 +08:00
Simon ShiandGitHub 3af6bde995 Merge pull request #11 from simonsmh/dependabot/npm_and_yarn/npm_and_yarn-14d799c0ca
build(deps-dev): bump postcss from 8.5.15 to 8.5.25 in the npm_and_yarn group across 1 directory
2026-07-30 19:17:09 +08:00
Simon Shi c97e372d08 chore: bump version to 0.3.0 2026-07-30 19:16:29 +08:00
dependabot[bot]andGitHub 842750054e build(deps-dev): bump postcss
Bumps the npm_and_yarn group with 1 update in the / directory: [postcss](https://github.com/postcss/postcss).


Updates `postcss` from 8.5.15 to 8.5.25
- [Release notes](https://github.com/postcss/postcss/releases)
- [Changelog](https://github.com/postcss/postcss/blob/main/CHANGELOG.md)
- [Commits](https://github.com/postcss/postcss/compare/8.5.15...8.5.25)

---
updated-dependencies:
- dependency-name: postcss
  dependency-version: 8.5.25
  dependency-type: indirect
  dependency-group: npm_and_yarn
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-07-30 11:16:19 +00:00
Simon ShiandGitHub a333aaf812 Merge pull request #10 from het-e2m/patch-1
feat: add latest Qoder frontier models
2026-07-30 19:15:27 +08:00
Simon ShiandGitHub 8b328aea1d Merge pull request #9 from unship/fix/stability
fix(stream): stop silently swallowing upstream errors and session-lock stalls
2026-07-30 19:15:07 +08:00
liyanan 37ce615e62 test(stream): assert usage input excludes cached/written tokens
Follow the fix in stream.ts: prompt_tokens (42) includes cached_tokens (5),
so input = 42 - 5 - 10 = 27. Use cache_write_tokens (not cacheable_tokens)
for cacheWrite, and keep cacheable_tokens:99 in the payload to prove it is
no longer mapped to cacheWrite.
2026-07-30 12:42:27 +08:00
liyanan d4c31fcc4e fix(stream): map usage to pi-core's cache convention (input excludes cached tokens)
pi-core computes promptTokens = input + cacheRead + cacheWrite (Anthropic
convention: input EXCLUDES cached/written tokens), but qoder follows OpenAI
semantics where prompt_tokens INCLUDES cached_tokens. pi-ai's own OpenAI
provider subtracts them; this provider didn't, which under-reported the
cache rate (45% vs the true ~83%) and tripped pi-core's miss detector on
every cached turn.

- input = max(0, prompt_tokens - cacheRead - cache_write_tokens)
- cacheWrite reads cache_write_tokens, not cacheable_tokens (a capacity
  metric that is 0 even on first-turn writes, not a write count)
2026-07-30 12:42:22 +08:00
liyanan 1b110a6291 fix index 2026-07-28 15:46:08 +08:00
liyanan 47141df66e fix: strip thinking tag artifacts leaked into reasoning_content
Qoder's backend sometimes routes a literal <thinking> opener into
reasoning_content while the matching closer lands in the content
stream, leaving tag fragments in the thinking block. Strip them during
streaming and add live repro scripts.
2026-07-28 10:21:28 +08:00