hermes - ✅(Solved) Fix Copilot ACP fs/read_text_file ignores line=1 pagination requests [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#13451Fetched 2026-04-22 08:06:29
View on GitHub
Comments
0
Participants
1
Timeline
6
Reactions
0
Participants
Timeline (top)
labeled ×3cross-referenced ×2referenced ×1

CopilotACPClient._handle_server_message() only applies line/limit slicing for fs/read_text_file when line > 1. Requests for the first page (line=1, limit=N) return the entire file instead of the requested slice.

Root Cause

CopilotACPClient._handle_server_message() only applies line/limit slicing for fs/read_text_file when line > 1. Requests for the first page (line=1, limit=N) return the entire file instead of the requested slice.

Fix Action

Fixed

PR fix notes

PR #13518: fix(copilot-acp): honor line=1 pagination in read_text_file (#13451)

Description (problem / solution / changelog)

Summary

  • apply fs/read_text_file pagination when line is 1 as well as later pages
  • preserve the existing limit-based slicing behavior
  • add a regression test covering line=1, limit=1

Verification

  • py -3 -m pytest -o addopts= testsgent est_copilot_acp_client.py -q
  • py -3 -m py_compile agent\copilot_acp_client.py testsgent est_copilot_acp_client.py
  • independent self-review completed before PR creation

Fixes #13451

Changed files

  • agent/copilot_acp_client.py (modified, +1/-1)
  • tests/agent/test_copilot_acp_client.py (modified, +19/-0)

PR #13817: fix(copilot_acp): fix fs/read_text_file pagination for line=1

Description (problem / solution / changelog)

Summary

In agent/copilot_acp_client.py, the pagination condition for fs/read_text_file was:

if isinstance(line, int) and line > 1:

This meant line=1, limit=N (first page) requests were ignored and the entire file was returned. Changed to line >= 1 so page-1 requests are also bounded by limit.

Changes

  • agent/copilot_acp_client.py:563: line > 1line >= 1

Testing

# line=1, limit=1 should return only the first line
client._handle_server_message(
    {'jsonrpc':'2.0','id':1,'method':'fs/read_text_file','params':{'path':str(p),'line':1,'limit':1}},
    ...
)
# Before: 'one\ntwo\nthree\n'  (full file — BUG)
# After:  'one\n'       (first line only — FIXED)

Closes #13451

Changed files

  • agent/copilot_acp_client.py (modified, +1/-1)
  • agent/prompt_builder.py (modified, +7/-1)
  • hermes_cli/model_normalize.py (modified, +17/-0)
  • hermes_cli/tools_config.py (modified, +9/-1)
  • run_agent.py (modified, +48/-1)
  • tests/agent/test_prompt_builder.py (modified, +18/-0)
  • ui-tui/src/components/appChrome.tsx (modified, +4/-1)

Code Example

line = params.get("line")
limit = params.get("limit")

---

if isinstance(line, int) and line > 1:

---

from pathlib import Path
import tempfile, json
from agent.copilot_acp_client import CopilotACPClient

class DummyStdin:
    def __init__(self): self.buf=[]
    def write(self, s): self.buf.append(s); return len(s)
    def flush(self): pass
class DummyProc:
    def __init__(self): self.stdin = DummyStdin()

with tempfile.TemporaryDirectory() as td:
    p = Path(td) / 'a.txt'
    p.write_text('one\ntwo\nthree\n')
    client = CopilotACPClient(acp_command='/bin/true', acp_cwd=td)
    proc = DummyProc()
    client._handle_server_message(
        {'jsonrpc':'2.0','id':1,'method':'fs/read_text_file','params':{'path':str(p),'line':1,'limit':1}},
        process=proc,
        cwd=td,
        text_parts=None,
        reasoning_parts=None,
    )
    result = json.loads(''.join(proc.stdin.buf))
    print(repr(result['result']['content']))

---

'one\ntwo\nthree\n'

---

'one\n'
RAW_BUFFERClick to expand / collapse

Summary

CopilotACPClient._handle_server_message() only applies line/limit slicing for fs/read_text_file when line > 1. Requests for the first page (line=1, limit=N) return the entire file instead of the requested slice.

Affected files / lines

  • agent/copilot_acp_client.py:529-539

Why this is a bug

The handler reads pagination parameters:

line = params.get("line")
limit = params.get("limit")

But it only slices when:

if isinstance(line, int) and line > 1:

So line=1 is treated as “no pagination”.

Minimal reproduction

from pathlib import Path
import tempfile, json
from agent.copilot_acp_client import CopilotACPClient

class DummyStdin:
    def __init__(self): self.buf=[]
    def write(self, s): self.buf.append(s); return len(s)
    def flush(self): pass
class DummyProc:
    def __init__(self): self.stdin = DummyStdin()

with tempfile.TemporaryDirectory() as td:
    p = Path(td) / 'a.txt'
    p.write_text('one\ntwo\nthree\n')
    client = CopilotACPClient(acp_command='/bin/true', acp_cwd=td)
    proc = DummyProc()
    client._handle_server_message(
        {'jsonrpc':'2.0','id':1,'method':'fs/read_text_file','params':{'path':str(p),'line':1,'limit':1}},
        process=proc,
        cwd=td,
        text_parts=None,
        reasoning_parts=None,
    )
    result = json.loads(''.join(proc.stdin.buf))
    print(repr(result['result']['content']))

Observed locally:

'one\ntwo\nthree\n'

Expected:

'one\n'

Expected behavior

line=1, limit=N should return the first N lines, just like line>1 requests return a bounded slice.

Actual behavior

First-page pagination is ignored and the entire file is sent.

Suggested investigation

Treat line >= 1 as a paginated request and cover line=1 in tests.

extent analysis

TL;DR

The issue can be fixed by modifying the condition in CopilotACPClient._handle_server_message() to apply pagination for line >= 1.

Guidance

  • Modify the condition if isinstance(line, int) and line > 1: to if isinstance(line, int) and line >= 1: to apply pagination for the first page.
  • Update the test cases to cover the scenario where line = 1 to ensure the fix works as expected.
  • Verify the fix by running the minimal reproduction code provided in the issue and checking if the output matches the expected behavior.
  • Review the code to ensure that the pagination logic is correct and consistent for all values of line and limit.

Example

if isinstance(line, int) and line >= 1:
    # apply pagination logic here

Notes

The issue seems to be a simple logical error in the condition. However, it's essential to review the surrounding code to ensure that the fix doesn't introduce any unintended consequences.

Recommendation

Apply the workaround by modifying the condition to if isinstance(line, int) and line >= 1:. This fix is straightforward and directly addresses the issue, making it a safe and effective solution.

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…

FAQ

Expected behavior

line=1, limit=N should return the first N lines, just like line>1 requests return a bounded slice.

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 Copilot ACP fs/read_text_file ignores line=1 pagination requests [2 pull requests, 1 participants]