Skip to content

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

Description

@romangalaxys10-spec

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions