fix(agent,transport): drop empty tool_calls array for strict API compatibility - #68942
Closed
lapapatech wants to merge 2 commits into
Closed
fix(agent,transport): drop empty tool_calls array for strict API compatibility#68942lapapatech wants to merge 2 commits into
lapapatech wants to merge 2 commits into
Conversation
added 2 commits
July 21, 2026 23:38
DeepSeek rechaza assistant messages con tool_calls=[] (HTTP 400 'Expected an array with minimum length 1'). Historiales escritos por versiones anteriores pueden contener el array vacío; se elimina la clave en la copia saliente dentro de _sanitize_tool_calls_for_strict_api.
El parche anterior solo cubría el camino de resumen (handle_max_iterations); el bucle principal pasa por ChatCompletionsTransport.convert_messages, que ahora también elimina 'tool_calls: []' de la copia saliente.
Collaborator
This was referenced Jul 27, 2026
Contributor
|
Thanks for the focused strict-provider compatibility fix. This is already implemented on current
|
This was referenced Aug 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
DeepSeek and Fireworks (among other strict API providers) reject assistant messages containing
tool_calls: []with HTTP 400:Empty tool_calls arrays appear in histories written by older versions of Hermes Agent. These histories are stored on disk and replayed, causing every subsequent request in the session to fail once an empty tool_calls message enters the context.
Fix
Two changes across the message pipeline:
run_agent.py —
_sanitize_tool_calls_for_strict_api()now strips emptytool_callsarrays from the message copy before sending to the provider. This covers the summary/retry path (handle_max_iterations).agent/transports/chat_completions.py —
convert_messages()(the main-loop message sanitizer) now detects emptytool_callsarrays in the detection phase and removes them from the outgoing copy in the sanitization phase. This covers the primary request path used by ~16 OpenAI-compatible providers.Both fixes operate on copies — no stored history is mutated.