open-code-review/cmd/opencodereview
kite c89282f4db
Some checks are pending
CI / cross-compile (arm64, linux) (push) Waiting to run
CI / cross-compile (arm64, windows) (push) Waiting to run
CI / cross-compile (arm64, darwin) (push) Waiting to run
Deploy Pages / deploy (push) Blocked by required conditions
Deploy Pages / build (push) Waiting to run
CI / test (push) Waiting to run
CI / cross-compile (amd64, darwin) (push) Waiting to run
CI / cross-compile (amd64, windows) (push) Waiting to run
CodeQL Advanced / Analyze (go) (push) Waiting to run
CodeQL Advanced / Analyze (actions) (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
feat(llm): support custom retry status codes via retry_codes config (#818)
* feat(llm): support custom retry status codes via retry_codes config

Add a retry_codes configuration field that allows users to specify
additional HTTP status codes (4xx) that should trigger exponential
backoff retry. This targets self-hosted LLM clusters that misuse
status codes like 403 or 400 for rate limiting.

Implementation uses SDK middleware to inject the x-should-retry: true
response header when a configured status code is encountered, leveraging
the existing SDK retry mechanism (up to 5 retries with exponential
backoff) without any SDK modifications.

Configuration is supported via:
- Provider config: providers.<name>.retry_codes / custom_providers.<name>.retry_codes
- Legacy llm config: llm.retry_codes
- CLI: ocr config set providers.<name>.retry_codes 403,400

Also fixes cloneProviderEntry to copy previously missing fields
(TimeoutSec, ExtraHeaders, RetryCodes) for TUI rollback correctness.

* test(llm): add unit tests for retry_codes feature

Cover ParseRetryCodes validation, retryCodesMiddleware behavior,
resolver integration (provider and legacy config paths, invalid codes),
and end-to-end retry via httptest for both OpenAI and Anthropic clients.

* feat(llm): silently filter redundant retry_codes (408/409/429) instead of erroring

Replace validateRetryCodes with sanitizeRetryCodes that filters out
SDK-default codes and returns warnings. The resolve phase silently
drops redundant codes without interrupting startup. The config set
command prints warnings to stderr so users are informed.

This makes the tool friendlier for users migrating from other tools
who habitually configure 429 and similar codes.

* test(tui): add coverage for cloneProviderEntry deep-copy of TimeoutSec/RetryCodes/ExtraHeaders

Verify that the clone correctly copies these fields and that
mutations to the clone do not affect the original. Also pin the
nil-stays-nil behavior for RetryCodes and ExtraHeaders.

* docs(llm): fix contradictory ParseRetryCodes comment

* test(config): cover retry_codes warning output in config set path

Verify that redundant codes (429, 408) emit a WARNING to stderr while
still writing the valid codes to config. Also verify that valid-only
codes produce no warning output.
2026-08-10 16:52:17 +08:00
..
apply_provider_field_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
background_file.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
background_file_test.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
budget_output_test.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
compat_test.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
completion.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
config_cmd.go feat(llm): support custom retry status codes via retry_codes config (#818) 2026-08-10 16:52:17 +08:00
config_cmd_test.go feat(llm): support custom retry status codes via retry_codes config (#818) 2026-08-10 16:52:17 +08:00
config_dispatch_test.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
config_runset_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
config_unset_error_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
delegate_cmd.go fix(cli): stop preview from creating a review session (#784) 2026-08-08 20:55:54 +08:00
delegate_exec_test.go fix(cli): stop preview from creating a review session (#784) 2026-08-08 20:55:54 +08:00
delegate_helpers_test.go feat: add QCA delegation integration (#762) 2026-08-07 13:58:27 +08:00
emit_run_result_test.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
flag_suggest.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
flag_suggest_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
flags_test.go feat(config): make per-file token limit configurable (#716) 2026-08-07 11:23:38 +08:00
git.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
git_test.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
llm_cmd.go fix(cli): reject unexpected positional arguments (#749) 2026-08-06 21:41:07 +08:00
main.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
misc_helpers_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
output.go fix(cli): honor --format json for review and scan preview (#783) 2026-08-08 13:09:08 +08:00
output_helpers_test.go fix(cli): honor --format json for review and scan preview (#783) 2026-08-08 13:09:08 +08:00
output_manifest_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
output_test.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
parent_cmd_test.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
procattr_unix.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
procattr_windows.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
provider_cmd.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
provider_cmd_test.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
provider_config_apply_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
provider_tui.go feat(llm): support custom retry status codes via retry_codes config (#818) 2026-08-10 16:52:17 +08:00
provider_tui_cpinput_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
provider_tui_customform_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
provider_tui_deleteconfirm_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
provider_tui_editsave_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
provider_tui_funcs_test.go feat(llm): support custom retry status codes via retry_codes config (#818) 2026-08-10 16:52:17 +08:00
provider_tui_manualenter_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
provider_tui_modeltui_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
provider_tui_persist_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
provider_tui_rollback_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
provider_tui_savefail_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
provider_tui_test.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
review_cmd.go fix(cli): stop preview from creating a review session (#784) 2026-08-08 20:55:54 +08:00
review_cmd_test.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
review_helpers_test.go fix(cli): stop preview from creating a review session (#784) 2026-08-08 20:55:54 +08:00
review_mcp_more_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
review_resume_more_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
root.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
rules_check_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
rules_cmd.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
scan_cmd.go fix(cli): stop preview from creating a review session (#784) 2026-08-08 20:55:54 +08:00
scan_cmd_test.go feat(config): make per-file token limit configurable (#716) 2026-08-07 11:23:38 +08:00
scan_helpers_test.go fix(cli): stop preview from creating a review session (#784) 2026-08-08 20:55:54 +08:00
scan_resume_more_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
session_cmd.go fix(cli): reject unexpected positional arguments (#749) 2026-08-06 21:41:07 +08:00
session_cmd_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
session_complete_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
session_display_more_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
shared.go feat(config): make per-file token limit configurable (#716) 2026-08-07 11:23:38 +08:00
shared_flags.go feat: add QCA delegation integration (#762) 2026-08-07 13:58:27 +08:00
shared_llmruntime_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
shared_test.go feat(config): make per-file token limit configurable (#716) 2026-08-07 11:23:38 +08:00
shell_unix.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
shell_windows.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
smallfiles_test.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
version.go fix(cli): reject unexpected positional arguments (#749) 2026-08-06 21:41:07 +08:00
viewer_cmd.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
zero_args_test.go fix(cli): reject unexpected positional arguments (#749) 2026-08-06 21:41:07 +08:00