hermes - ✅(Solved) Fix run_agent: 'Unrepairable tool_call arguments' when Gemini-3-Flash-Preview emits parallel tool calls as }{ — JSON parser drops them [2 pull requests, 3 comments, 3 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#25333Fetched 2026-05-14 03:47:13
View on GitHub
Comments
3
Participants
3
Timeline
13
Reactions
0
Author
Timeline (top)
cross-referenced ×4labeled ×4commented ×3referenced ×1

Root Cause

Suggested fix direction: when the JSON parser fails because of trailing characters after a complete object, attempt to split on the boundary and emit each {...} as a separate tool_call. Either in run_agent's normalisation step or in the Gemini-specific adapter.

Fix Action

Fix / Workaround

Workaround for users: switch to a model that emits one tool call per chunk until the parser handles }{. From the same Issue #5 repro, Claude / GPT / older Gemini work cleanly.

PR fix notes

PR #25346: fix(run_agent): split concatenated streamed tool-call args

Description (problem / solution / changelog)

Summary

  • split fully decodable concatenated tool-call argument blobs like {"a":1}{"b":2} into separate streamed tool calls
  • keep existing truncation handling for partial or otherwise non-lossless payloads
  • add regression coverage for both the splitter and streaming assembly path

Testing

  • uv run --frozen pytest -o addopts='' tests/run_agent/test_repair_tool_call_arguments.py tests/run_agent/test_run_agent.py::TestStreamingApiCall::test_concatenated_json_arguments_split_into_parallel_tool_calls tests/run_agent/test_run_agent.py::TestStreamingApiCall::test_ollama_reused_index_separate_tool_calls tests/run_agent/test_run_agent.py::TestStreamingApiCall::test_truncated_tool_call_args_upgrade_finish_reason_to_length
  • git diff --check
  • uv run --frozen ruff check run_agent.py tests/run_agent/test_repair_tool_call_arguments.py tests/run_agent/test_run_agent.py

Attribution

Known red Tests on recent company PRs and origin/main is treated as preexisting_unrelated baseline noise; this candidate's targeted local gate is green.

Closes #25333.

Changed files

  • run_agent.py (modified, +56/-0)
  • tests/run_agent/test_repair_tool_call_arguments.py (modified, +14/-1)
  • tests/run_agent/test_run_agent.py (modified, +30/-0)

PR #25347: fix(agent): repair concatenated JSON tool_call arguments from Gemini parallel calls

Description (problem / solution / changelog)

Summary

When Gemini-3-Flash-Preview emits parallel tool calls, it produces concatenated JSON objects like {...}{...} without any delimiter. The existing repair passes in _repair_tool_call_arguments() fail to parse this and replace both calls with empty objects ({}), dropping user intent entirely.

Changes

  • run_agent.py: Add repair pass 5 using json.JSONDecoder.raw_decode() to extract the first complete JSON object when trailing { content is detected after a valid object. This preserves at least the first tool call instead of discarding both.
  • tests/run_agent/test_repair_tool_call_arguments.py: Add 3 tests covering concatenated objects, nested braces in values, and regression for single valid objects.

Root Cause

The raw_decode() method parses exactly one JSON value from the start of a string and returns the end index. When the remainder starts with {, we know the arguments contain concatenated objects from parallel tool calls. We extract and return just the first valid object.

Testing

pytest tests/run_agent/test_repair_tool_call_arguments.py -v
# 24 passed

Fixes #25333

Changed files

  • run_agent.py (modified, +24/-0)
  • tests/run_agent/test_repair_tool_call_arguments.py (modified, +22/-0)

Code Example

2026-05-13 21:03:25,108 WARNING run_agent: Unrepairable tool_call arguments for yantrikdb_relate — replaced with empty object (was: {"entity": "Don Bowman", "relationship": "works_at", "target": "Agilicus"}{"enti)
RAW_BUFFERClick to expand / collapse

Repro: agent running gemini-3-flash-preview emits multiple parallel tool calls in one streaming chunk separated only by }{ (no JSON-array wrapper, no delimiter). Hermes' run_agent JSON parser reads from the first {, hits the matching }, encounters the second { immediately, and fails the whole blob as "unrepairable" — both tool calls dropped.

Log signature (from a yantrikdb-hermes-plugin user, yantrikos/yantrikdb-hermes-plugin#5):

2026-05-13 21:03:25,108 WARNING run_agent: Unrepairable tool_call arguments for yantrikdb_relate — replaced with empty object (was: {"entity": "Don Bowman", "relationship": "works_at", "target": "Agilicus"}{"enti)

That trailing {"enti is the start of a second relate call ({"entity": ...}) immediately following the first complete one. No \n, no ,, no }{ array-elem syntax — just two raw objects glued together.

The string-truncation cases ({"text": "Use Canadian/British Englis)) are likely the same bug seen mid-object: when the parser fails on the next-object's {, it surfaces the truncated (was:...) log with whatever it'd seen up to the failure point.

Affected:

  • Model: gemini-3-flash-preview consistently exhibits this. Older Gemini (gemini-2.0-flash, gemini-2.5-pro), Claude, and GPT-4o don't — they emit one tool call per streaming chunk with proper boundaries.
  • Hermes path: run_agent's tool-call reassembler / Gemini adapter.
  • Plugin-agnostic: any plugin with two-or-more parallel tool calls hits this.

Suggested fix direction: when the JSON parser fails because of trailing characters after a complete object, attempt to split on the boundary and emit each {...} as a separate tool_call. Either in run_agent's normalisation step or in the Gemini-specific adapter.

Workaround for users: switch to a model that emits one tool call per chunk until the parser handles }{. From the same Issue #5 repro, Claude / GPT / older Gemini work cleanly.

Happy to provide more log samples or test against a candidate fix — I have a reproducible case from a live Hermes user.

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

hermes - ✅(Solved) Fix run_agent: 'Unrepairable tool_call arguments' when Gemini-3-Flash-Preview emits parallel tool calls as }{ — JSON parser drops them [2 pull requests, 3 comments, 3 participants]