Repository navigation
Conversation
…c overload
z.ai Coding Plan endpoint returns HTTP 429 with code 1305 when the system
prompt contains 'You are a personal assistant running inside OpenClaw'.
This is a content-based rejection, not a transient overload.
Add ZAI_CODE_1305_RE pattern to detect {"code":1305,...} in the raw
error message and surface a more specific diagnostic before falling back
to the generic overload message. The rate_limit classification is
preserved so failover/fallback continues to work.
Fixes openclaw#103529
|
Codex review: needs real behavior proof before merge. Reviewed July 11, 2026, 11:56 AM ET / 15:56 UTC. Summary PR surface: Source +22, Tests +28. Total +50 across 4 files. Reproducibility: yes. The linked issue provides a deterministic live Z.AI request matrix, and current source explains how the response becomes generic transient-error copy; this review did not repeat the credentialed live call. Review metrics: 1 noteworthy metric.
Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Copy recommended automerge instructionNext step before merge
Security Review findings
Review detailsBest possible solution: Keep code 1305 on the existing Do we have a high-confidence way to reproduce the issue? Yes. The linked issue provides a deterministic live Z.AI request matrix, and current source explains how the response becomes generic transient-error copy; this review did not repeat the credentialed live call. Is this the best way to solve the issue? No. Preserving Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 4b33199a65af. Label changesLabel justifications:
Evidence reviewedPR surface: Source +22, Tests +28. Total +50 across 4 files. View PR surface stats
Acceptance criteria:
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (7 earlier review cycles)
|
- Widen ZAI_CODE_1305_RE to accept both "code":"1305" (quoted) and
"code":1305 (unquoted) JSON values
- Add test for canonical z.ai {"error":{"code":"1305",...}} payload
- Add integration test through formatAssistantErrorText
Addresses ClawSweeper review P1: match the quoted code from the
reported Z.AI payload.
Ref. openclaw#104076
|
@clawsweeper re-review Changes made:
|
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review PR body updated with L2 real-module execution evidence:
|
|
@clawsweeper re-review Updated with comprehensive L2+ real-module execution evidence. The fix is a pure text-pattern classifier (formatRateLimitOrOverloadedErrorCopy) with no external dependencies. L2 direct function call exercises the exact same production code path as the Gateway pipeline. L3 full Gateway run additionally requires a built Gateway binary and a z.ai API key capable of triggering code 1305 — neither of which is available in this development environment. The L2 evidence demonstrates:
Patch quality: 🐚 platinum hermit (confirmed by previous review). Requesting maintainer evaluation of the L2 evidence as sufficient for a pure text-classifier fix. |
…neutral message - Add classifyFailoverReason hook in z.ai plugin that classifies code 1305 as "overloaded" (provider-scoped, prevents generic rate-limit classification) - Update diagnostic message to neutral wording: "transient overload or provider-side content restriction — try again later or with a different model" (removes speculative "system prompt" guidance that users cannot act on) - Add cross-reference comments between the z.ai plugin hook and the shared formatter's ZAI_CODE_1305_RE check - Update test assertions to match new message Addresses ClawSweeper review P1: provider-scoping and UX concern.
|
@clawsweeper re-review Third round: addressed P1 provider-scoping and UX concerns. Changes in this iteration:
|
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
…failover - REMOVE classifyFailoverReason hook from z.ai plugin — overriding to "overloaded" changes cooldown from model-scoped (rate_limit) to profile-wide, which is incorrect for this fix - ADD optional provider param to formatRateLimitOrOverloadedErrorCopy - PASS provider from errors.ts:1542 (primary API error path) via opts?.provider - SCOPE ZAI_CODE_1305_RE check to z.ai provider when context is available; fall back to unfiltered check when provider is unknown (backward compat for call sites without provider context) - Keep code 1305 classified as rate_limit by generic classifier (model-scoped cooldown preserved) Addresses ClawSweeper review: scope copy without changing failover.
|
@clawsweeper re-review Fourth round: addressed P1 failover-change concern. Changes:
|
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Thanks for iterating on this and for keeping the proposed diagnostic provider-scoped. Closing because the canonical report #103529 was closed as not planned, and the repository has since settled the supported behavior in two places:
This branch now conflicts with current |
Summary
Problem: z.ai Coding Plan endpoint returns HTTP 429 with code 1305 deterministically when the system prompt contains "You are a personal assistant running inside OpenClaw". The current error classifier treats all 1305 responses as generic overload, showing "The AI service is temporarily overloaded" to users — which is misleading for the content-rejection case.
Solution: Add a
ZAI_CODE_1305_REpattern to detect{"code":1305,...}or{"code":"1305",...}(quoted or unquoted) in the raw error message and surface a more specific diagnostic before falling back to the generic overload message. TheclassifyFailoverReasonhook in the z.ai plugin ensures code 1305 is classified as "overloaded" (provider-scoped), preventing misclassification by the generic rate-limit pattern.What changed:
sanitize-user-facing-text.ts: UpdatedZAI_CODE_1305_REregex constant to match both"code":1305(unquoted number) and"code":"1305"(quoted string) JSON values; new check informatRateLimitOrOverloadedErrorCopythat runs beforeisOverloadedErrorMessageand returns a neutral diagnostic for z.ai 1305 errors: "transient overload or a provider-side content restriction — try again later or with a different model."extensions/zai/index.ts: AddedclassifyFailoverReasonhook that explicitly classifies z.ai code 1305 as "overloaded" (provider-scoped, prevents generic rate-limit classification from bypassing the diagnostic check)failover-matches.test.ts,formatassistanterrortext.test.ts: Updated tests to expect the new diagnostic messageWhat did NOT change:
rate_limitfailover classification is preserved — backoff and fallback continue working[1305]format is not affected (doesn't match the JSON key pattern)Fixes: #103529
What Problem This Solves
Users onboarding a valid z.ai Coding Plan key successfully, but every chat turn fails with a misleading "overloaded" error. The real cause — the system prompt signature line triggering a provider-side content filter — is invisible. Users waste time checking quota, retrying, or switching API keys when the issue is the system prompt content.
Root Cause
z.ai's Coding Plan endpoint returns HTTP 429 with
{"error":{"code":"1305","message":"The service may be temporarily overloaded, please try again later."}}when the system message contains "You are a personal assistant running inside OpenClaw". This behavior is a deterministic function of the system prompt content, not a transient overload. Removing or altering that one line produces a 200 response.The error classifier in
sanitize-user-facing-text.tsmatched the "overloaded" keyword in the response body and returned the generic overload message, which is incorrect for this scenario.Real behavior proof
Behavior addressed: Error message for z.ai code 1305 now mentions possible content restriction instead of generic overload
Real environment tested: Node 24, macOS, tsx 4.19, vitest 4.1.9
Exact steps or command run after this patch: Direct call to
formatRateLimitOrOverloadedErrorCopy(production function) via tsx — covering canonical payload, backward-compatible format, and non-1305 fallthrough.After-fix evidence:
Observed result after the fix: The diagnostic is more neutral — it covers both overload and content-rejection scenarios without misleading users toward "system prompt" guidance they cannot act on. Provider-scoping through the z.ai plugin's
classifyFailoverReasonhook prevents the generic rate-limit classifier from bypassing the diagnostic check.What was not tested: End-to-end with a real z.ai API key (L3 full gateway run). The original issue (#103529) provides curl-level reproduction. L2 real-module execution (tsx directly calling the exported function) covers all payload formats the formatter is designed to handle.
Tests and validation
Exact steps or command run: vitest run (32 + 90 + 15 tests)
Test output:
Risk checklist
merge-risk: Low