时间:2026-08-06 11:42 | 来源:墨客学术 | 作者:墨客学术 | 点击:次
Summary
claude-mem's worker generates observations against real Anthropic (CLAUDE_MEM_CLAUDE_AUTH_METHOD=subscription, the default), but sends the captured conversation transcript as message history — including thinking blocks whose signature was produced by a different provider (Z.AI GLM, used as the main Claude Code provider via ANTHROPIC_BASE_URL). Anthropic validates thinking-block signatures and rejects foreign ones → 400 Invalid signature in thinking block → SDK retries up to 11× → wasted Anthropic quota, log spam, background CPU. The main agent loop is unaffected, but on a heavy session this produced 428 such errors in a single day (and recurs every turn a thinking-enabled assistant message is in history).
Environmentclaude-mem: 13.10.2
Claude Code: 2.1.202
Main CC provider: Z.AI GLM (ANTHROPIC_BASE_URL=https://api.z.ai/api/anthropic, ANTHROPIC_DEFAULT_SONNET_MODEL=glm-5.2)
claude-mem auth: CLAUDE_MEM_PROVIDER=claude, CLAUDE_MEM_CLAUDE_AUTH_METHOD=subscription (defaults — worker calls real api.anthropic.com, bypassing the GLM token/ANTHROPIC_BASE_URL)
ReproductionConfigure the CC main loop against a non-Anthropic Anthropic-compatible endpoint that returns thinking blocks (e.g. Z.AI GLM).
Keep claude-mem on default subscription auth, so its worker calls real api.anthropic.com for observation generation.
Run a multi-turn session with extended thinking enabled; let claude-mem generate observations.
In ~/.vscode-server/data/logs/*/Anthropic.claude-code/Claude VSCode.log:
[ERROR] API error (attempt 1/11): 400 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.1.content.0: Invalid `signature` in `thinking` block"},"request_id":"req_011Ccu…"} [WARN] [thinking] server rejected a thinking block; stripping all thinking blocks and retrying.
Evidence / root causeZ.AI does not validate thinking signatures at all. Direct calls to api.z.ai/api/anthropic/v1/messages return 200 for a thinking block with a FAKE signature, with NO signature field, and with an Anthropic-format signature — so the 400 is not coming from the main (GLM) provider.
All signature-400s carry Anthropic req_… request_ids (Z.AI error-ids are timestamp-format, e.g. 20260712070400…), confirming they originate at real api.anthropic.com.
claude-mem's worker is the only component here on the subscription/Anthropic path, and the 400s correlate with claude-mem activity in the logs.
In scripts/worker-service.cjs, captured transcript streams are reconstructed into thinking blocks carrying a signature (via signature_delta accumulation) and then sent as message history to the LLM. When that LLM is real Anthropic but the thinking blocks originated from GLM, the signatures are foreign → Anthropic rejects them.
Suggested fixBefore sending captured transcript history to any LLM for observation generation, strip thinking / redacted_thinking blocks (or at minimum their signature fields) from assistant turns. Signatures are provider-specific and non-portable: Anthropic validates them, third-party endpoints ignore them — so stripping is safe for claude-mem's summarization calls (which don't rely on the user's thinking chain continuity) and eliminates the reject-retry tax everywhere. A toggle (e.g. CLAUDE_MEM_STRIP_THINKING=1, default on) would let users opt out.
Related WorkaroundUntil fixed: either point claude-mem at the same non-Anthropic provider (CLAUDE_MEM_PROVIDER/CLAUDE_MEM_MODEL — note claude-* model names don't resolve on Z.AI, returns 1211 Unknown Model), or tolerate the background retry tax, which does not affect the main agent loop or generation quality.