Skip to content

fix: use max_completion_tokens for Azure OpenAI#760

Open
zerone0x wants to merge 2 commits intoevalstate:mainfrom
zerone0x:fix/azure-max-completion-tokens-461
Open

fix: use max_completion_tokens for Azure OpenAI#760
zerone0x wants to merge 2 commits intoevalstate:mainfrom
zerone0x:fix/azure-max-completion-tokens-461

Conversation

@zerone0x
Copy link
Copy Markdown

Summary

Fixes #461

  • send max_completion_tokens instead of max_tokens for Azure OpenAI chat completions
  • add a unit test covering Azure request args

Testing

  • not run (unit test added)

Co-Authored-By: Claude <noreply@anthropic.com>
@evalstate
Copy link
Copy Markdown
Owner

This was made with orbit?

@evalstate
Copy link
Copy Markdown
Owner

Triage result

Human attention: ⚠️ Required
Human decision needed: ready for human landing decision
Recommendation: 🏁 escalate to a human

Quick read

This PR appears ready for human landing review. It fixes the Azure OpenAI request-shaping bug at the right seam, the bug was locally reproduced and shown fixed, a small test-strengthening follow-up was added, Codex review is clear, CI is green, and the branch is conflict-free against origin/main.

Intent

Make Azure OpenAI requests work by sending the token limit under Azure’s expected field name and add a test so this provider-specific behavior is covered.

Why

fast-agent was sending max_tokens for Azure OpenAI chat completions, but some Azure models require max_completion_tokens instead. That causes 400 unsupported-parameter errors and blocks those Azure deployments.

Codex review

  • GitHub Codex review findings: none collected for the current head.
  • Local Codex review: successful and usable.
  • Local Codex conclusion: no concrete regression or blocking issue identified in the diff.
  • Minor follow-through was applied in this lane: the new Azure unit test was tightened so it explicitly exercises the non-reasoning Azure branch that originally emitted max_tokens, rather than being able to pass through a reasoning-model path.

CI/CD

  • Validation path: bug reproduction and fix confirmation.
  • Local validation established the bug and the fix:
    • pre-change behavior for a non-reasoning Azure model produced max_tokens
    • PR behavior for the same request produced max_completion_tokens
  • Active CI state: green/unrelated.
  • Reported GitHub Actions check: update_release_draft passing.
  • Initial conflict check: clean against origin/main.
  • Final conflict check: clean against origin/main.

Recommendation

🏁 Escalate to a human for the final landing decision. The change is small, targeted, validated, reviewed, and conflict-free, so this looks ready for normal human merge judgment.

@evalstate
Copy link
Copy Markdown
Owner

Triage result

Human attention: ⚠️ Required
Human decision needed: Please confirm whether this Azure-specific parameter translation is the desired fix and approve the change, or request a design adjustment if Azure/OpenAI handling should be generalized differently.
Recommendation: 🏁 escalate to a human

Quick read

This PR is addressing a real Azure OpenAI compatibility issue: some Azure deployments reject max_tokens and require max_completion_tokens instead.

Intent

Make fast-agent work with Azure OpenAI by sending the token limit under the parameter name Azure expects, and add a test to lock that behavior in.

Why

The issue report describes 400 errors from Azure OpenAI when max_tokens is sent. The patch changes the OpenAI request builder so Azure uses max_completion_tokens while non-Azure behavior stays the same.

Codex review

The code change is right-shaped and includes a unit test that asserts the Azure request payload uses max_completion_tokens and does not include max_tokens.

CI/CD

Validation could not be completed in this handoff because I could not execute the focused repro or test run in this environment. No conflict issues were detected in the merge state.

Recommendation

🏁 escalate to a human

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.

Azure OpenAI compatibility: max_tokens not supported, needs max_completion_tokens

2 participants