hermes - ✅(Solved) Fix [Bug]: `patch` tool conditionally required parameters are systematically omitted [1 pull requests, 1 comments, 2 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#15524Fetched 2026-04-26 05:26:54
View on GitHub
Comments
1
Participants
2
Timeline
8
Reactions
0
Author
Participants
Timeline (top)
labeled ×4commented ×1cross-referenced ×1referenced ×1

The patch tool's conditionally required parameters (old_string/new_string for replace mode, patch for patch mode) are systematically omitted when the tool is called via the standard tool-calling mechanism. This results in schema validation errors regardless of model (tested on kimi-k2.6 and kimi-k2.5).

Error Message

Actual: Error "old_string and new_string required". Actual: Error "patch content required". Actual: Error "patch content required".

Additional Logs / Traceback (optional)

Root Cause

Root Cause Analysis (optional)

Fix Action

Fix / Workaround

Summary

The patch tool's conditionally required parameters (old_string/new_string for replace mode, patch for patch mode) are systematically omitted when the tool is called via the standard tool-calling mechanism. This results in schema validation errors regardless of model (tested on kimi-k2.6 and kimi-k2.5).

Environment

  • Platform: Hermes Agent CLI
  • Models tested: kimi-k2.6, kimi-k2.5
  • Tool affected: patch
  1. Attempt to call patch in replace mode with old_string and new_string:

PR fix notes

PR #15673: fix(patch-tool): advertise per-mode required params in schema descriptions

Description (problem / solution / changelog)

Problem

Strict LLM backends (e.g. kimi-k2.x, reported in #15524) omit conditionally-required parameters like old_string/new_string for replace mode because the PATCH_SCHEMA only declares required: ["mode"]. The model sees every other parameter as optional and skips them, resulting in runtime errors.

Root cause

JSON Schema has no standard way to express "required if another field equals X" that all providers accept. The obvious fix—anyOf at the parameters level—breaks at least three providers:

  • Anthropic API rejects anyOf/oneOf/allOf on tool parameter schemas (documented in tests/honcho_plugin/test_session.py:376)
  • Fireworks rejects the same
  • Kimi/Moonshot: agent/moonshot_schema.py has a sanitizer bug where anyOf causes it to strip type then re-add it, resulting in a schema Kimi rejects

Fix

Add explicit guidance in the descriptions — the only universally-accepted signalling mechanism:

  1. Top-level description restructured with REPLACE MODE and PATCH MODE sections, each listing REQUIRED PARAMETERS: ...
  2. Per-property description prefixed with REQUIRED when mode='replace' / REQUIRED when mode='patch' for the conditionally-required fields
  3. required array stays ["mode"] — no anyOf / oneOf

Tests

Added TestPatchSchemaShape (9 assertions) to tests/tools/test_file_tools.py that lock the schema shape and guard against regressions:

  • Verifies top-level description documents required params for both modes
  • Verifies each conditionally-required property has REQUIRED when mode= in its description
  • Verifies no anyOf/oneOf at parameters level
  • Verifies required == ["mode"]

All 32 tests pass.

Closes #15524

Changed files

  • tests/tools/test_file_tools.py (modified, +45/-0)
  • tools/file_tools.py (modified, +38/-9)

Code Example

{
  "mode": "replace",
  "path": "/tmp/test.txt",
  "old_string": "line2",
  "new_string": "line2_modified"
}

---

{
  "mode": "patch",
  "path": "/tmp/test.txt",
  "patch": "*** Begin Patch\n*** Update File: /tmp/test.txt\n@@ context @@\n-line2\n+line2_modified\n*** End Patch"
}

---

Report     https://paste.rs/gUkOC
  agent.log  https://paste.rs/zsFxN

---
RAW_BUFFERClick to expand / collapse

Bug Description

Summary

The patch tool's conditionally required parameters (old_string/new_string for replace mode, patch for patch mode) are systematically omitted when the tool is called via the standard tool-calling mechanism. This results in schema validation errors regardless of model (tested on kimi-k2.6 and kimi-k2.5).

Environment

  • Platform: Hermes Agent CLI
  • Models tested: kimi-k2.6, kimi-k2.5
  • Tool affected: patch

Steps to Reproduce

  1. Attempt to call patch in replace mode with old_string and new_string:
{
  "mode": "replace",
  "path": "/tmp/test.txt",
  "old_string": "line2",
  "new_string": "line2_modified"
}

Expected: Tool executes successfully.
Actual: Error "old_string and new_string required".

  1. Attempt to call patch in patch mode with patch parameter:
{
  "mode": "patch",
  "path": "/tmp/test.txt",
  "patch": "*** Begin Patch\n*** Update File: /tmp/test.txt\n@@ context @@\n-line2\n+line2_modified\n*** End Patch"
}

Expected: Tool executes successfully.
Actual: Error "patch content required".

Expected Behavior

Tool executes successfully.

Actual Behavior

Actual: Error "patch content required".

Affected Component

CLI (interactive chat)

Messaging Platform (if gateway-related)

No response

Debug Report

Report     https://paste.rs/gUkOC
  agent.log  https://paste.rs/zsFxN

Operating System

Ubuntu 24.04

Python Version

No response

Hermes Version

No response

Additional Logs / Traceback (optional)

Root Cause Analysis (optional)

No response

Proposed Fix (optional)

No response

Are you willing to submit a PR for this?

  • I'd like to fix this myself and submit a PR

extent analysis

TL;DR

The patch tool's required parameters are being omitted when called via the standard tool-calling mechanism, resulting in schema validation errors.

Guidance

  • Verify that the old_string and new_string parameters are being passed correctly when calling the patch tool in replace mode.
  • Check the tool-calling mechanism to ensure it is properly handling the required parameters for the patch tool.
  • Test the patch tool with the patch mode and patch parameter to confirm the issue is not specific to the replace mode.
  • Review the provided debug reports (https://paste.rs/gUkOC and https://paste.rs/zsFxN) for any additional error information.

Example

No code snippet is provided as the issue seems to be related to the tool-calling mechanism rather than a specific code implementation.

Notes

The issue appears to be related to the Hermes Agent CLI and the patch tool, but without more information about the Python version, Hermes version, or the tool-calling mechanism, it is difficult to provide a more specific solution.

Recommendation

Apply workaround: Modify the tool-calling mechanism to ensure that the required parameters are being passed correctly to the patch tool. This may involve updating the mechanism to handle the old_string and new_string parameters for replace mode and the patch parameter for patch mode.

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 [Bug]: `patch` tool conditionally required parameters are systematically omitted [1 pull requests, 1 comments, 2 participants]