Skip to content

fix: Agent OpenAI calls fail for GPT-5 and o-series models#3367

Open
eniok wants to merge 1 commit into
parse-community:alphafrom
eniok:feat/agent-openai-next-gen-models
Open

fix: Agent OpenAI calls fail for GPT-5 and o-series models#3367
eniok wants to merge 1 commit into
parse-community:alphafrom
eniok:feat/agent-openai-next-gen-models

Conversation

@eniok
Copy link
Copy Markdown

@eniok eniok commented May 26, 2026

New Pull Request Checklist

Issue Description

The dashboard AI agent could only talk to OpenAI models up to GPT-4.1. Configuring a newer model (the GPT-5 family or the o-reasoning series, e.g. gpt-5.4, gpt-5.5, o1, o3) failed with:

OpenAI API error: Unsupported parameter: 'max_tokens' is not supported with this model. Use 'max_completion_tokens' instead.

OpenAI changed the Chat Completions contract for these newer models:

  • max_tokens was renamed to max_completion_tokens
  • only the default temperature is accepted

The agent's request body in Parse-Dashboard/app.js hardcoded max_tokens: 2000 and temperature: 0.7, so any next-generation model was rejected by the API.

Approach

  • Added a small, pure, unit-tested helper Parse-Dashboard/openAIModelParams.js that detects the model generation from its name and returns the correct token/temperature parameters.
    • Legacy (GPT-4.1 and older, gpt-4o, gpt-4-turbo, gpt-3.5-turbo, …) → max_tokens + temperature: 0.7 (unchanged behavior).
    • Next-gen (gpt-5+ and the o-series) → max_completion_tokens, temperature omitted.
    • Unknown/unmatched names default to the legacy contract for backwards compatibility.
  • Wired it into both OpenAI request bodies (initial call and tool-call follow-up) in Parse-Dashboard/app.js via object spread, keeping the rest of the request unchanged.
  • Updated the README agent docs to note both model generations are supported.

This keeps full legacy support intact while enabling newer models.

TODOs before merging

  • Add tests
  • Add changes to documentation (guides, repository pages, code comments, etc.)
  • Add security check

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added support for next-generation OpenAI models (GPT-5, o-series reasoning models) with automatic API parameter adaptation based on model generation
  • Documentation

    • Updated README to document support for both legacy and newer OpenAI models, including details on automatic parameter adjustment

Review Change Stack

The agent hardcoded `max_tokens` and `temperature` in the Chat
Completions request body. Newer OpenAI models (the GPT-5 family and the
o-reasoning series) reject `max_tokens` in favor of
`max_completion_tokens` and only accept the default temperature, so
configuring e.g. `gpt-5.5` failed with "Unsupported parameter:
'max_tokens' is not supported with this model."

Add a pure, testable helper (openAIModelParams.js) that detects the
model generation and emits the correct token/temperature parameters,
preserving legacy behavior for GPT-4.1 and older.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@parse-github-assistant
Copy link
Copy Markdown

parse-github-assistant Bot commented May 26, 2026

🚀 Thanks for opening this pull request! We appreciate your effort in improving the project. Please let us know once your pull request is ready for review.

Tip

  • Keep pull requests small. Large PRs will be rejected. Break complex features into smaller, incremental PRs.
  • Use Test Driven Development. Write failing tests before implementing functionality. Ensure tests pass.
  • Group code into logical blocks. Add a short comment before each block to explain its purpose.
  • We offer conceptual guidance. Coding is up to you. PRs must be merge-ready for human review.
  • Our review focuses on concept, not quality. PRs with code issues will be rejected. Use an AI agent.
  • Human review time is precious. Avoid review ping-pong. Inspect and test your AI-generated code.

Note

Please respond to review comments from AI agents just like you would to comments from a human reviewer. Let the reviewer resolve their own comments, unless they have reviewed and accepted your commit, or agreed with your explanation for why the feedback was incorrect.

Caution

Pull requests must be written using an AI agent with human supervision. Pull requests written entirely by a human will likely be rejected, because of lower code quality, higher review effort and the higher risk of introducing bugs. Please note that AI review comments on this pull request alone do not satisfy this requirement. Our CI and AI review are safeguards, not development tools. If many issues are flagged, rethink your development approach. Invest more effort in planning and design rather than using review cycles to fix low-quality code.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 2026

📝 Walkthrough

Walkthrough

The PR adds support for next-generation OpenAI models by introducing a utility module that detects model generation and adapts API request parameters accordingly. The feature is integrated into existing agent request flows and documented in the configuration reference.

Changes

Next-gen Model Parameter Support

Layer / File(s) Summary
Model Parameter Adaptation Utility
Parse-Dashboard/openAIModelParams.js, src/lib/tests/openAIModelParams.test.js
New utility module detects whether a model uses next-gen (GPT-5+, o1, o3) or legacy (GPT-4.x, gpt-3.5-turbo) OpenAI API contracts and builds request parameters accordingly: next-gen uses max_completion_tokens and omits temperature; legacy uses max_tokens plus temperature. Comprehensive tests cover model classification and parameter construction.
OpenAI Request Flow Integration
Parse-Dashboard/app.js, README.md
Imports and integrates buildModelParams() into both the initial OpenAI Chat Completions request and post-tool-call follow-up request, replacing hardcoded generation settings. README documents supported model families and automatic parameter adaptation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 6 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Engage In Review Feedback ❓ Inconclusive Cannot verify review feedback engagement without access to GitHub PR comments/discussions, which are not stored in the git repository. Check the PR on GitHub to confirm: (1) if review comments exist, (2) whether they were addressed via new commits or discussion before resolution, (3) whether feedback was properly engaged with before closure.
✅ Passed checks (6 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: Agent OpenAI calls fail for GPT-5 and o-series models' correctly uses the 'fix:' prefix, clearly summarizes the main issue being addressed, and directly matches the primary change in the PR.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Security Check ✅ Passed No vulnerabilities found. Model parameter from validated config; buildModelParams uses safe regex/string ops; returns hardcoded objects; no injection/command execution.
Description check ✅ Passed The PR description is comprehensive and detailed, covering the issue, approach, and completion of required tasks with proper formatting.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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.

eniok

This comment was marked as low quality.

Copy link
Copy Markdown
Member

@mtrezza mtrezza left a comment

Choose a reason for hiding this comment

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

This looks too model specific; we want to move towards abstraction, not specificity, to support non-OpenAI models in the future. Why not make the passed model params part of the model config, and allow to override default params? This way dashboard doesn't need to mirror param changes in the future.

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.

2 participants