Skip to content

fix(tools): split concatenated streamed tool-call args - #36207

Closed
Jamesvagabond599 wants to merge 1 commit into
NousResearch:mainfrom
Jamesvagabond599:gen-ai/tool-call-payload-repair-pr25346-local
Closed

fix(tools): split concatenated streamed tool-call args#36207
Jamesvagabond599 wants to merge 1 commit into
NousResearch:mainfrom
Jamesvagabond599:gen-ai/tool-call-payload-repair-pr25346-local

Conversation

@Jamesvagabond599

@Jamesvagabond599 Jamesvagabond599 commented Jun 1, 2026

Copy link
Copy Markdown

What does this PR do?

Fixes streamed tool-call handling when a model emits multiple concatenated JSON tool-call argument payloads in one streamed argument buffer.

The repair splits adjacent complete JSON object payloads before reconstructing streamed mock tool calls, preventing concatenated tool-call arguments from being treated as a single invalid JSON blob.

Related Issue

Fixes tool-call argument streaming failures observed with local Hermes/Qwen-style runtime usage.

Fixes #

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • Adds _split_concatenated_tool_call_arguments(...) handling in agent/chat_completion_helpers.py.
  • Applies the splitter before streamed mock_tool_calls reconstruction.
  • Adds focused regression coverage in tests/test_model_tools_tool_call_payload_repair.py.
  • Preserves existing single-payload behavior and rejects incomplete/partial concatenations.

How to Test

  1. ./venv/bin/python -m pytest -q tests/test_model_tools_tool_call_payload_repair.py
  2. Confirm result: 3 passed.
  3. Confirm the branch contains only:
    • agent/chat_completion_helpers.py
    • tests/test_model_tools_tool_call_payload_repair.py

Checklist

Code

  • My commit messages follow Conventional Commits (fix(scope): ...)
  • I searched for existing PRs to make sure this isn’t a duplicate
  • My PR contains only changes related to this fix/feature
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes
  • I've tested on my platform: Linux / Fedora

Documentation & Housekeeping

  • I've updated relevant documentation — N/A, behavior-only bug fix with regression test
  • I've updated cli-config.yaml.example if I added/changed config keys — N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — N/A
  • I've considered cross-platform impact — pure Python parsing helper, no OS-specific behavior
  • I've updated tool descriptions/schemas if I changed tool behavior — N/A

For New Skills

[x] N/A — this PR does not add a skill

  • This skill is broadly useful to most users (if bundled) — see Contributing Guide
  • SKILL.md follows the standard format (frontmatter, trigger conditions, steps, pitfalls)
  • No external dependencies that aren't already available (prefer stdlib, curl, existing Hermes tools)
  • I've tested the skill end-to-end: hermes --toolsets skills -q "Use the X skill to do Y"

Screenshots / Logs

@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/tools Tool registry, model_tools, toolsets labels Jun 1, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #36039 and #25346 — same fix: splitting concatenated streamed tool-call argument payloads ({...}{...}) into separate calls via json.JSONDecoder.raw_decode(). All three target the same root cause (#25333). Consolidating effort on one of these would help maintainers avoid reviewing three near-identical implementations.

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/tools Tool registry, model_tools, toolsets P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants