Skip to content

feat(chat): enhance reasoning and response handling - #659

Merged
steebchen merged 12 commits into
mainfrom
fix/reasoning-openai
Aug 29, 2025
Merged

steebchen merged 12 commits into
mainfrom
fix/reasoning-openai

Conversation

@steebchen

Copy link
Copy Markdown
Member

No description provided.

Refined handling of Anthropic responses to extract and map reasoning
content. Introduced support for streaming and budgeted reasoning tokens.
Updated tests and request logic for improved reasoning support.
Added validation to ensure the max_tokens value does not exceed the
maximum allowed by the provider mapping for the selected model.
Updated token calculation logic to dynamically adjust thinking budgets
based on reasoning effort levels.
Updated the token calculation for "low" effort levels from 1000 to 1024
to align with Anthropic's minimum token requirements. Added a clarifying
comment.
Updated test cases to use only models with streaming-enabled providers. Added logic to determine streaming availability at both the model and provider levels. Improved filtering to ensure accurate test coverage for streaming use cases.
Added support for OpenAI's responses API with reasoning capability. Improved transformation of responses and streaming formats for reasoning and tool calls. Refined reasoning content extraction and token calculations for consistency. Updated handling for OpenAI delta and completions formats. Introduced tests for enhanced reasoning support.
Enhanced parsing of OpenAI's streaming API with expanded event type handling. Improved transformations for reasoning and content deltas. Added support for token use tracking in final responses.
Refactored tool call extraction to support `function_call` updates in OpenAI responses. Improved status mapping by differentiating function call-based flow. Added `tool_choice` and enhanced tool transformation logic for Responses API format, enabling tool handling with reasoning models.
@coderabbitai

coderabbitai Bot commented Aug 28, 2025 •

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@steebchen has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 11 minutes and 34 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbit review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between d1ed8e1 and 2c5ceb5.

📒 Files selected for processing (4)
  • apps/gateway/src/api.e2e.ts (4 hunks)
  • apps/gateway/src/chat/chat.ts (12 hunks)
  • packages/models/src/models.ts (1 hunks)
  • packages/models/src/provider-api.ts (6 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/reasoning-openai

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbit in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbit in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbit gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbit read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbit help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbit ignore or @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbit summary or @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbit or @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Handle missing OpenAI required fields by normalizing response data.
Ensure `role` and `object` attributes are set correctly in streaming
responses. Normalize `reasoning` to `reasoning_content` for consistency.
Created `transformStandardOpenAIStreaming` to refactor and centralize
logic for transforming OpenAI streaming responses. Ensures consistency
by normalizing `reasoning` to `reasoning_content` and applying default
values for required fields across all usages. Simplified existing
handlers to use the helper function.
@steebchen
steebchen changed the base branch from fix/reasoning-anthropic to main August 28, 2025 23:24
@steebchen steebchen changed the title feat(chat): enhance OpenAI reasoning and response handling feat(chat): enhance reasoning and response handling Aug 28, 2025
Added comprehensive end-to-end test cases to validate reasoning
combined with tool calls. Ensured correct output structure, tool call
validation, reasoning content, logs, and token usage.
@steebchen
steebchen force-pushed the fix/reasoning-openai branch from fd6b1a3 to 2c5ceb5 Compare August 28, 2025 23:41
@steebchen
steebchen added this pull request to the merge queue Aug 29, 2025
Merged via the queue into main with commit 7510249 Aug 29, 2025
9 of 10 checks passed
@steebchen
steebchen deleted the fix/reasoning-openai branch August 29, 2025 00:36
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