Commit bd527ad
authored
fix: convert litellm response with reasoning content to openai message (#1098)
### 1. Description
This PR fixes an issue where reasoning content from models accessed via
LiteLLM was not being correctly parsed into the `ChatCompletionMessage`
format. This was particularly noticeable when using reasoning models.
### 2. Context
I am using the `openai-agents-python` library in my project, and it has
been incredibly helpful. Thank you for building such a great tool!
My setup uses `litellm` to interface with `gemini-2.5-pro`. I noticed
that while the agent could receive a response, the reasoning(thinking)
from the Gemini model was lost during the conversion process from the
LiteLLM response format to the OpenAI `ChatCompletionMessage` object.
I saw that PR #871 made progress on a similar issue, but it seems the
specific response structure from LiteLLM still requires a small
adaptation. This fix adds the necessary logic to ensure that these
responses are handled.
**Relates to:** #871
### 3. Key Changes
- `LitellmConverter.convert_message_to_openai`: add `reasoing_content`
- `Converter.items_to_messages`: just pass the reasoning item1 parent 656ee0c commit bd527ad
File tree
2 files changed
+26
-2
lines changed- src/agents
- extensions/models
- models
2 files changed
+26
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
48 | 56 | | |
49 | 57 | | |
50 | 58 | | |
| |||
364 | 372 | | |
365 | 373 | | |
366 | 374 | | |
367 | | - | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
368 | 380 | | |
369 | 381 | | |
370 | 382 | | |
371 | 383 | | |
372 | 384 | | |
373 | 385 | | |
| 386 | + | |
374 | 387 | | |
375 | 388 | | |
376 | 389 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
210 | 211 | | |
211 | 212 | | |
212 | 213 | | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
213 | 220 | | |
214 | 221 | | |
215 | 222 | | |
| |||
459 | 466 | | |
460 | 467 | | |
461 | 468 | | |
462 | | - | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
463 | 474 | | |
464 | 475 | | |
465 | 476 | | |
| |||
0 commit comments