Repository navigation
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8c84d97b7b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…emPrompt z.ai Coding Plan endpoints deterministically reject requests whose system prompt contains OpenClaw's exact opening identity line (HTTP 429, code 1305, disguised as overload). Rewrite that one line to a measured-safe equivalent via the provider transformSystemPrompt seam, scoped to Coding Plan base URLs only, so ordinary z.ai routes keep canonical prompt bytes. Fixes openclaw#103529
8c84d97 to
179050b
Compare
|
I'm not sure I wanna play this cat and mouse game - if you wanna change this clean on your end ask your agent to write a small plugin that rewites system prompt via a hook. |
|
@felirami adding a docs datapoint for #103529 / this PR. Z.ai's published docs do support the general upstream explanation that OpenClaw/general-agent traffic can hit temporary rate limits under load:
That said, I don’t think those docs explain away the measurement in #103529: the docs describe dynamic/high-load behavior, while the report/PR evidence is deterministic on an exact system-message substring, with same key/endpoint/UA/params flipping |
Closes #103529
What Problem This Solves
Fixes an issue where users who onboard a valid z.ai Coding Plan key would see every chat turn fail with
⚠️ API rate limit reached. Please try again later.even though the key, quota, and endpoint are all healthy. As measured in #103529 (and re-confirmed live below), the z.ai Coding Plan endpoints (api.z.ai/api/coding/paas/v4andopen.bigmodel.cn/api/coding/paas/v4) deterministically return HTTP 429 / code 1305 whenever the request'ssystemmessage contains OpenClaw's exact opening identity lineYou are a personal assistant running inside OpenClaw— the match is case-sensitive, exact-substring, and system-role-only. Onboarding succeeds (the detection probe carries no system prompt), then every real turn fails, with no in-product recovery.Why This Change Was Made
This uses the fix shape identified in the ClawSweeper triage on #103529: the provider-owned
transformSystemPromptseam, which exists precisely for small transport compatibility rewrites after OpenClaw assembles the full prompt. The z.ai plugin now rewrites only the blocked line —running inside OpenClaw→running within OpenClaw, a substitution the issue's measurement matrix (and the live run below) shows passes the filter while any single-character deviation returns 200 — and only when the request routes to a Coding Plan path (/api/coding/, which also covers user reverse proxies that preserve the upstream path).Route detection mirrors core model resolution (per Codex review feedback): the provider config entry is resolved like core
resolveConfiguredProviderConfig(exact key, then normalized-key match), and a per-modelmodels[]entrybaseUrl— matched in plain or provider-scoped id form likematchesProviderScopedModelId— takes precedence over the provider-levelbaseUrl, matching the transport'smetadataOverrideBaseUrl ?? providerConfiguredBaseUrlprecedence. Ordinary z.ai routes and all other providers keep byte-identical canonical prompts. The blocked-string literal in the plugin is a provider-contract match against z.ai's measured server-side filter, not a cosmetic string; this is documented at the constant. Complementary to #104076, which improves the 1305 error copy but does not make Coding Plan turns succeed.Non-goal: this does not decide whether z.ai intends to block OpenClaw on Coding Plan; that upstream question stays with maintainers per the issue discussion. Until it is answered, this restores a working chat path for affected users.
User Impact
z.ai Coding Plan users (global and CN) get working chat turns immediately after onboarding, instead of a fully broken session disguised as a rate limit. No config changes, no new options, no behavior change for any other provider or z.ai route.
Evidence
Live validation (glm-5.2,
api.z.ai/api/coding/paas/v4, UAOpenAI/JS 6.39.1)Measurement matrix — only the
systemcontent varies:End-to-end through the actual production transform (
transformZaiCodingSystemPrompt) — its real output POSTed to the live endpoint, for both routing configurations:So the shipped transform turns a deterministically-blocked Coding Plan request into a successful one, while leaving every other
OpenClawreference in the prompt intact.Automated tests / checks
extensions/zai/coding-prompt-compat.test.ts(provider-level and per-model route scoping incl. proxy paths and provider-scoped ids, precedence of per-model overrides in both directions, normalized provider-key lookup, single/multiple occurrence rewrite, byte-identical pass-through for non-coding routes, case-sensitivity guard) and a wiring test inextensions/zai/index.test.tsproving the registered provider hook applies the rewrite for/api/coding/base URLs and returnsundefinedfor the ordinary endpoint.pnpm test:extension zai— 7 files, 54 tests passed (includesprovider-runtime.contract.test.ts,onboard.test.ts).pnpm test src/agents/system-prompt.test.ts src/agents/embedded-agent-runner/run/attempt-system-prompt.test.ts src/agents/plugin-text-transforms.test.ts— 4 files, 106 tests passed (prompt-seam callers unaffected).pnpm check:test-typesandpnpm lint:extensionsgreen locally after rebasing onto latestmain(the earliercheck-lintCI failure was the pre-existingsrc/wizard/clack-prompter.test.tsissue fixed onmainby test(wizard): satisfy promise executor lint #107301; the earliercheck-test-typesfailure was a test-file cast in this PR, fixed).pnpm check— all lanes green except thenpm shrinkwrap guard, which fails identically on a cleanmaincheckout (root,extensions/llama-cpp,extensions/twitchreport stale) and is unrelated to this diff;node scripts/generate-npm-shrinkwrap.mjs --changed --checkreports "No shrinkwrap-managed package changes detected".AI-assisted (Claude) with human review; the transform literal and scoping decisions follow the measurements and fix shape recorded in #103529 and are confirmed by the live runs above.