zai-org / zai-org/feedback

[Bug]: Account Models (GLM-5.3-Flash) Cannot Be Selected via App-Server Protocol Due to Revision Type Mismatch

Open
#695 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

priority: P2
Dominant language
No language data
Stars
22
Forks
1
PR merge metrics
No merged PRs in 30d

Description

Bug Description

In ZCode 3.12.3 (tested on macOS arm64), when using zcode.cjs app-server over stdio in hosted mode, account models (e.g. GLM-5.3-Flash under account:zai-individual-coding-plan) cannot be selected via the RPC protocol:

session/setModel {
  "model": {
    "providerId": "account:zai-individual-coding-plan",
    "modelId": "GLM-5.3-Flash"
  }
}

Error Returned:
→ -32603 Provider Registry 中不存在 Model

Additionally, turns initiated via session/send with a modelSelection override stall indefinitely with a provider_not_found event.


Root Cause Analysis (Confirmed via Bundle Disassembly)
  1. The desktop chat engine runs in standalone mode (initializing account providers directly from local credential stores).
  2. A CLI-spawned app-server child process runs in hosted mode, where account providers must be received via a provider/updateAccountConfig push from the host.
  3. While the RPC responds with status: "received", the snapshot payload is silently discarded right before registry merge by this gate:
    if (snapshot.basedOnZCodeBuiltinRevision !== configSource.zcodeBuiltinRevision) { /* discard */ }
    
  4. The Type Mismatch:
    • The incoming wire schema enforces basedOnZCodeBuiltinRevision as a string (z.string().trim()).
    • The internal configSource.zcodeBuiltinRevision is stored as a number (e.g. value 28).
    • Because of strict inequality (!==), the condition evaluates to true on 100% of payloads ("28" !== 28), guaranteeing that no snapshot can ever pass the gate and merge into the provider registry.

Environment & Reproduction

Proposed Fix
  1. Normalize Revision Comparison:
    Coerce both sides of the comparison to strings or numbers before evaluation:
    if (String(snapshot.basedOnZCodeBuiltinRevision) !== String(configSource.zcodeBuiltinRevision)) { ... }
    
  2. Schema Coercion:
    Allow basedOnZCodeBuiltinRevision in the wire schema to accept z.union([z.string(), z.number()]) or apply z.coerce.number().
  3. Optional Standalone Flag:
    Provide a CLI argument (e.g. --standalone-providers) allowing app-server to read credentials directly from local credential storage.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the zcode.cjs app-server entry point and trace provider/updateAccountConfig handling through the revision comparison before registry merge. Reproduce the session/setModel or session/send request with the account model, then verify that the revision values compare consistently, the provider registry receives the snapshot, and no provider_not_found event occurs.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.