Skip to content

[bug] memory tool remove action rejects valid old_text arg with "old_text is required" error #43412

Closed

Description

@Eagle112

Environment
- Hermes Agent: 0.16.0 (HEAD 3705625)
- Memory tool: tools/memory_tool.py

Bug
Calling the memory tool with action="remove" and a non-empty old_text argument
returns the error:

> old_text is required for 'remove' action.

…even when old_text is clearly populated.

Root cause
MEMORY_SCHEMA in tools/memory_tool.py:684-707 declares:

python
"required": ["action", "target"],


old_text is not in the required list. As a result, schema-aware LLM tool-calling
layers (and possibly some clients) drop the old_text argument before invoking the
handler. The handler at line 639-642 then sees an empty string and bails:

python
elif action == "remove":
    if not old_text:
        return tool_error("old_text is required for 'remove' action.", success=False)
    result = store.remove(target, old_text)


The same affects replace (line 632-637).

Reproduction
1. Add two memory entries.
2. Call memory with action="remove", target="memory",
   old_text="<a unique short substring of entry 1>".
3. Tool returns the "old_text is required" error.

Suggested fix
Make old_text part of the top-level required list — it is unused by add
(which never reads it), and the cost of always passing it is zero:

python
"required": ["action", "target", "old_text"],


A more correct but invasive alternative is to split the schema into
add_memory / replace_memory / remove_memory tools, each with its own
parameter set and required list.

Workaround
Edit ~/.hermes/memories/MEMORY.md directly with the patch tool — entries
are §-delimited, so deletions are straightforward as long as the trailing

Activity

  1. added
    type/bugSomething isn't working
    P2Medium — degraded but workaround exists
    comp/toolsTool registry, model_tools, toolsets
    tool/memoryMemory tool and memory providers
    on Jun 10, 2026
  2. teknium1 commented on Jun 21, 2026

    @teknium1
    Collaborator

    Fixed on main via PR #49997 (commit c6bf6bd). Single-op replace/remove no longer dead-ends when old_text is dropped by a strict-schema client — it now returns the current entry inventory plus a retry instruction so the model can reissue with old_text set. Your root-cause analysis (old_text not in the schema required list → schema-aware layers strip it) was correct; we couldn't make it conditionally-required (the if/then form 400s on OpenAI's Codex backend), so the fix makes the missing-old_text case recoverable instead. Thanks for the precise report.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existscomp/toolsTool registry, model_tools, toolsetstool/memoryMemory tool and memory providerstype/bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions