Repository navigation
Keep thinking models' reasoning across agent turns on vLLM - #463
Closed
gregorybchris wants to merge 1 commit into
Closed
gregorybchris wants to merge 1 commit into
gregorybchris wants to merge 1 commit into
Conversation
vLLM returns reasoning parser output as `reasoning`, which openai-agents only reads as `reasoning_content`, and the SDK replays reasoning into later turns only for DeepSeek models. With Qwen3.5 thinking enabled this made the model put its second tool call inside an unclosed think block, ending every agent run after one tool call. Read either field, and replay a model's own reasoning on self-hosted servers. Managed APIs keep the SDK default. Fixes #461 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
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.
Toward #461. Thinking models served by vLLM now keep their reasoning across agent turns in the
openai_agentsscaffold. Before this, Qwen3.5 with thinking on ended every agent run after one tool call.Cause
Two gaps between vLLM 0.19.1 and openai-agents 0.20:
message.reasoning, and the SDK reads onlyreasoning_content.<think>block. The reasoning parser classified the whole thing as reasoning withtool_calls=[], and the SDK treated that as the final answer.Changes
patch_openai_agents_for_vllm(inference/utils.py): the SDK's converter now readsreasoningasreasoning_contentwhen only the former is present, so the model's reasoning becomes a reasoning item. The patch is idempotent and separate from the existingstrictpatch.replay_own_reasoning(harness/scaffolds/openai_agents.py): this is passed as the SDK'sshould_replay_reasoning_contenthook. It replays a reasoning item when the current model produced it, or when the item's origin is unknown. It applies only to self-hosted servers, using the same check the scaffold already uses forchat_template_kwargs. Managed APIs keep the SDK default, because they would reject the extra field.Runs with thinking off are unaffected, because there is no reasoning to replay.
Tests
TestReasoningReplayintests/core/harness/test_openai_agents_scaffold.py:reasoningplus a tool call,reasoning_contentfor a self-hosted provider, and omits it for a managed one.reasoninginto a reasoning item.replay_own_reasoningreplays the model's own reasoning and items of unknown origin, but not another model's.Five of the six new tests fail without the source change. The one that passes is the managed-provider case, which is unchanged by design.
uv run ruff check src/ tests/anduv run ruff format --check src/ tests/: clean.uv run ty check src/ alembic/: same two diagnostics asmain.uv run pytest tests/ --ignore=tests/integration: 3306 passed, 35 skipped. The scaffold tests (24 passed) run with--extra agents.Verification on Beaker
This change is not enough on its own. SWE-bench Verified (#445) with this change applied, Qwen3.5-9B, the same 20 instances (every 25th), with
reasoning_parser=qwen3andmax_model_len=131072:complete, after one tool call (median trajectory: 2 entries)submitted, 15max_turnsWith thinking on, every run still ends after its first tool call, the same symptom as before. The unit tests show the reasoning is now carried into the next request on self-hosted servers. That isn't what stops the run, though, or this change doesn't take effect on vLLM.
Next step: a one-instance run with vLLM request and response logging (
enable_log_requests,enable_log_outputs) to see the second turn's request and response directly. Converted to draft until that's resolved.🤖 Generated with Claude Code