Commit 6df32b5
feat: move sampling options (temperature/topP/maxTokens) into modelOptions (#660)
* refactor(ai-openai): read sampling options from modelOptions
* refactor(openai-base): read sampling options from modelOptions in chat-completions base
* refactor(ai-anthropic): read sampling options from modelOptions, drop cast
* fix(ai-anthropic): exempt max_tokens from dropped-key warning
* refactor(ai-gemini): read sampling options from modelOptions
* fix(ai-ollama): read sampling from nested modelOptions.options, drop cast and flat root reads
* refactor(ai-openrouter): read sampling options from modelOptions, drop cast
* refactor(ai): remove root sampling options; modelOptions is the sole sampling surface
* fix(ai): preserve summarize maxLength per-provider + fix otel sampling attribute spellings
* refactor(ai-openrouter): read sampling from modelOptions in responses adapter
* refactor(ai-gemini): read sampling from modelOptions in text-interactions adapter
* test: migrate remaining root sampling usages to modelOptions
* feat(codemods): add move-sampling-to-model-options codemod
* docs: document sampling options under modelOptions + migration guide
* docs(skills): sampling options now live in modelOptions
* chore: changeset for sampling-options-to-modelOptions move
* docs: correct sampling migration framing to breaking change
* ci: apply automated fixes
* fix(sampling): address PR #660 review feedback
Blocking fixes (codemod CI + Ollama silent drops):
- codemod: Prettier-normalize the transform test harness so recast's print
style no longer diverges from the Prettier-formatted fixtures (20/20 green),
and add a `test:lib` script to the codemods package so `nx affected` (and
thus `test:pr`) actually runs the suite instead of skipping it.
- summarize: place the default `temperature` where the wrapped provider reads
it — nested under `options` for Ollama (a flat value was dropped at the wire
while still surfacing in OTel). Honor caller-set flat token limits in the
Ollama branch, and warn instead of silently dropping `maxLength` for an
unrecognised adapter name.
- code-mode eval harness: nest Ollama `num_predict`/`num_ctx` under `options`.
- examples: route the generic `maxTokens` through provider-native
`modelOptions` (shared `maxTokensModelOptions` helper for dynamically
resolved adapters; native keys inline where the adapter is static).
Other review items:
- anthropic: `max_tokens ?? 1024` so an explicit `0` reaches validation
instead of being coerced to the default.
- openrouter (chat): forward root `metadata` like the responses adapter (+ test).
- otel: `firstNumber` now requires `Number.isFinite` (rejects NaN/Infinity).
- logger: add `InternalLogger.warn`, gated by the `errors` category so
`debug: false` still silences it.
- docs: fix the migration example to put sampling under `modelOptions`; drop
leaked trailing tags from the sampling guide; note the removed
`OllamaTextProviderOptions` export in the changeset; split the codemod
README's OpenAI row into Responses vs Chat Completions.
- codemod: emit ES6 shorthand when a moved value matches its key; drop an
unsafe `as RootSamplingKey` cast.
* refactor(ai): share max-token spelling table between summarize and otel
Extract the provider-native max-output-token key spellings into
`utilities/sampling-keys.ts` so the summarize wrapper's caller-limit
detection and the OTel middleware's sampling-attribute extraction read
from one source and cannot drift. Also document the intentional
non-native-spelling caveat in `applyMaxLength`.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Tom Beckenham <34339192+tombeckenham@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 8aabeec commit 6df32b5
96 files changed
Lines changed: 2729 additions & 422 deletions
File tree
- .changeset
- codemods
- move-sampling-to-model-options
- __testfixtures__
- docs
- adapters
- advanced
- api
- migration
- examples
- ts-code-mode-web/src
- lib
- routes
- _banking-demo
- _database-demo
- _home
- ts-react-chat/src/routes
- packages
- ai-anthropic
- src
- adapters
- text
- tests
- ai-code-mode/models-eval
- ai-gemini
- src
- adapters
- experimental/text-interactions
- text
- tests
- ai-grok/tests
- ai-groq/tests
- ai-ollama
- src
- adapters
- meta
- tests
- ai-openai
- src/text
- tests
- ai-openrouter
- src/adapters
- tests
- ai
- skills/ai-core
- adapter-configuration
- references
- chat-experience
- middleware
- src
- activities
- chat
- middleware
- summarize
- logger
- middlewares
- utilities
- tests
- middlewares
- openai-base
- src/adapters
- tests
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | | - | |
11 | | - | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
Lines changed: 15 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
0 commit comments