Skip to content

fix(agent): drop tool_calls key when all tool_calls are deduplicated (#70126) - #70176

Closed
ms-alan wants to merge 3 commits into
NousResearch:mainfrom
ms-alan:fix/70126-sanitize-api-messages-tool-calls
Closed

fix(agent): drop tool_calls key when all tool_calls are deduplicated (#70126)#70176
ms-alan wants to merge 3 commits into
NousResearch:mainfrom
ms-alan:fix/70126-sanitize-api-messages-tool-calls

Conversation

@ms-alan

@ms-alan ms-alan commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Closes #70126

sanitize_api_messages() Step 3 deduplication creates tool_calls: []
when every tool_call in a turn has a duplicate id. This empty array
then passes through to strict OpenAI-compatible providers (Qwen-series)
which reject it with HTTP 400. Fix: when kept_tcs is empty after
dedup, drop the tool_calls key entirely instead of setting it to []. This
matches the behavior already present in the separate empty-tool_calls
cleanup step (lines 2736-2747) and ensures byte-stable persisted history.

chenbin added 3 commits July 24, 2026 00:08
Closes NousResearch#70146

When hermes sessions optimize-storage runs and the database grows
(rather than shrinks), the old code always printed '(reclaimed X MB)'
with a negative value. Fix by using a conditional label:
- positive delta → 'reclaimed X MB'
- negative delta → 'grew by X MB'
…upes

Closes NousResearch#70126

sanitize_api_messages() Step 3 deduplication creates tool_calls: []
when every tool_call in a turn has a duplicate id. This empty array
then passes through to strict OpenAI-compatible providers (Qwen-series)
which reject it with HTTP 400. Fix: when kept_tcs is empty after
dedup, drop the tool_calls key entirely instead of setting it to []. This
matches the behavior already present in the separate empty-tool_calls
cleanup step (lines 2736-2747) and ensures byte-stable persisted history.
…odels

GLM models (glm-4, glm-4-plus, etc.) use the same reasoning_effort:
ultra parameter as GPT-5.6 ultra. The _reasoning_config_for_model
function was only checking for gpt-5.6, causing GLM reasoning effort
to be sent as raw string 'ultra' instead of the normalized integer.
This fixes the mismatch for GLM model families.

Closes NousResearch#70058
@ms-alan ms-alan closed this Jul 23, 2026
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/cli CLI entry point, hermes_cli/, setup wizard provider/qwen Qwen / Alibaba Cloud (OAuth) sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state duplicate This issue or pull request already exists labels Jul 23, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Duplicate of #64345 for the same sanitize_api_messages dedup-output empty-tool_calls fix. This PR also bundles unrelated transport and CLI display changes; please consolidate the focused repair with the canonical PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/cli CLI entry point, hermes_cli/, setup wizard duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists provider/qwen Qwen / Alibaba Cloud (OAuth) sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: sanitize_api_messages dedup writes tool_calls: [], breaking Qwen-series tool-calling sessions on v0.18.2+

2 participants