Skip to content

feat: stabilize custom Claude routing and quota failover - #156

Closed
baoluong2900 wants to merge 7 commits into
Quorinex:mainfrom
baoluong2900:fix/custom-claude-routing-v2
Closed

baoluong2900 wants to merge 7 commits into
Quorinex:mainfrom
baoluong2900:fix/custom-claude-routing-v2

Conversation

@baoluong2900

Copy link
Copy Markdown

Summary

  • integrate configurable external Anthropic/OpenAI routing on top of the latest upstream stream-integrity fixes
  • keep cooling Kiro accounts ineligible and honor bounded upstream Retry-After values
  • add a circuit breaker with atomic half-open probe admission
  • preserve the original model when external routing falls back to Kiro
  • normalize Claude Code stop-hook JSON responses
  • propagate quota status and Retry-After through Claude, OpenAI, Responses, and web-search terminal paths
  • expose External API controls in the existing admin UI

Verification

  • go test ./... -count=1
  • go vet ./...
  • go build
  • targeted pool/account race tests
  • targeted quota/circuit race tests
  • Docker image build completed successfully

This supersedes #155, which was based on an older main and became conflicted after the stream-integrity merges.

Integrate external Anthropic/OpenAI routing on top of the latest stream-integrity fixes, with account cooldown enforcement, bounded Retry-After handling, circuit breaker admission, stop-hook normalization, and admin configuration.
@baoluong2900

Copy link
Copy Markdown
Author

Follow-up review fixes pushed in ce47c6b: Kiro endpoint fallback now retains the longest bounded Retry-After across all 429 responses, with a multi-endpoint regression test. The branch remains green on go test ./..., go vet ./..., and go build.

@baoluong2900

Copy link
Copy Markdown
Author

Final review hardening pushed in 76e6398: buffered native Claude and OpenAI external responses are now fully read before committing headers or closing the circuit. A body-read/truncation error returns to the Kiro fallback with an untouched client response. Regression tests cover both helpers, including targeted race runs. Full tests, vet, and build remain green.

@baoluong2900

Copy link
Copy Markdown
Author

Additional cleanup pushed: 7cf492c removes duplicate completed-request logging for retryable external attempts; 0648fcb restores deterministic per-request proxy-environment evaluation (fixing the full-suite proxy regression). Current verification: go test ./..., go vet ./..., go build, targeted race tests, and Docker build kiro-go:pr156-verify all pass.

@baoluong2900

Copy link
Copy Markdown
Author

Completed the remaining buffered-response review coverage in 7400fdf: stop-hook normalization and Claude-to-OpenAI bridge now fully read the upstream body before circuit success or response commit; read/truncation failures cleanly return to Kiro fallback. New regression tests pass, including targeted race runs. Full go test ./..., vet, and build remain green.

@baoluong2900

Copy link
Copy Markdown
Author

Stream completion hardening pushed in 34c33d3: native Claude and OpenAI external streams no longer close the circuit or log success when the upstream body terminates with a non-EOF read error after response commit. Such requests are recorded failed and feed the circuit breaker; regression and targeted race tests cover both paths. Full tests, vet, and build remain green.

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.

1 participant