Skip to content

fix(sdk): align error types, retry delays and response validation - #8

Merged
moonyue-w merged 1 commit into
mainfrom
codex/align-python-sdk-behavior
Sep 24, 2026
Merged

moonyue-w merged 1 commit into
mainfrom
codex/align-python-sdk-behavior

Conversation

@moonyue-w

Copy link
Copy Markdown
Collaborator

Summary

Align Python response handling with the pinned Anthropic v1.7.0 baseline. HTTP 413 and 529 receive dedicated error classes, positive server-requested retry delays above 60 seconds are respected, and responses use lenient model construction by default with optional strict validation.

  • Export RequestTooLargeError and OverloadedError from qca and qca.common.
  • Cap positive retry delays at 4,294,967 seconds and align millisecond-header precedence and backoff behavior. Retry eligibility is unchanged.
  • Preserve _strict_response_validation=True across client copies, response views, pagination, and SSE.
  • Add six read-only strict-response integration checks for Forward model/template/session lists and Managed model/agent/session lists. Existing business scenarios retain default parsing.

Why

Provide the same error classification and response compatibility behavior as Anthropic, honor server-requested retry waits, and retain a separate integration check for server schema drift.

Verification

  • Ruff lint and format checks passed.
  • mypy src/qca scripts: 595 source files passed.
  • pytest -q: 2,994 passed; account-backed integration tests excluded.
  • pytest tests/integration -m integration -k strict_response_contract -q: 6 passed against the real service using existing local test credentials; GET requests only.
  • Documentation generation/check passed; 25 README snippets compiled.
  • Wheel and source distribution built successfully.
  • Example --help checks were not rerun; examples are unchanged.

Impact

  • Public behavior changes and migration notes recorded in CHANGELOG.md and README.
  • Synchronous and asynchronous clients covered; generated API documentation updated.
  • Contract tests updated. Endpoint and wire-field fixtures are unchanged.
  • Cross-SDK retry safety differences considered and preserved.
  • No credentials, environment files, logs, or test output committed.

Breaking changes: callers requiring the previous response-schema checks should set _strict_response_validation=True. HTTP 529 now raises OverloadedError, directly under APIStatusError, so an InternalServerError catch alone no longer includes overloads. Invalid JSON and invalid download URLs still fail in either validation mode.

@moonyue-w
moonyue-w merged commit fcadb06 into main Sep 24, 2026
5 checks passed
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