Commit 7c3dc17
authored
fix(vertexai): preserve reasoning_content as thought parts in multi-turn conversations (#5677)
# What does this PR do?
When thinking-enabled Gemini models (2.5/3) return `reasoning_content`
in assistant messages, that content must be sent back as native
`thought` parts in subsequent multi-turn requests. Without this, the
model loses prior reasoning context across turns.
This PR updates `_convert_assistant_message()` in the VertexAI converter
to extract `reasoning_content` from assistant messages and emit it as a
`{"thought": True, "text": ...}` part, placed before text and
function_call parts. A truthiness guard skips the part when
`reasoning_content` is missing or `None`, preserving backward
compatibility.
## Test Plan
Added parametrized unit tests covering all combinations of
`reasoning_content` with text, tool_calls, both, neither, and `None`:
```bash
uv run pytest tests/unit/providers/inference/vertexai/test_converters_requests.py -v -k "reasoning"
```
Output:
```text
test_assistant_reasoning_content[reasoning_and_text] PASSED
test_assistant_reasoning_content[reasoning_only] PASSED
test_assistant_reasoning_content[no_reasoning] PASSED
test_assistant_reasoning_content[reasoning_none] PASSED
test_assistant_reasoning_content_with_tool_calls[reasoning_and_tool_calls] PASSED
test_assistant_reasoning_content_with_tool_calls[reasoning_text_and_tool_calls] PASSED
6 passed in 0.04s
```
Full converter test suite (110 tests) passes with no regressions:
```bash
uv run pytest tests/unit/providers/inference/vertexai/test_converters_requests.py tests/unit/providers/inference/vertexai/test_converters_responses.py -x --tb=short
```
```text
110 passed in 0.05s
```
Signed-off-by: Major Hayden <major@redhat.com>
Signed-off-by: Major Hayden <major@mhtx.net>1 parent 6751d40 commit 7c3dc17
2 files changed
Lines changed: 84 additions & 0 deletions
File tree
- src/ogx/providers/remote/inference/vertexai
- tests/unit/providers/inference/vertexai
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
253 | 253 | | |
254 | 254 | | |
255 | 255 | | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
256 | 266 | | |
257 | 267 | | |
258 | 268 | | |
| |||
Lines changed: 74 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
607 | 607 | | |
608 | 608 | | |
609 | 609 | | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
610 | 684 | | |
611 | 685 | | |
612 | 686 | | |
| |||
0 commit comments