4 Commits
Author SHA1 Message Date
cat-shark 9821439603 fix: read prompt and tools from the transcript
CI / Lint, typecheck & build (push) Failing after 32s
pi 0.87 made the session transcript canonical for provider context: the
context handed to a custom provider's stream no longer carries
`systemPrompt` and `tools`; they live on the leading system message
(`sections` + `toolsAdded`). streamQoder still read the removed fields,
so every request went out with `system: ""` and `tools: []` - the model
saw no prompt and no tools and answered that it cannot access files.

- resolve the prompt with getCurrentSystemPrompt(messages) and the tool
  list with getCurrentTools(messages)
- give tool parameters a root `type: "object"`: Qoder's upstream rejects
  a union root ("schema must be a JSON Schema of 'type: \"object\"', got
  'type: null'"), e.g. the agent-browser Electron tool, which failed the
  whole request with a 400
- bump the pi-ai / pi-coding-agent devDependencies to ^0.87.1 and cover
  the transcript prompt/tools path with a regression test
2026-09-29 10:18:44 +08:00
cat-shark d0d69617da fix: keep a turn's tool results together when one returns an image
The OpenAI-shaped `tool` role content is a plain string, so a tool result
carrying images (pi's read/screenshot tools) follows as an extra user
message. It was emitted immediately after its own tool message, which broke
multi-call turns:

  assistant(tool_calls=[a, b]) -> tool(a) -> user(image) -> tool(b)

Qoder rejects that with "An assistant message with 'tool_calls' must be
followed by tool messages responding to each 'tool_call_id' (insufficient
tool messages following tool_calls message)", leaving the session unable to
send any further request.

Queue the image follow-up and flush it once the run of consecutive tool
results ends, so every tool_call_id is answered before the user message.
2026-09-24 17:17:25 +08:00
cat-shark e7d12b5532 fix: retry instead of stalling when DSML tool-call markup leaks
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.
2026-09-24 17:17:18 +08:00
cat-shark a0be14764c feat(models): register every /model/list scenario
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.
2026-09-24 17:17:10 +08:00