Skip to content

[Bugfix] Fix Responses API crash when ResponseReasoningItem has content=None#36839

Open
rranabha wants to merge 1 commit intovllm-project:mainfrom
rranabha:fix/responses-reasoning-content-none
Open

[Bugfix] Fix Responses API crash when ResponseReasoningItem has content=None#36839
rranabha wants to merge 1 commit intovllm-project:mainfrom
rranabha:fix/responses-reasoning-content-none

Conversation

@rranabha
Copy link

Summary

  • Fix TypeError: object of type 'NoneType' has no len() crash in response_input_to_harmony() when a ResponseReasoningItem has content=None
  • Fall back to the summary field (joining all summary texts) when content is None, which occurs in multi-turn Responses API requests where previous reasoning output is passed back as input
  • Add unit tests covering reasoning items with content, content=None with summary, multiple summaries, empty summary, and missing summary

Test plan

  • Existing tests in tests/entrypoints/openai/responses/test_harmony_utils.py pass
  • New TestResponseInputToHarmonyReasoning test class covers all content/summary combinations
  • Multi-turn Responses API requests with ResponseReasoningItem(content=None) in input no longer crash

…nt=None

Handle the case where ResponseReasoningItem.content is None by falling
back to the summary field. This occurs in multi-turn requests when
previous response reasoning items are passed back as input.
@github-actions
Copy link

👋 Hi! Thank you for contributing to the vLLM project.

💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels.

Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors.

You ask your reviewers to trigger select CI tests on top of fastcheck CI.

Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can either: Add ready label to the PR or enable auto-merge.

If you have any questions, please reach out to us on Slack at https://slack.vllm.ai.

🚀

@mergify mergify bot added frontend bug Something isn't working labels Mar 12, 2026
@gemini-code-assist
Copy link
Contributor

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

@mergify
Copy link

mergify bot commented Mar 12, 2026

Hi @rranabha, the pre-commit checks have failed. Please run:

uv pip install pre-commit
pre-commit install
pre-commit run --all-files

Then, commit the changes and push to your branch.

For future commits, pre-commit will run automatically on changed files before each commit.

Tip

Is mypy failing?
mypy is run differently in CI. If the failure is related to this check, please use the following command to run it locally:
# For mypy (substitute "3.10" with the failing version if needed)
pre-commit run --hook-stage manual mypy-3.10

Copy link
Contributor

@alvinttang alvinttang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The root cause is correctly identified — content=None is a valid API state when encrypted_content is used, so the hard assert was wrong. The fallback to summary is a reasonable recovery strategy, but joining multiple summary items with a single space (e.g., "First thought. Second thought.") could produce grammatically awkward output depending on punctuation; a newline separator might be more faithful to the original reasoning structure. The remaining assert len(content) == 1 in the non-None branch is still a potential crash if the API ever returns multi-entry content arrays — worth converting to a more defensive approach (e.g., joining or taking the first item). Test coverage is thorough and the edge cases are well exercised.

@chaunceyjiang
Copy link
Collaborator

/cc @qandrew PTAL.

@bbrowning
Copy link
Contributor

I believe this attempts to fix the same issues as #34499, but 34499 properly handles the summary field which is only meant to be user-visible summaries but not supposed to make its way back into the model's prompt.

@mergify
Copy link

mergify bot commented Mar 12, 2026

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @rranabha.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify bot added the needs-rebase label Mar 12, 2026
@bbrowning
Copy link
Contributor

@rranabha 34499 just merged. If you're willing, please take a look at the changes merged there to ensure they fix your issue and if so we can close this PR. If you're not sure or want to chat about that, I'm happy to do that as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working frontend needs-rebase

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants