Skip to content

Fix channel monitor false errors for Claude and Gemini#2158

Open
Go1c wants to merge 5 commits intoWei-Shaw:mainfrom
Go1c:main
Open

Fix channel monitor false errors for Claude and Gemini#2158
Go1c wants to merge 5 commits intoWei-Shaw:mainfrom
Go1c:main

Conversation

@Go1c
Copy link
Copy Markdown

@Go1c Go1c commented May 2, 2026

Summary

  • Fix channel monitor false errors for Claude/Gemini probes.
  • Preserve selected monitor request-template headers for Claude Code probes instead of overwriting them, and normalize duplicate header names case-insensitively so template/user values win deterministically.
  • Keep default monitor probes unchanged for normal upstreams, but when Anthropic explicitly rejects a probe as non-Claude-Code usage, automatically retry with the same Claude Code-style request shape used by real Claude Code traffic.
  • Regenerate Claude Code monitor fingerprints on that rejection path: metadata.user_id and x-client-request-id are fresh on retry.
  • Improve Claude/Gemini monitor response extraction for thinking/SSE output.
  • Retry once on transient upstream 5xx/Cloudflare responses and response-header timeouts.

Fixes #1946

Test Plan

  • From backend/: GOCACHE=/tmp/sub2api-go-build-cache GOMODCACHE=/tmp/sub2api-go-mod-cache go test -count=1 -tags=unit ./internal/service -run "RunCheckForModel_AnthropicCompatibilityProbePreservesClaudeCodeTemplateHeaders|TestMergeHeaders_NormalizesDuplicateHeaderNames" -v
  • From backend/: GOCACHE=/tmp/sub2api-go-build-cache GOMODCACHE=/tmp/sub2api-go-mod-cache go test -count=1 -tags=unit ./internal/service -run "ChannelMonitor|RunCheckForModel|Challenge"
  • From backend/: GOCACHE=/tmp/sub2api-go-build-cache GOMODCACHE=/tmp/sub2api-go-mod-cache go test ./...
  • From frontend/: npm run build

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 2, 2026

All contributors have signed the CLA. ✅
Posted by the CLA Assistant Lite bot.

@Go1c Go1c changed the title Fix channel monitor compatibility probes for Claude and Gemini Fix channel monitor false errors for Claude and Gemini May 2, 2026
@Go1c
Copy link
Copy Markdown
Author

Go1c commented May 2, 2026

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request May 2, 2026
@Go1c
Copy link
Copy Markdown
Author

Go1c commented May 2, 2026

I have read the CLA Document and I hereby sign the CLA

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

【bug】anthropic监控渠道取值逻辑问题,text并不永远是content.0.text

1 participant