Skip to content

feat: read both forms of the Lenz API's responses - #107

Merged
lenzhq merged 5 commits into
mainfrom
feat/read-both-api-shapes
Oct 8, 2026
Merged

lenzhq merged 5 commits into
mainfrom
feat/read-both-api-shapes

Conversation

@lenzhq

@lenzhq lenzhq commented Oct 8, 2026

Copy link
Copy Markdown
Owner

What

The Lenz API is adding a newer, dated response form alongside the current one. This SDK and CLI keep sending X-Lenz-API-Version: 2026-05-13, so they keep receiving the current form. This release makes them read both, without changing anything for existing code.

  • Current-form bodies parse exactly as before. A model treats a body as the newer form only when it carries a key only that form sends. Otherwise everything is unchanged: fields, values, model_dump (incl. exclude_unset), repr, JSON schema, pickle and CLI output. This is pinned by an oracle of origin/main's outputs over 353 recordings, with a mutation check.
  • New names are read-only properties computed from either form (status, failure, more_claims, claims, completed_at, …).
  • Old names keep their old meaning when the newer form arrives (failed row "Error"/"low", error_code mapped back, modified_at later-UTC-day rule, /me/usage blocks recomputed from credits + costs).
  • Webhooks: events keep their dataclass fields (asdict / == unchanged); event_id, failure, claims and reason are properties.
  • webhook_url: verify / verify_batch no longer send "" by default. review / citecheck bodies are unchanged and pinned.
  • Removal dates: no 2026-11-29 removal date remains (README, warnings, docstrings, openapi.json, which is byte-identical with the Node SDK's). The changelog has a correction entry and lists what to settle before the SDK sends the newer date.

Tests

1526 passed, 8 skipped, coverage 93.3%; mypy --strict and ruff clean. The parity fixtures are excluded from the wheel and sdist.

Release

Changelog under Unreleased, marked minor (2.21.0); the release is tag-gated.

🤖 Generated with Claude Code

lenzhq and others added 4 commits October 8, 2026 20:07
…on verify

Every model, the webhook parser, the error mapping and the CLI read the
API's newer response shape as well as the original one. The newer field
names are attributes (ExtractedClaims.claims, AssessClaim.status/failure/
more_claims, TaskStatus.failure, completed_at, claim, FailureBlock.code,
the *_limit_exceeded flags, webhook event_id), and every older attribute
keeps its original meaning, computed from whichever shape arrives.
model_dump() returns the shape the server sent.

verify and verify_batch leave webhook_url out instead of sending "" (both
meant the key's default); review and citecheck bodies are unchanged.

The /me/usage deprecations no longer name a removal date.

Parity tests freeze what the previous release produced from each
original-shape response (models, CLI text and JSON, wait outcomes, errors,
webhooks, request bodies) and hold both shapes to it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d on newer-shape review webhooks

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…arlier release

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… properties

A body is read as the newer response shape only when it carries a key only
that shape has; every other body goes through the same fields, values,
dump, repr, exclude_unset, JSON schema and pickle as before. The newer
names (claims, status, failure, more_claims, completed_at, claim, code,
detail, the *_exceeded flags, webhook event_id / failure / claims / reason)
are read-only properties, not fields, and the model-level serializer is
gone.

Errors read the newer failure block, retry_after and a computed remaining
only for a newer-shape body and only where the original key is absent.
Webhook events keep their dataclass fields; a needs_input option with a null
domain no longer raises. The CLI renderers are back to 2.20's code.

Parity fixtures are rebuilt from the real recorded pairs (responses and
webhooks), extract goes through the client with the recorded locate, and the
oracle now also freezes exclude_unset dumps, repr, JSON schemas and pickles.
The remaining removal-date text is gone, and the changelog lists what to
settle before the SDK asks for the newer shape.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lenzhq
lenzhq requested a review from paveljor as a code owner October 8, 2026 17:27
…ew_id / citecheck_id as task_id

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lenzhq
lenzhq merged commit 3e4a8c2 into main Oct 8, 2026
13 checks passed
@lenzhq
lenzhq deleted the feat/read-both-api-shapes branch October 8, 2026 21:32
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