Skip to content

fix(gateway): add caching provider option#15329

Closed
Kage18 wants to merge 1 commit into
vercel:mainfrom
Kage18:kage-fix-gateway-caching-provider-option
Closed

fix(gateway): add caching provider option#15329
Kage18 wants to merge 1 commit into
vercel:mainfrom
Kage18:kage-fix-gateway-caching-provider-option

Conversation

@Kage18

@Kage18 Kage18 commented May 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add the documented gateway.caching automatic provider option to GatewayProviderOptions
  • verify typed gateway options can include automatic caching
  • verify caching auto is forwarded in gateway request provider options
  • document the option in the AI Gateway provider options list

Fixes #14595.

Kage usage

  • Used Kage scoped to packages/gateway to orient around gateway provider options and request forwarding tests.
  • Captured a repo-local memory packet explaining that GatewayProviderOptions type missing 'caching' property (docs mismatch) #14595 was a schema/type mismatch for documented automatic caching.
  • Local Kage metrics after refresh: 59 files, 1,279 symbols, 1,587 calls, 370 tests, 100% indexed coverage, 3 memory packets, 71 memory graph entities, 72 evidence-backed edges, 0 stale packets.

Tests

  • pnpm --dir packages/gateway exec vitest --config vitest.node.config.js --run src/gateway-language-model.test.ts src/gateway-provider-options.test-d.ts
  • pnpm --filter @ai-sdk/gateway type-check

Note: local verification emitted the repository Node engine warning because this shell runs Node v25.9.0 while the repo declares support for ^18/^20/^22/^24.

@Kage18

Kage18 commented May 15, 2026

Copy link
Copy Markdown
Contributor Author

Kage usage for this PR:

This PR fixed #14595 by adding the documented gateway.caching: 'auto' provider option to the Gateway type/schema path and request forwarding behavior.

How Kage helped:

  • Scoped recall to packages/gateway provider options instead of the full provider surface.
  • Kept the relevant code, type tests, request-body tests, and docs together: gateway-provider-options.ts, gateway-provider-options.test-d.ts, gateway-language-model.test.ts, and the AI Gateway docs page.
  • Helped identify the issue as a docs/API mismatch: docs described automatic caching, but the typed provider options did not allow it.
  • Captured the durable rule: gateway.caching: 'auto' should be accepted in provider options and forwarded in the request body.
  • Captured the exact verification commands and the local Node engine-warning context.

Why this matters for future sessions:
A future agent working on Gateway provider options can recall that documented options need type coverage and request-forwarding tests, not just a docs update.

Full contribution summary and Kage metrics: kage-core/Kage#8

gr2m pushed a commit that referenced this pull request Jun 29, 2026
…16483)

## Background

The `caching` provider option for the AI Gateway was previously untyped
despite being in AI Gateway docs.

#15768 added it, but only to v7

## Summary

Backported that change by updating the `gatewayProviderOptions` zod
schema in v6.

## Manual Verification

This is properly typed in v6 now with intellisense working and no
errors:

```typescript
  const result = streamText({
    model: 'anthropic/claude-sonnet-4.6',
    system:
      'You are a helpful assistant with access to a large knowledge base...',
    prompt: 'What is the capital of France?',
    providerOptions: {
        gateway: {
            caching: 'auto',
        } satisfies GatewayProviderOptions,
    },
  });
```

## Checklist

- [X] All commits are signed (PRs with unsigned commits cannot be
merged)
- [ ] Tests have been added / updated (for bug fixes / features)
- [ ] Documentation has been added / updated (for bug fixes / features)
- [X] A _patch_ changeset for relevant packages has been added (for bug
fixes / features - run `pnpm changeset` in the project root)
- [X] I have reviewed this pull request (self-review)

## Related Issues

Fixed #14595

Closes #14609
Closes #14632
Closes #14664
Closes #14886
Closes #15298
Closes #15329
Closes #15458
Closes #15500
Closes #15857
@n1ckoates

Copy link
Copy Markdown
Member

Added to AI SDK 7 in #15768
Backported to AI SDK 6 in #16483

@n1ckoates n1ckoates closed this Jun 29, 2026
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.

GatewayProviderOptions type missing 'caching' property (docs mismatch)

2 participants