mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-25 05:52:34 +00:00
feat(transports/codex): pass reasoning.effort to xAI Responses API
The is_xai_responses branch only sent include=[reasoning.encrypted_content] without forwarding the resolved reasoning_effort. Other Responses providers (OpenAI, GitHub) already get effort forwarded — this aligns the xAI path. Without this, agent.reasoning_effort is silently dropped on the xAI direct path, making Hermes unable to control reasoning depth on grok-4.x via api.x.ai. Tests added to TestCodexBuildKwargs cover effort passthrough, disabled state, and minimal-clamp parity with non-xAI.
This commit is contained in:
parent
252d68fd45
commit
cd712b176a
2 changed files with 32 additions and 0 deletions
|
|
@ -105,6 +105,7 @@ class ResponsesApiTransport(ProviderTransport):
|
||||||
|
|
||||||
if reasoning_enabled and is_xai_responses:
|
if reasoning_enabled and is_xai_responses:
|
||||||
kwargs["include"] = ["reasoning.encrypted_content"]
|
kwargs["include"] = ["reasoning.encrypted_content"]
|
||||||
|
kwargs["reasoning"] = {"effort": reasoning_effort}
|
||||||
elif reasoning_enabled:
|
elif reasoning_enabled:
|
||||||
if is_github_responses:
|
if is_github_responses:
|
||||||
github_reasoning = params.get("github_reasoning_extra")
|
github_reasoning = params.get("github_reasoning_extra")
|
||||||
|
|
|
||||||
|
|
@ -149,6 +149,37 @@ class TestCodexBuildKwargs:
|
||||||
# "minimal" should be clamped to "low"
|
# "minimal" should be clamped to "low"
|
||||||
assert kw.get("reasoning", {}).get("effort") == "low"
|
assert kw.get("reasoning", {}).get("effort") == "low"
|
||||||
|
|
||||||
|
def test_xai_reasoning_effort_passed(self, transport):
|
||||||
|
messages = [{"role": "user", "content": "Hi"}]
|
||||||
|
kw = transport.build_kwargs(
|
||||||
|
model="grok-4.3", messages=messages, tools=[],
|
||||||
|
is_xai_responses=True,
|
||||||
|
reasoning_config={"effort": "high"},
|
||||||
|
)
|
||||||
|
# xAI Responses must receive both encrypted reasoning content and the effort
|
||||||
|
assert kw.get("reasoning") == {"effort": "high"}
|
||||||
|
assert "reasoning.encrypted_content" in kw.get("include", [])
|
||||||
|
|
||||||
|
def test_xai_reasoning_disabled_no_reasoning_key(self, transport):
|
||||||
|
messages = [{"role": "user", "content": "Hi"}]
|
||||||
|
kw = transport.build_kwargs(
|
||||||
|
model="grok-4.3", messages=messages, tools=[],
|
||||||
|
is_xai_responses=True,
|
||||||
|
reasoning_config={"enabled": False},
|
||||||
|
)
|
||||||
|
# When reasoning is disabled, do not send the reasoning key at all
|
||||||
|
assert "reasoning" not in kw
|
||||||
|
|
||||||
|
def test_xai_minimal_effort_clamped(self, transport):
|
||||||
|
messages = [{"role": "user", "content": "Hi"}]
|
||||||
|
kw = transport.build_kwargs(
|
||||||
|
model="grok-4.3", messages=messages, tools=[],
|
||||||
|
is_xai_responses=True,
|
||||||
|
reasoning_config={"effort": "minimal"},
|
||||||
|
)
|
||||||
|
# "minimal" should be clamped to "low" for xAI as well
|
||||||
|
assert kw.get("reasoning", {}).get("effort") == "low"
|
||||||
|
|
||||||
|
|
||||||
class TestCodexValidateResponse:
|
class TestCodexValidateResponse:
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue