Skip to content

feat(xai): allow reasoning_effort on Grok-4 family#2

Open
acrogenesis wants to merge 1 commit into
mainfrom
xai-reasoning-effort-grok4
Open

feat(xai): allow reasoning_effort on Grok-4 family#2
acrogenesis wants to merge 1 commit into
mainfrom
xai-reasoning-effort-grok4

Conversation

@acrogenesis
Copy link
Copy Markdown
Member

xAI now exposes the reasoning_effort parameter on all reasoning-capable Grok-4 models (none / low / medium / high — default "low"):

https://docs.x.ai/developers/model-capabilities/text/reasoning

The translate_options/3 guard that stripped the parameter for any model whose id contained "grok-4" was written before that landed. Forward reasoning_effort to the API for Grok-4 the same way it already does for Grok-3 mini variants, and update the model-compatibility note + test accordingly.

Description

Brief description of changes.

Type of Change

  • Bug fix (non-breaking change fixing an issue)
  • New feature (non-breaking change adding functionality)
  • Breaking change (fix or feature causing existing functionality to change)
  • Documentation update

Breaking Changes

Testing

  • Tests pass (mix test)
  • Quality checks pass (mix quality)

Checklist

  • My code follows the project's style guidelines
  • I have updated the documentation accordingly
  • I have added tests that prove my fix/feature works
  • All new and existing tests pass
  • My commits follow conventional commit format
  • I have NOT edited CHANGELOG.md (it is auto-generated by git_ops)

Related Issues

Closes #

Copy link
Copy Markdown

@palantir-valiot palantir-valiot Bot left a comment

Choose a reason for hiding this comment

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

Overall Assessment

This PR removes the outdated guard in translate_options/3 that dropped reasoning_effort for any Grok-4 model id, allowing the parameter (none/low/medium/high) to be forwarded exactly as it already is for Grok-3-mini variants. Documentation and the relevant test are updated. Implementation is sound; only one low-severity style violation found.

Findings

# Severity File Issue
1 Low test/providers/xai_test.exs Inline comments inside test function body violate AGENTS.md rule against comments in function bodies

Notes

  • Test coverage for the reasoning_effort path is present and was correctly updated.
  • The duplicate Keyword.pop for :reasoning_effort (lines 722 and 776) is pre-existing code and was not modified by this PR, so it was not flagged.
  • No other logic, security, or performance issues identified.

assert Keyword.get(translated_opts, :reasoning_effort) == "high"
assert warnings == []

# Grok-4 family now supports reasoning_effort
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This comment block inside the test function body violates the project rule in AGENTS.md: "DO NOT WRITE COMMENTS INTO THE BODY OF ANY FUNCTIONS." Remove it (the test name + assertions already document the intent).

xAI now exposes the reasoning_effort parameter on all reasoning-capable
Grok-4 models (none / low / medium / high — default "low"):

  https://docs.x.ai/developers/model-capabilities/text/reasoning

The translate_options/3 guard that stripped the parameter for any model
whose id contained "grok-4" was written before that landed. Forward
reasoning_effort to the API for Grok-4 the same way it already does for
Grok-3 mini variants, and update the model-compatibility note + test
accordingly.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@acrogenesis acrogenesis force-pushed the xai-reasoning-effort-grok4 branch from 5007891 to 18e8b31 Compare May 14, 2026 15:30
Copy link
Copy Markdown

@palantir-valiot palantir-valiot Bot left a comment

Choose a reason for hiding this comment

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

Overall Assessment

The PR removes the Grok-4 exclusion guard in translate_options/3 so that reasoning_effort (including the new "none" value) is forwarded for the Grok-4 family exactly as it already is for Grok-3-mini variants. Documentation and tests are updated in lockstep. The implementation is correct and low-risk; only cosmetic issues remain.

Findings

No actionable findings.

Notes

  • Updated the validates reasoning_effort model compatibility test to assert successful forwarding for grok-4 (good coverage of the behavioral change).
  • The double Keyword.pop/put sequence for :reasoning_effort inside translate_options/3 (lines 722-732 then 776-783) is redundant but harmless and was not introduced by this PR.
  • The @doc for encode_body/1 still claims reasoning_effort support is "for grok-3-mini models" only; the moduledoc and guide were updated but this one was missed. Would be caught by a documentation pass.

@acrogenesis acrogenesis force-pushed the main branch 2 times, most recently from fbe4ba1 to aacce19 Compare May 14, 2026 16:12
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