mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-28 18:19:28 +00:00
fix(cli): report unknown line deltas for content-free diffs instead of +0 -0
Found by E2E-rendering the collector against realistic tool payloads.
This commit is contained in:
parent
ce997f9e62
commit
9ca33680ea
2 changed files with 32 additions and 1 deletions
|
|
@ -151,7 +151,13 @@ def _extract_line_deltas(tool_name: str, result: Any) -> tuple[int, int] | None:
|
|||
diff = payload.get("diff")
|
||||
if not isinstance(diff, str) or not diff.strip():
|
||||
return None
|
||||
return _count_diff_lines(diff)
|
||||
added, removed = _count_diff_lines(diff)
|
||||
# A diff that carries no +/- content lines (e.g. a bare hunk header) tells
|
||||
# us nothing — report it as unknown rather than rendering a misleading
|
||||
# "+0 -0" next to a real edit.
|
||||
if added == 0 and removed == 0:
|
||||
return None
|
||||
return added, removed
|
||||
|
||||
|
||||
class TurnSummaryCollector:
|
||||
|
|
|
|||
|
|
@ -344,3 +344,28 @@ def test_turn_summary_config_defaults_present():
|
|||
display = DEFAULT_CONFIG["display"]
|
||||
assert display["turn_summary"] is True
|
||||
assert display["spinner_token_flow"] is True
|
||||
|
||||
|
||||
def test_content_free_diff_reports_unknown_not_zero_zero():
|
||||
"""A diff with no +/- content lines (bare hunk header) must render as an
|
||||
edit with UNKNOWN deltas, never a misleading '+0 -0'.
|
||||
|
||||
Found by E2E-rendering the collector against realistic tool payloads: the
|
||||
unit suite only fed diffs that had real content lines.
|
||||
"""
|
||||
from agent.turn_summary import TurnSummaryCollector
|
||||
|
||||
c = TurnSummaryCollector()
|
||||
c.begin()
|
||||
c.record_tool("patch", result={"success": True, "diff": "@@ -1,3 +1,15 @@"})
|
||||
line = c.render(3.0)
|
||||
assert "edited 1 file" in line
|
||||
assert "+0 -0" not in line
|
||||
|
||||
real = TurnSummaryCollector()
|
||||
real.begin()
|
||||
real.record_tool(
|
||||
"patch",
|
||||
result={"success": True, "diff": "--- a/x\n+++ b/x\n@@ -1 +1,2 @@\n-old\n+new\n+extra\n"},
|
||||
)
|
||||
assert "+2 -1" in real.render(1.0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue