# NousResearch/hermes-agent · read_file line counting bugs and fixes

## Open now

- 0 issues, 5 PRs open on GitHub.
- PR #3927: fix(tools): read_file() undercounts total_lines for files without trailing newline
- PR #20814: fix(file_operations): correct total_lines for files without trailing newline
- PR #22945: fix(file): count unterminated final line in read_file
- PR #42929: fix(tools): count file lines newline-agnostically in read_file
- PR #74372: feat(desktop): add microphone device selector for voice mode

Multiple bug reports and fix attempts addressing two related read_file issues: undercounting total_lines for files without a trailing newline, and displaying a phantom empty last line for files that do end with a newline. One unrelated microphone device selector feature is also present.

## TL;DR

- 13 member(s): 0 open issue(s), 3 closed issue(s), 5 open PR(s), 1 merged PR(s), 4 PR(s) closed without merging.
- A fix was merged to main in PR #107798. Verify it addresses your case.
- **Recommended:** read PR #107798 (and any competing PRs below) before filing. Confirm the merged change covers your symptom.

## Maintainer resolution verdict

- Internal-tracker verdict over this cluster's issue members: `unresolved`. This is distinct from the fix status above. Weigh it yourself.

## How this cluster was grouped

- Link evidence (`STRUCTURAL_PARTIAL`): some members are connected by structural evidence (shared changed files, or a closing/superseded reference); the rest are joined by an automated relevance judgement over their text.
- Members outside that structural core may belong to a different underlying problem.
- Pairwise link density `0.15`: the share of member pairs that carry a link, counting a structural link in full and a relevance-only link at 0.36. `1.00` means every pair is linked.

## Closed / duplicate issues

- #3907: \[Bug\]: read_file() undercounts total_lines for files without trailing newline
- #55697: read_file undercounts total_lines and can silently drop the last line of a file without a trailing newline
- #59999: \[Bug\] read_file total_lines is inaccurate — uses wc -l which counts newlines, not lines

## Prior & competing PRs

- **#107798: fix(tools): read_file counts unterminated final lines and stops rendering a phantom trailing line (salvage #106888, #49453)**. merged to main · fix tier `verified`
  - maintainer direction: category `merged`
  - files: `tests/tools/test_file_operations.py`, `tests/tools/test_file_operations_edge_cases.py`, `tests/tools/test_file_ops_single_roundtrip.py`, `tools/file_operations.py`
- **#3908: tools/file_operations: fix wc -l undercounting for files without trailing newline (#3907)**. closed without merge
  - maintainer direction: category `duplicate_of`; implication `duplicate`; refs `#3908`
- **#3927: fix(tools): read_file() undercounts total_lines for files without trailing newline**. open
  - maintainer direction: category `uncategorized`; implication `needs_llm`
  - files: `tests/tools/test_read_file_total_lines.py`, `tools/file_operations.py`
- **#20814: fix(file_operations): correct total_lines for files without trailing newline**. open
  - maintainer direction: category `duplicate_of`; implication `duplicate`; refs `#3927`, `#3908`, `#3907`
  - files: `tools/file_operations.py`
- **#22945: fix(file): count unterminated final line in read_file**. open
  - maintainer direction: category `duplicate_of`; implication `duplicate`; refs `#3927`, `#3908`, `#3907`, `#20814`
  - files: `tests/tools/test_file_tools_live.py`, `tools/file_operations.py`
- **#42929: fix(tools): count file lines newline-agnostically in read_file**. open
  - maintainer direction: category `duplicate_of`; implication `duplicate`; refs `#3907`, `#3927`, `#3908`, `#20814`, `#22945`
  - files: `tests/tools/test_file_operations.py`, `tests/tools/test_file_operations_edge_cases.py`, `tools/file_operations.py`
- **#55696: fix(tools): read_file undercounts (and can drop) a final line without a trailing newline**. closed without merge
  - maintainer direction: category `implemented_elsewhere`; implication `superseded`; refs `#107798`, `#106888`, `#49453`
- **#55757: fix(file): count unterminated final line in read_file**. closed without merge
  - maintainer direction: category `duplicate_of`; implication `duplicate`; refs `#42929`, `#55697`, `#55696`, `#22945`
- **#74372: feat(desktop): add microphone device selector for voice mode**. open
  - maintainer direction: category `uncategorized`; implication `needs_llm`; refs `#55697`, `#111234`
  - files: `apps/desktop/src/app/chat/composer/controls.tsx`, `apps/desktop/src/app/chat/composer/hooks/use-mic-device.ts`, `apps/desktop/src/app/chat/composer/hooks/use-mic-recorder.ts`, `apps/desktop/src/app/chat/composer/hooks/use-voice-conversation.ts`, `apps/desktop/src/app/chat/composer/hooks/use-voice-recorder.ts`, `apps/desktop/src/app/chat/composer/index.tsx`, `apps/desktop/src/app/chat/composer/types.ts`, `gateway/platforms/wecom.py`, `tests/gateway/test_wecom.py`
- **#106888: fix(tools): count final unterminated line in read_file total_lines**. closed without merge
  - maintainer direction: category `merged_via`; implication `superseded`; refs `6f62aff7f2bf`, `#107798`

## Fix status

- Merged to main in PR #107798 (cited above). No release data is tracked. Verify downstream.
- Fix last verified (merged) `2026-09-13`.
- Subsystem: `agent`
