hermes - ✅(Solved) Fix [Bug]: xAI grok-4-1-fast returns HTTP 400 — "does not support parameter reasoningEffort" [3 pull requests, 1 comments, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#23088Fetched 2026-05-11 03:31:18
View on GitHub
Comments
1
Participants
1
Timeline
9
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×4labeled ×4commented ×1

Error Message

Non-retryable error (HTTP 400) — trying fallback... Primary model failed — switching to fallback: anthropic/claude-sonnet-4.6 via openrouter

Error: HTTP 400: Error code: 400 - {'code': 'Client specified an invalid argument', 'error': 'Model grok-4-1-fast does not support parameter reasoningEffort.'}

Root Cause

HTTP 400 on every call. The xAI API rejects the request because it contains a reasoningEffort parameter that grok-4-1-fast does not support.

Fix Action

Fixed

PR fix notes

PR #23106: fix(transports/codex): gate xAI reasoning.effort per model

Description (problem / solution / changelog)

Summary

  • xAI's Responses API rejects reasoning.effort on most Grok models with HTTP 400; only grok-4.3 and grok-4.20-multi-agent accept it per xAI's reasoning capability docs. The codex transport was sending it (plus the reasoning.encrypted_content include) unconditionally for every xAI model, which was breaking primary-model calls on grok-4-1-fast and forcing fallback on every request.
  • Add a per-model allowlist helper in agent/transports/codex.py using exact-or-hyphen-delimited matching (with optional OpenRouter x-ai/ prefix strip) and gate both kwargs["reasoning"] and kwargs["include"] = ["reasoning.encrypted_content"] inside that branch. Debug-log when a configured reasoning_effort is silently dropped for an unsupported model.
  • Existing happy-path behavior on grok-4.3 is preserved; no other provider paths (OpenAI, Anthropic, OpenRouter, Kimi, GitHub Models, LM Studio) are touched.
  • Replace the inaccurate "no reasoning_effort parameter needed" claim in the xAI provider docs with the correct per-model gating contract; mirror under the global Reasoning Effort configuration section.

Fixes #23088.

Test plan

  • uv run pytest tests/agent/transports/test_codex_transport.py -q — 56 passed (29 existing + 27 new in TestCodexXaiReasoningEffortGating).
  • uv run pytest tests/agent/transports/ tests/hermes_cli/test_reasoning_effort_menu.py -q — 198 passed.
  • Adversarial check: stash the fix, regression tests fail (including the literal grok-4-1-fast repro); restore, all green.
  • Boundary tests pin: grok-4.30 does NOT match grok-4.3; x-ai/grok-4.3 (OpenRouter) does match; mixed-case still gates correctly; empty/None model does not crash.
  • Live smoke test against grok-4-1-fast with a real XAI_API_KEY — to be run by the issue reporter after this lands.

Changed files

  • agent/transports/codex.py (modified, +36/-3)
  • tests/agent/transports/test_codex_transport.py (modified, +264/-0)
  • website/docs/integrations/providers.md (modified, +5/-1)
  • website/docs/user-guide/configuration.md (modified, +4/-0)

PR #23109: fix(xai): skip reasoning effort for grok 4.1 responses

Description (problem / solution / changelog)

Summary

  • avoid sending xAI reasoning effort for grok-4-1 response models that hard-fail with HTTP 400
  • keep encrypted reasoning includes intact for the xAI responses path
  • add focused transport coverage for supported and unsupported Grok variants

Verification

  • UV_PYTHON=3.11 uv run --frozen pytest -q -o addopts= tests/agent/transports/test_codex_transport.py\n- UV_PYTHON=3.11 uv run --frozen ruff check agent/transports/codex.py tests/agent/transports/test_codex_transport.py

Changed files

  • agent/transports/codex.py (modified, +14/-1)
  • tests/agent/transports/test_codex_transport.py (modified, +19/-0)

PR #23460: fix(transports/codex): remove unsupported include parameter for standard OpenAI Chat Completions API

Description (problem / solution / changelog)

Summary

Fixes #23450: OpenAI Chat Completions API does not support the include parameter, causing HTTP 400 errors when Hermes sends include: [reasoning.encrypted_content] to the standard Chat Completions endpoint.

Root Cause

In agent/transports/codex.py, the build_kwargs() method unconditionally sets:

kwargs["include"] = ["reasoning.encrypted_content"]

for general backends (non-xAI, non-GitHub Responses) when reasoning is enabled. This is incorrect for:

  • Standard OpenAI Chat Completions API (api.openai.com/v1) - does NOT support the include parameter
  • Other general backends that may not support encrypted content

The include parameter with reasoning.encrypted_content is only valid for:

  • xAI backend (already gated per model in #23106)
  • GitHub Responses API (handles it separately)

Fix

  • Removed kwargs["include"] = ["reasoning.encrypted_content"] for general backends
  • Added explanatory comment about backend-specific include parameter support
  • The reasoning parameter is still sent to general backends (OpenAI supports it)
  • The elif not is_github_responses and not is_xai_responses: kwargs["include"] = [] line remains for when reasoning is disabled

Regression Coverage

Added TestCodexIncludeParameterGating class with 4 tests:

  • test_openai_chat_completions_no_include_when_enabled - verifies standard OpenAI API does NOT receive include parameter (but does receive reasoning)
  • test_xai_include_with_reasoning_enabled - verifies xAI backend still receives include parameter (preserving #23106 behavior)
  • test_github_responses_no_include_without_extra - verifies GitHub Responses does NOT receive include without github_reasoning_extra
  • test_github_responses_reasoning_without_include - verifies GitHub Responses can use reasoning but not include

All 28 tests in test_codex_transport.py pass.

Related Issues

  • #23450: This fix
  • #23106: xAI reasoning.effort gating (same class of bug, different backend)
  • #23088: Original xAI bug report

Test Plan

  • python -m pytest tests/agent/transports/test_codex_transport.py -v — 28 passed
  • Verified xAI tests still pass (preserving #23106 behavior)
  • Verified GitHub Responses tests still pass
  • Manual verification: standard OpenAI Chat Completions API no longer receives include parameter

Changed files

  • agent/transports/codex.py (modified, +2/-1)
  • gateway/platforms/whatsapp.py (modified, +4/-1)
  • tests/agent/transports/test_codex_transport.py (modified, +70/-0)
  • tests/tools/test_file_tools.py (modified, +37/-0)
  • tools/file_tools.py (modified, +6/-6)

Code Example

Non-retryable error (HTTP 400) — trying fallback...
Primary model failed — switching to fallback: anthropic/claude-sonnet-4.6 via openrouter

Error: HTTP 400: Error code: 400 - {'code': 'Client specified an invalid argument',
'error': 'Model grok-4-1-fast does not support parameter reasoningEffort.'}

---

yaml
   model:
     default: grok-4-1-fast
     provider: xai

---

Report       https://paste.rs/CL1md
  agent.log    https://dpaste.com/H4X5F7U6C
  gateway.log  https://dpaste.com/CMB243MTG

---
RAW_BUFFERClick to expand / collapse

Bug Description

Hello! First off, thank you all for this wonderful software! It has been a pleasure using this so far on both CLI and Slack, and I look forward to even more enhancements and integrations soon.

After updating hermes-agent today, every primary model call (I'm using xAI grok-4-1-fast, which I know should be retiring soon, but nevertheless,) fails immediately with HTTP 400 and falls back to the configured fallback model:

Non-retryable error (HTTP 400) — trying fallback...
Primary model failed — switching to fallback: anthropic/claude-sonnet-4.6 via openrouter

Error: HTTP 400: Error code: 400 - {'code': 'Client specified an invalid argument',
'error': 'Model grok-4-1-fast does not support parameter reasoningEffort.'}

Steps to Reproduce

  1. Configure Hermes with xAI provider + grok-4-1-fast:
   yaml
   model:
     default: grok-4-1-fast
     provider: xai
  1. Start the gateway (or CLI)
  2. Send any message

Expected Behavior

Request succeeds; model responds normally.

Actual Behavior

HTTP 400 on every call. The xAI API rejects the request because it contains a reasoningEffort parameter that grok-4-1-fast does not support.

Affected Component

Setup / Installation

Messaging Platform (if gateway-related)

N/A (CLI only)

Debug Report

Report       https://paste.rs/CL1md
  agent.log    https://dpaste.com/H4X5F7U6C
  gateway.log  https://dpaste.com/CMB243MTG

Operating System

Debian GNU/Linux 13 (trixie), kernel 6.12.85+deb13-amd64

Python Version

3.11.15

Hermes Version

v0.13.0 (2026.5.7)

Additional Logs / Traceback (optional)

Root Cause Analysis (optional)

The xAI provider plugin (plugins/model-providers/xai/__init__.py) unconditionally sets api_mode="codex_responses", routing all requests to /v1/responses. The codex transport (agent/transports/codex.py line 106–108) sends reasoning: {"effort": "medium"} for xAI. However, the xAI Responses API appears to serialize or forward this as the top-level reasoningEffort field, which grok-4-1-fast rejects - this field only works for grok-4-3 and later.

Relevant code pointers:

Reference:

Proposed Fix (optional)

Implement reasoning_effort only for Grok 4.3 and later iterations - Grok 4.1 now fails, and presumably Grok 4.20 as well.

Are you willing to submit a PR for this?

  • I'd like to fix this myself and submit a PR

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING