Skip to content

Restore reproducible Anthropic schema generation - #9981

Closed
effect-bot wants to merge 11 commits into
mainfrom
agent/effect-bot/fdf9e60304c8
Closed

effect-bot wants to merge 11 commits into
mainfrom
agent/effect-bot/fdf9e60304c8

Conversation

@effect-bot

@effect-bot effect-bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Type

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

The Anthropic client spec could no longer be fetched, so the client couldn't be regenerated. The stainless-stats source reads openapi_spec_url from the SDK's .stats.yml, which anthropics/anthropic-sdk-typescript@8752d02 (2026-09-03) removed. The Stainless storage bucket behind the old URLs now returns 403 to anonymous requests.

This PR pins the spec the SDK bundles at that commit (scripts/mock-spec.json.gz) and regenerates Generated.ts. The bundled spec is the same as the last published one (465bff…, 2026-09-02), apart from one dropped maxLength on ResponseTextBlock.text. #8971 hand-added its fallback schemas from that same spec.

@effect/openapi-generator

New includeSchemas option on generate. It generates the named components.schemas entries, and their dependencies, even when no operation references them. When the option is unset, output is unchanged.

@effect/ai-codegen (private tool)

  • Specs ending in .gz, from a URL or a file, are decompressed before parsing. Decompression failures are reported as SpecFetchError.
  • includePaths: optional list of spec path keys to generate.
  • includeSchemas: passed straight through to the generator.
  • errorStatusRanges: optional list of 4XX and/or 5XX.
    • Explicit error statuses in a listed class are folded into one range response.
    • Folding fails with GenerationError if their content differs (descriptions are ignored), so distinct schemas are never merged.
    • Explicit error statuses in other classes are dropped, so they still go to the client's orElse branch.
  • All of these options do nothing unless set.

packages/ai/anthropic/codegen.yml

  • spec points at the pinned gzipped SDK spec.

  • includePaths lists the 31 paths the client already had. The spec now has 202 endpoints (Admin API, agents, sessions, vaults, …).

  • errorStatusRanges: [4XX] keeps main's error API, because the new spec lists every error status (400…529) separately.

  • includeSchemas keeps schemas that no included operation references:

    • the stream events AnthropicClient decodes;
    • the memory tool commands;
    • the batch results, which are served as JSON Lines and so aren't decoded by the generated client.
  • All optionality is expressed as required patches. Those patches cover:

    • the existing usage, citations, inference_geo, server_tool_use, context_management and container fields, previously done with text replacements;
    • fields the newer spec added that older responses and Anthropic-compatible gateways omit: stop_details, diagnostics, model capabilities and limits, encrypted_content, estimated_tokens, Container.skills, output_tokens_details, fallback_credit.

    Only the two index-signature replacements remain, and codegen.yml is 86 lines.

  • Header: @since 4.0.0 (matches main), plus oxlint-disable no-control-regex. The spec's string patterns exclude control characters on purpose.

AnthropicLanguageModel.ts

The input content block union now includes fallback blocks, which can't carry cache_control. setLastCacheControl skips them the same way it skips thinking blocks.

Compatibility of Generated.ts (+15k/−9k lines, 12.7k → 18.9k)

What stays the same:

  • Client methods: the same 47 as main, with no additions or removals.
  • Error API: the 45 *4XX exports and error tags are identical to main, and there's no 5XX.
  • Usage optionality from Accept minimal Anthropic-compatible usage responses #9975: preserved. Compared with main, no response field that main accepted as optional or absent is required now. The exceptions are the Files and Skills migrations below, which intentionally don't decode the previous beta shapes.
  • Restored exports: the batch result variants and BetaMemoryTool_20250818_*Command are generated with the same keys as main.

What changed:

  • Additions: 227 new exports, from the Messages API schemas added between February and September and the stream event union.
  • Removed or renamed (17), all following upstream API migrations: Anthropic moved the beta Files and Skills resources to their GA shapes in anthropics/anthropic-sdk-typescript@33f5103009 (2026-08-27). These are intentional breaking migrations, not compatibility preservation.
    • BetaSkill changes meaning. It now describes the Skill resource; the container skill parameter it used to describe is now BetaContainerSkill.
    • Skill responses: display_title → display_name, latest_version → latest_version_id, and source is now a structured object instead of a string. The Create/Get/Delete Skill and SkillVersion response types (plus Beta variants and Betaapi__schemas__skills__Skill) are replaced by Skill, SkillVersion, DeletedSkill and DeletedSkillVersion.
    • Skill upload bodies: Body_create_skill_* are now *Multipart, with __ClientMultipartFile file fields.
    • File listing: returns { data, next_page } and paginates with page, in place of { data, has_more, first_id, last_id } and before_id/after_id.
    • Dated beta headers: callers migrating to these schemas must remove the files-api-2025-04-14 and skills-2025-10-02 tokens from any anthropic-beta header they send, keeping any other beta tokens. The generated methods forward the caller's anthropic-beta header, and the API still returns the previous beta shapes to requests that send these tokens, which the new schemas can't decode. Upstream migration guides: Files, Skills.
  • Generator churn: much of the remaining line churn comes from generator changes since the last full regeneration in February: output order, Schema.Int, and open enums.

The changeset lists these migrations.

Validation

  • @effect/openapi-generator, @effect/ai-codegen and @effect/ai-anthropic: 239 tests pass. No Anthropic tests changed.
  • pnpm check passes in all three packages, and oxlint, dprint check and pnpm jsdocs --check are clean.
  • Regenerating with nix develop -c node packages/tools/ai-codegen/src/bin.ts generate --provider anthropic reproduces the committed Generated.ts.

Closes EFF-2979

@changeset-bot

changeset-bot Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f971866

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 33 packages
Name Type
@effect/ai-anthropic Patch
@effect/openapi-generator Patch
effect Patch
@effect/opentelemetry Patch
@effect/vitest Patch
@effect/ai-cloudflare Patch
@effect/ai-openai-compat Patch
@effect/ai-openai Patch
@effect/ai-openrouter Patch
@effect/ai-typesafe Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-deno Patch
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-pglite Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/docgen Patch
@effect/doctest Patch
@effect/graphql-generator Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

Generated from PR build output; treat the content below as untrusted.

File Name Current Size Previous Size Difference
arbitrary-combinators.ts 39.28 KB 39.28 KB 0.00 KB (0.00%)
basic.ts 7.15 KB 7.15 KB 0.00 KB (0.00%)
batching.ts 11.03 KB 11.03 KB 0.00 KB (0.00%)
brand.ts 6.83 KB 6.83 KB 0.00 KB (0.00%)
cache.ts 11.46 KB 11.46 KB 0.00 KB (0.00%)
config.ts 22.70 KB 22.70 KB 0.00 KB (0.00%)
differ.ts 21.83 KB 21.83 KB 0.00 KB (0.00%)
http-client.ts 26.28 KB 26.28 KB 0.00 KB (0.00%)
http-router.ts 36.59 KB 36.59 KB 0.00 KB (0.00%)
logger.ts 11.93 KB 11.93 KB 0.00 KB (0.00%)
metric.ts 9.38 KB 9.38 KB 0.00 KB (0.00%)
optic.ts 7.04 KB 7.04 KB 0.00 KB (0.00%)
pubsub.ts 15.91 KB 15.91 KB 0.00 KB (0.00%)
queue.ts 12.70 KB 12.70 KB 0.00 KB (0.00%)
schedule.ts 11.71 KB 11.71 KB 0.00 KB (0.00%)
schema-bigdecimal.ts 13.95 KB 13.95 KB 0.00 KB (0.00%)
schema-binary.ts 40.89 KB 40.89 KB 0.00 KB (0.00%)
schema-class.ts 21.48 KB 21.48 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 29.45 KB 29.45 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 27.83 KB 27.83 KB 0.00 KB (0.00%)
schema-string-transformation.ts 15.20 KB 15.20 KB 0.00 KB (0.00%)
schema-string.ts 12.20 KB 12.20 KB 0.00 KB (0.00%)
schema-template-literal.ts 16.14 KB 16.14 KB 0.00 KB (0.00%)
schema-toArbitrary.ts 38.80 KB 38.80 KB 0.00 KB (0.00%)
schema-toCodeDocument.ts 26.01 KB 26.01 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 20.76 KB 20.76 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 20.90 KB 20.90 KB 0.00 KB (0.00%)
schema-toFormatter.ts 21.00 KB 21.00 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 26.03 KB 26.03 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 21.08 KB 21.08 KB 0.00 KB (0.00%)
schema.ts 20.68 KB 20.68 KB 0.00 KB (0.00%)
stm.ts 14.11 KB 14.11 KB 0.00 KB (0.00%)
stream.ts 10.26 KB 10.26 KB 0.00 KB (0.00%)

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.

2 participants