Back to home@flashyiyi

dsh-zcode-persona

Make the model believe it is inside the Z.ai Code (Zhipu ZCode) agent environment. DSH system-prompt waterfall plugin.

Stars
0
Language
TypeScript
Created
Sep 5, 2026
Updated
Sep 6, 2026
GitHub repo

Introduction

dsh-zcode-persona

Provisions a ZCode-identity GLM Coding Plan channel for DeepSeek Harness so the Zhipu gateway recognizes the DSH client as ZCode, activating the official limited-time perk: equivalent model calls deduct only 67% of quota (i.e. 1.5× usable quota). No prompt/persona changes (the server-side check only looks at request characteristics, not the system prompt).

English | 简体中文

Mechanism & evidence

Zhipu's docs (docs.bigmodel.cn → GLM Coding Plan → ZCode) state that GLM Coding Plan users signed in via ZCode enjoy an all-day 1.5× usage allowance (67% deduction). The check happens server-side on HTTP request characteristics. Field-level evidence for the identity headers:

  • TriDefender/zcode-api: src/proxy/identity.ts mirrors the ZCode bundle's pio field-for-field (refreshed 2026-08-07); the README says "it's all about the 1.5x usage on frontier models";
  • LINUX DO t/2531858: reusing ZCode request headers in another client, the perk applied.

After ready, this plugin idempotently writes one provider into the llm-pi-ai settings namespace via the ctx.settings seam (default key zai-coding-cn, pointing at the domestic endpoint https://open.bigmodel.cn/api/coding/paas/v4), with requests carrying the full ZCode identity header set: HTTP-Referer, X-ZCode-App-Version (default 3.11.2), X-Title: Z Code@cli, X-ZCode-Agent: glm, X-Platform, X-Release-Channel: production, X-Client-Language, X-Client-Timezone, X-Os-Category, X-Os-Version, X-Device-Mid (stable host-fingerprint-derived UUID). The write is a path-level mutate — only the provider key is added; existing providers (doubao, opencode-go, …) are never touched. The write passes through llm-pi-ai's own schema and serviceability validation; a refusal leaves existing routes untouched. pi-ai ships the zai-coding-cn catalog (thinkingFormat: zai wire compatibility is inherited); models missing from the catalog (glm-5.3, glm-5.3-flash) are declared with full specs.

Known boundary: DSH enforces product-attribution User-Agent (dsh-llm attributionHeaders); llm-pi-ai strips user-agent from profile headers and substitutes the harness UA. So User-Agent: ZCode/… cannot be delivered via configuration; every other ZCode-specific header passes through. Whether the gateway fingerprint accepts this needs a live check; if not, a local reverse proxy restoring the UA is required (not built into this plugin).

Configuration (reload the plugin after changing)

KeyDefaultMeaning
codingPlan.enabledtrueProvisioning master switch.
codingPlan.providerKeyzai-coding-cnllm-pi-ai providers dict key (route id).
codingPlan.apiKeyEnvGLM_CODING_API_KEYEnv-var reference for the Coding Plan API key.
codingPlan.displayNameGLM Coding Plan (ZCode)Name shown in the model settings UI.
codingPlan.appVersion3.11.2X-ZCode-App-Version; update to the real client after upgrading ZCode.
codingPlan.sourceTitlecliX-Title: Z Code@{sourceTitle}.
codingPlan.deviceMid''X-Device-Mid; empty derives a stable host-fingerprint UUID.
codingPlan.baseURLhttps://open.bigmodel.cn/api/coding/paas/v4Domestic Zhipu Coding Plan OpenAI-compatible endpoint.
codingPlan.modelsDEFAULT_MODELS in sourceModel list served by this route (replaces the catalog).

Usage & verification

⚠️ If the plan is currently at its 5-hour cycle quota limit, wait for the cycle to reset before firing observable billing requests (official: quota refreshes 5 hours after consumption).

  1. After provisioning, pick glm-5.3 / glm-5.2 etc. under the GLM Coding Plan (ZCode) provider in Settings → Models;
  2. Set the env var GLM_CODING_API_KEY=<your Coding Plan API key> (generated on the Zhipu open platform Coding Plan page; requires an active GLM Coding Plan / bigmodel subscription);
  3. After the quota resets, fire some real requests and check usage: quota should be deducted at 67% (equivalent 1.5×). If it deducts at 100%, the gateway fingerprint checks more than these headers (e.g. User-Agent), and a local reverse proxy restoring the full UA is required.

⚠️ Zhipu enforces risk controls on plan usage (shared accounts and abnormal clients may trigger verification, throttling, or bans — see LINUX DO discussions). Personal use, low concurrency, and a genuine Coding Plan subscription are the baseline.

Compliance

Intended for behavior customization of your own subscription, research, and testing. Impersonating ZCode or any other brand to serve others or to bypass upstream service restrictions is at your own risk; please honor Zhipu's terms of service.

Build

DSH_CHECKOUT=<checkout> bash scripts/build.sh