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)
- The desktop chat engine runs in standalone mode (initializing account providers directly from local credential stores).
- 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.
- 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 */ }
- 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
- Normalize Revision Comparison:
Coerce both sides of the comparison to strings or numbers before evaluation:
if (String(snapshot.basedOnZCodeBuiltinRevision) !== String(configSource.zcodeBuiltinRevision)) { ... }
- Schema Coercion:
Allow basedOnZCodeBuiltinRevision in the wire schema to accept z.union([z.string(), z.number()]) or apply z.coerce.number().
- Optional Standalone Flag:
Provide a CLI argument (e.g. --standalone-providers) allowing app-server to read credentials directly from local credential storage.
Bug Description
In ZCode 3.12.3 (tested on macOS arm64), when using
zcode.cjs app-serverover stdio in hosted mode, account models (e.g.GLM-5.3-Flashunderaccount:zai-individual-coding-plan) cannot be selected via the RPC protocol:Error Returned:
→ -32603 Provider Registry 中不存在 ModelAdditionally, turns initiated via
session/sendwith amodelSelectionoverride stall indefinitely with aprovider_not_foundevent.Root Cause Analysis (Confirmed via Bundle Disassembly)
app-serverchild process runs in hosted mode, where account providers must be received via aprovider/updateAccountConfigpush from the host.status: "received", the snapshot payload is silently discarded right before registry merge by this gate:basedOnZCodeBuiltinRevisionas a string (z.string().trim()).configSource.zcodeBuiltinRevisionis stored as a number (e.g. value28).!==), the condition evaluates totrueon 100% of payloads ("28" !== 28), guaranteeing that no snapshot can ever pass the gate and merge into the provider registry.Environment & Reproduction
zcode.cjs app-server(--stdio/--surface desktop)박명철 [Z.ai]on Z.ai Community DiscordProposed Fix
Coerce both sides of the comparison to strings or numbers before evaluation:
Allow
basedOnZCodeBuiltinRevisionin the wire schema to acceptz.union([z.string(), z.number()])or applyz.coerce.number().Provide a CLI argument (e.g.
--standalone-providers) allowingapp-serverto read credentials directly from local credential storage.