Skip to content

fix(ai): keep the HTTP status of a Claude reply after retries - #4976

Merged
dan-petty merged 4 commits into
mainfrom
fix/3797-claude-status-after-retries
Nov 12, 2026
Merged

dan-petty merged 4 commits into
mainfrom
fix/3797-claude-status-after-retries

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

The Claude path sends through the shared client, whose retry transport raises httpx2.HTTPStatusError after its last try. The Anthropic SDK raises APIConnectionError from that error, so the client built a connection error with no status: a reply 529 gave the reason LLM_INFERENCE_ERROR, and a reply 401 did not give the credentials error. _map_anthropic_errors now reads the cause of the APIConnectionError and builds the error from the status error with _provider_http_error, as for a status error that the SDK did not wrap. A connection error from another cause keeps no status. The Claude error tests now use the shared client with its retry transport.

Closes #3797

Change: openspec/changes/archive/2026-11-12-3797-a-claude-reply-loses-its-http/

@dan-petty dan-petty added type/bug Type bug: the code does not do what it must scope/ai AI review pipeline, personas, prompts, LLM client, or RAG labels Nov 12, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Test record

Local checks on the final code (rebased on origin/main):

  • uv run devops ci test tests/ai/client/test_ai_client_error_reason.py tests/ai/client/test_claude_provider.py tests/ai/client/test_ai_streaming.py: 75 passed.
  • uv run devops ci test tests/ai/client/test_ai_client_finish_reasons.py tests/ai/client/test_ai_client_providers_and_embeddings.py tests/ai/client/test_ai_client_structured.py tests/ai/client/test_ai_client_telemetry.py tests/ai/client/test_ai_gateway_base_url.py tests/ai/client/test_ai_client_retries.py tests/ai/test_thinking_providers.py: 131 passed.
  • uv run mypy src/devops_cli/ai/client/claude.py: no issues.
  • uv run devops ci --check --only lint,format,docs,constructs,openspec,test-settings,test-tree,startup-imports,swallowed-failures: all rows pass.
  • No paid model call: the tests use the web fake.

Fail-to-pass

uv run devops ci fail-to-pass --base origin/main:

  passed on base: tests.ai.client.test_ai_client_error_reason::test_a_provider_that_builds_its_own_error_gives_the_status_or_the_timeout[claude-refused]
  passed on base: tests.ai.client.test_ai_client_error_reason::test_the_reason_is_the_code_then_the_status_or_the_timeout[status-with-no-phrase]
  passed on base: tests.ai.client.test_ai_client_error_reason::test_a_call_that_times_out_says_so
  passed on base: tests.ai.client.test_ai_client_error_reason::test_the_reason_is_the_code_then_the_status_or_the_timeout[timeout-and-status]
  passed on base: tests.ai.client.test_ai_client_error_reason::test_a_provider_that_builds_its_own_error_gives_the_status_or_the_timeout[ollama-timeout]
  passed on base: tests.ai.client.test_ai_client_error_reason::test_a_provider_that_builds_its_own_error_gives_the_status_or_the_timeout[claude-timeout]
  failed on base: tests.ai.client.test_ai_client_error_reason::test_a_claude_reply_that_refuses_the_key_gives_the_credentials_error (AssertionError: assert (<class 'devo...rror'>, False) == (<class 'devo...Error'>, True))
  passed on base: tests.ai.client.test_ai_client_error_reason::test_a_transport_timeout_of_the_shared_client_says_so
  passed on base: tests.ai.client.test_ai_client_error_reason::test_a_reply_with_a_status_gives_the_status_and_not_the_body
  passed on base: tests.ai.client.test_ai_client_error_reason::test_the_reason_is_the_code_then_the_status_or_the_timeout[timeout]
  failed on base: tests.ai.client.test_ai_client_error_reason::test_a_claude_reply_with_a_status_gives_the_status[chat] (AssertionError: assert (None, 'LLM_I...NCE_ERROR', 2) == (529, 'LLM_IN... HTTP 529', 2))
  passed on base: tests.ai.client.test_ai_client_error_reason::test_the_reason_is_the_code_then_the_status_or_the_timeout[neither]
  failed on base: tests.ai.client.test_ai_client_error_reason::test_a_claude_reply_with_a_status_gives_the_status[stream] (AssertionError: assert (None, 'LLM_I...NCE_ERROR', 2) == (529, 'LLM_IN... HTTP 529', 2))
  passed on base: tests.ai.client.test_ai_client_error_reason::test_a_provider_that_builds_its_own_error_gives_the_status_or_the_timeout[ollama-status]
  passed on base: tests.ai.client.test_ai_client_error_reason::test_an_error_frame_with_a_status_gives_that_status
  passed on base: tests.ai.client.test_ai_client_error_reason::test_the_reason_is_the_code_then_the_status_or_the_timeout[status]
3 failed on base (3 failed and 13 passed in tests/ai/client/test_ai_client_error_reason.py; 0 errored).

@dan-petty
dan-petty marked this pull request as ready for review November 12, 2026 08:31
@dan-petty
dan-petty merged commit 5bf9466 into main Nov 12, 2026
23 checks passed
@dan-petty
dan-petty deleted the fix/3797-claude-status-after-retries branch November 12, 2026 12:04
dan-petty pushed a commit that referenced this pull request Nov 12, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.118.0](v0.117.2...v0.118.0)
(2026-11-12)


### Features

* **ci:** devops ci stops its rows when timeout ends it
([#5031](#5031))
([1fa4e9c](1fa4e9c))
* **roadmap:** keep the stage gate problems as a list with a code
([#5022](#5022))
([5819627](5819627))
* **roadmap:** log one result line for each roadmap job attempt
([#4966](#4966))
([2b6fe3f](2b6fe3f))
* **telemetry:** record each CLI usage error by name and kind
([#4973](#4973))
([a179fd9](a179fd9))


### Bug Fixes

* **ai:** chat loads each persona prompt and challenger gets tools
([#5037](#5037))
([c40b0ad](c40b0ad))
* **ai:** keep the HTTP status of a Claude reply after retries
([#4976](#4976))
([5bf9466](5bf9466))
* **deps:** keep Renovate uv bumps green and groups on Monday
([#4987](#4987))
([b19e153](b19e153))
* **k8s:** raise the limits that 7 d of use shows are too low
([#5030](#5030))
([028c62b](028c62b))
* **roadmap:** a job posts no comment that repeats a recent one
([#4978](#4978))
([fff903a](fff903a))
* **service:** alert when GitHub cannot deliver a webhook
([#5045](#5045))
([2bfbfcb](2bfbfcb))
* **service:** delete the stream route that sends canned verified text
([#5038](#5038))
([e9d51b5](e9d51b5))
* **telemetry:** keep one upstream status series per service
([#4986](#4986))
([3e4ca56](3e4ca56))
* **tests:** remove the runner variable in the test floor
([#4988](#4988))
([093aa61](093aa61))


### Performance Improvements

* **ai:** make the ast graph walk and call search faster
([#5039](#5039))
([3b25cc6](3b25cc6)),
closes [#4662](#4662)
* **ci:** build the devcontainer only on its own inputs
([#4977](#4977))
([c5b15ac](c5b15ac))
* **ci:** test each merge once, on the push to main
([#5043](#5043))
([c6992b1](c6992b1))
* **tests:** remove fixed waste in six slow tests
([#4995](#4995))
([1c7044e](1c7044e))


### Code Refactoring

* **ai:** delete devops ai pipeline and persona leftovers
([#5044](#5044))
([d5fefde](d5fefde)),
closes [#4827](#4827)
* **openspec:** split big capabilities into nested ones
([#4981](#4981))
([dfb09bd](dfb09bd))
* **pr:** devops pr update acts only on a failed check
([#4990](#4990))
([aa4fa1a](aa4fa1a))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/ai AI review pipeline, personas, prompts, LLM client, or RAG type/bug Type bug: the code does not do what it must

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(ai): a Claude reply loses its HTTP status after retries

1 participant