Commit 87dc40b
authored
feat(inference): bidirectional reasoning token passthrough for chat completions (#5038)
# What does this PR do?
Add extra="allow" to OpenAIAssistantMessageParam so that
provider-specific fields (reasoning, reasoning_content, thinking) are
preserved when clients echo assistant messages back in multi-turn
conversations.
Without this, reasoning tokens returned by models like gpt-oss on Ollama
were silently dropped during request deserialization, causing measurable
quality degradation on multi-turn benchmarks (e.g. BFCL).
The response direction already worked: the OpenAI SDK uses extra="allow"
on its response types, so provider reasoning fields survive the
provider->client path and are included in model_dump_json() output. This
change closes the client->provider gap.
No OpenAPI schema fields are added for reasoning content -- the
passthrough is transparent (additionalProperties: true), keeping
provider-specific details out of the public API contract.
Add integration test test_openai_chat_completion_reasoning_passthrough
that records a two-turn conversation with a reasoning model and asserts
that reasoning tokens survive the round-trip. The test is skipped
automatically when the configured model does not emit reasoning tokens.
## Test Plan
new integration test using gpt-oss:20b
relates to #5007
Signed-off-by: Charlie Doern <cdoern@redhat.com>1 parent bf94583 commit 87dc40b
12 files changed
Lines changed: 1335 additions & 4 deletions
File tree
- client-sdks/stainless
- docs/static
- src/llama_stack_api/inference
- tests/integration
- inference
- recordings
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4600 | 4600 | | |
4601 | 4601 | | |
4602 | 4602 | | |
| 4603 | + | |
4603 | 4604 | | |
4604 | 4605 | | |
4605 | 4606 | | |
| |||
13051 | 13052 | | |
13052 | 13053 | | |
13053 | 13054 | | |
| 13055 | + | |
13054 | 13056 | | |
13055 | 13057 | | |
13056 | 13058 | | |
| |||
13084 | 13086 | | |
13085 | 13087 | | |
13086 | 13088 | | |
| 13089 | + | |
13087 | 13090 | | |
13088 | 13091 | | |
13089 | 13092 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1144 | 1144 | | |
1145 | 1145 | | |
1146 | 1146 | | |
| 1147 | + | |
1147 | 1148 | | |
1148 | 1149 | | |
1149 | 1150 | | |
| |||
9597 | 9598 | | |
9598 | 9599 | | |
9599 | 9600 | | |
| 9601 | + | |
9600 | 9602 | | |
9601 | 9603 | | |
9602 | 9604 | | |
| |||
9630 | 9632 | | |
9631 | 9633 | | |
9632 | 9634 | | |
| 9635 | + | |
9633 | 9636 | | |
9634 | 9637 | | |
9635 | 9638 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1256 | 1256 | | |
1257 | 1257 | | |
1258 | 1258 | | |
| 1259 | + | |
1259 | 1260 | | |
1260 | 1261 | | |
1261 | 1262 | | |
| |||
9354 | 9355 | | |
9355 | 9356 | | |
9356 | 9357 | | |
| 9358 | + | |
9357 | 9359 | | |
9358 | 9360 | | |
9359 | 9361 | | |
| |||
9387 | 9389 | | |
9388 | 9390 | | |
9389 | 9391 | | |
| 9392 | + | |
9390 | 9393 | | |
9391 | 9394 | | |
9392 | 9395 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3021 | 3021 | | |
3022 | 3022 | | |
3023 | 3023 | | |
| 3024 | + | |
3024 | 3025 | | |
3025 | 3026 | | |
3026 | 3027 | | |
| |||
11406 | 11407 | | |
11407 | 11408 | | |
11408 | 11409 | | |
| 11410 | + | |
11409 | 11411 | | |
11410 | 11412 | | |
11411 | 11413 | | |
| |||
11439 | 11441 | | |
11440 | 11442 | | |
11441 | 11443 | | |
| 11444 | + | |
11442 | 11445 | | |
11443 | 11446 | | |
11444 | 11447 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4600 | 4600 | | |
4601 | 4601 | | |
4602 | 4602 | | |
| 4603 | + | |
4603 | 4604 | | |
4604 | 4605 | | |
4605 | 4606 | | |
| |||
13051 | 13052 | | |
13052 | 13053 | | |
13053 | 13054 | | |
| 13055 | + | |
13054 | 13056 | | |
13055 | 13057 | | |
13056 | 13058 | | |
| |||
13084 | 13086 | | |
13085 | 13087 | | |
13086 | 13088 | | |
| 13089 | + | |
13087 | 13090 | | |
13088 | 13091 | | |
13089 | 13092 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
391 | 391 | | |
392 | 392 | | |
393 | 393 | | |
| 394 | + | |
| 395 | + | |
394 | 396 | | |
395 | 397 | | |
396 | 398 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
Lines changed: 71 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 62 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments