Repository navigation
Conversation
The openai-agents SDK already turns Chat Completions reasoning_content into a ReasoningItem, but _convert_trajectory had no branch for it, so the reasoning was dropped before the trajectory was saved. Add an optional AgentTurn.reasoning field, attach each reasoning item to the assistant turn that follows it (message or tool call), and keep trailing reasoning on an empty assistant turn instead of losing it. Pending reasoning never crosses a response boundary: a message without text or a tool output flushes it the same way. Turns without reasoning serialize exactly as before. A reasoning-only final response now yields one empty assistant turn, so num_turns is one higher in that cut-off case.
vLLM returns a reasoning model's thinking as the message field reasoning. openai-agents 0.20 builds a ReasoningItem only from reasoning_content or thinking blocks, so behind a vLLM server the converter never sees the reasoning and the saved trajectory still drops it. The scaffold now instantiates a small subclass of OpenAIChatCompletionsModel whose _fetch_response mirrors reasoning onto reasoning_content on the raw completion, before the SDK converts the message. The mirror does nothing when the server already returned a non-empty reasoning_content or thinking blocks, or when the message carries no reasoning at all. Streaming responses pass through untouched; olmo-eval does not use them and the SDK's stream handler already reads the field on that path. The SDK replays reasoning_content into later requests only for model names containing "deepseek", so a DeepSeek-named model served by vLLM sends the mirrored text back as assistant history. vLLM 0.19.1 ignores that key, and a test pins the replay for a DeepSeek name and its absence for a Qwen name. openai-agents 0.21.1 and later read the reasoning field themselves but require openai 3.x, which this repository's pins exclude, so the mirror stays until that migration and should be removed with it. A test pins the private hook so a rename fails loudly instead of silently losing reasoning again.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The openai-agents SDK converts Chat Completions
reasoning_contentinto aReasoningItem, but_convert_trajectoryonly handled message, tool call and tool output items, so reasoning was dropped before the trajectory was saved.AgentTurngains an optionalreasoningfield and the converter aReasoningItembranch that attaches the item to the assistant turn that follows it, flushing onto an otherwise empty assistant turn at a tool output or the end of the run so it never crosses a response boundary. Turns without reasoning serialize exactly as before: trajectory.py, openai_agents.py.vLLM returns thinking as
reasoning, a field the pinned SDK's Chat Completions converter does not read, so behind a vLLM server the new branch would still see nothing. The scaffold therefore instantiates a small subclass ofOpenAIChatCompletionsModelthat mirrorsreasoningontoreasoning_contenton the raw completion before the SDK converts it, and does nothing when a non-emptyreasoning_contentor thinking blocks are already present or when there is no reasoning. The SDK releases that read the field themselves require openai 3.x, which this repository's pins exclude, so the mirror stays until that migration.Checked on Beaker with Qwen3.5-9B behind vLLM 0.19.1 (
--reasoning-parser qwen3, thinking enabled) on three litsearch instances: all seven model responses produced reasoning and all seven are saved on the assistant turns, with none of that text in any turn content, tool argument or final output. Also checked with a one-instance litsearch run against deepseek-reasoner, and end to end through the SDK Runner over a mock transport answering in vLLM 0.19.1's message shape, with nothing extra replayed to the server: test_openai_agents_scaffold.py, test_trajectory_types.py. The new scaffold tests skip in CI like the existing ones in that file.