hermes - ✅(Solved) Fix fix(cli): nested paste references not expanded (chained pastes lose content) [2 pull requests, 1 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#23430Fetched 2026-05-11 03:29:31
View on GitHub
Comments
0
Participants
1
Timeline
5
Reactions
0
Participants
Timeline (top)
labeled ×3cross-referenced ×2

Root Cause

_expand_paste_references() in cli.py uses re.sub() with a callback, which only does one pass. When the expanded paste file's content contains another paste reference, re.sub() does not re-scan the replacement text.

Fix Action

Fixed

PR fix notes

PR #23431: fix(cli): recursively expand nested paste references

Description (problem / solution / changelog)

Summary

_expand_paste_references() in cli.py uses re.sub() which only does one pass. When a paste file's content contains a reference to another paste file (chained pastes from multiple sequential pastes), nested references are left as literal [Pasted text #N] placeholders — silently dropping content from the agent's input.

Fix: Loop expansion until no references remain, with a circular reference guard (max 10 iterations + seen set).

How to Test

  1. Paste 3+ blocks of 5+ lines each in sequence (chain pastes)
  2. Submit the message
  3. Verify all pasted content appears in the agent's input

Unit tests cover:

  • Single-level expansion (existing behavior)
  • 3-level nested expansion
  • Circular reference guard

Platform Tested

  • Windows 11 with git-bash
  • Python 3.11.14
  • Hermes main (a28243430)

Related

Closes #23430

Changed files

  • cli.py (modified, +24/-2)
  • tests/cli/test_cli_external_editor.py (modified, +62/-1)

PR #23520: fix(cli): recursively expand nested paste references

Description (problem / solution / changelog)

What does this PR do?

Fixes chained paste expansion in the interactive CLI.

Today _expand_paste_references() only runs a single re.sub() pass, so if a pasted file contains another [Pasted text #N: ... → file] placeholder, only the top-level reference is expanded and nested placeholders are left behind in the final message.

This patch makes paste expansion recursive so chained paste files are fully expanded before the message is sent to the agent. It also adds a bounded pass limit so self-referential or cyclic placeholders do not loop forever.

Related Issue

Fixes #23430.

Type of Change

  • Bug fix
  • Tests

Changes Made

  • Update HermesCLI._expand_paste_references() to repeatedly expand paste placeholders until the text stabilizes or no placeholders remain
  • Add a recursion/pass limit to avoid infinite expansion on self-referential placeholders
  • Add regression tests for:
    • nested/chained paste expansion
    • self-referential placeholders stopping safely
    • existing single-level expansion behavior remaining intact

How to Test

pytest -q tests/cli/test_cli_external_editor.py
pytest -q tests/cli/test_cli_external_editor.py -k paste

Local result:

  • 9 passed in 24.62s
  • 4 passed in 37.37s

Checklist

  • I have tested these changes locally
  • I have added or updated tests where needed
  • This PR is scoped to a single bugfix

Screenshots / Logs

N/A

Changed files

  • cli.py (modified, +10/-1)
  • tests/cli/test_cli_external_editor.py (modified, +36/-0)
RAW_BUFFERClick to expand / collapse

Bug Description

When pasting multiple blocks of text in sequence, each paste generates a [Pasted text #N: X lines → file] placeholder. If a paste file's content itself contains a reference to a previous paste file (chained pastes), only one level of expansion occurs — nested references are left as literal placeholders in the agent's input.

Steps to Reproduce

  1. Paste block A with 5+ lines → creates paste_1.txt, buffer shows [Pasted text #1]
  2. Paste block B with 5+ lines → creates paste_2.txt containing [Pasted text #1] + new text, buffer shows [Pasted text #2]
  3. Repeat for block C → paste_3.txt contains [Pasted text #2] + new text
  4. Submit the message

Expected: All nested paste content expands into the final message Actual: Only the top-level paste expands; nested references remain as [Pasted text #N] placeholders

Root Cause

_expand_paste_references() in cli.py uses re.sub() with a callback, which only does one pass. When the expanded paste file's content contains another paste reference, re.sub() does not re-scan the replacement text.

Environment

  • Windows 11, git-bash
  • Latest main (a28243430)
  • Python 3.11

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 fix(cli): nested paste references not expanded (chained pastes lose content) [2 pull requests, 1 participants]