Skip to content

fix: support vLLM 'reasoning' field as fallback for 'reasoning_content'#3959

Open
r266-tech wants to merge 1 commit intocamel-ai:masterfrom
r266-tech:fix/vllm-reasoning-field-fallback
Open

fix: support vLLM 'reasoning' field as fallback for 'reasoning_content'#3959
r266-tech wants to merge 1 commit intocamel-ai:masterfrom
r266-tech:fix/vllm-reasoning-field-fallback

Conversation

@r266-tech
Copy link
Copy Markdown

Related Issue

#3939

Description

vLLM deprecated the reasoning_content field in favor of reasoning in v0.8.3 (see vllm-project/vllm#12953). CAMEL only checks for reasoning_content, so reasoning output is silently discarded when users run newer vLLM deployments of reasoning models (e.g., DeepSeek-R1 via vLLM ≥ 0.8.3).

Root cause: ChatAgent._handle_batch_response and the two streaming loops each hard-code reasoning_content with no fallback.

Fix: Add a getattr fallback chain so that reasoning is used when reasoning_content is absent, for both the non-streaming and streaming code paths. The change is fully backward-compatible — existing providers that emit reasoning_content are unaffected.

Changed lines in camel/agents/chat_agent.py:

  • Non-streaming (~line 3932): getattr(choice.message, 'reasoning_content', None) or getattr(choice.message, 'reasoning', None)
  • Streaming loop 1 (~line 4635) and loop 2 (~line 5745): extracted into _reasoning_delta with the same fallback pattern.

What is the purpose of this pull request?

  • Bug fix

Checklist

  • I have read and agree to the AI-Generated Code Policy (required)
  • I have linked this PR to an issue (required)
  • I have checked if any dependencies need to be added or updated in pyproject.toml and run uv lock
  • I have updated the tests accordingly (required for a bug fix or a new feature)
  • I have updated the documentation if needed
  • I have added examples if this is a new feature

vLLM deprecated the 'reasoning_content' field in favor of 'reasoning'
in v0.8.3 (see vllm-project/vllm#12953). This caused reasoning content
to be silently lost when using CAMEL with newer vLLM deployments of
reasoning models.

Fix both the non-streaming and streaming code paths in ChatAgent to
check 'reasoning' as a fallback when 'reasoning_content' is absent:
- _handle_batch_response: getattr fallback chain for choice.message
- _astream / streaming loop: _reasoning_delta extracted with fallback

Resolves camel-ai#3939
Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

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

⚠️ Code review skipped — your organization's overage spend limit has been reached.

Code review is billed via overage credits. To resume reviews, an organization admin can raise the monthly limit in Settings → Usage.

Once credits are available, reopen this pull request to trigger a review.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 22, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 10f51bbc-dfc9-450f-b225-ed786105c6f3

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can scan for known vulnerabilities in your dependencies using OSV Scanner.

OSV Scanner will automatically detect and report security vulnerabilities in your project's dependencies. No additional configuration is required.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant