Skip to content

Commit 58b0427

Browse files
committed
fix(cli): improve /history display with consistent numbering
Fixes NousResearch#633 Problem: - Sequential numbering gaps (e.g., NousResearch#1, NousResearch#2, NousResearch#5, NousResearch#8) confuse users - 200 char truncation too aggressive - Tool messages completely hidden with no indication Fix: 1. Use separate counter for displayed messages only 2. Skip tool messages but show count at end 3. Skip system messages 4. Increase truncation to 300 chars 5. Display 'N tool messages hidden' summary Impact: - Consistent numbering: NousResearch#1, NousResearch#2, NousResearch#3, NousResearch#4 - Users know when tool calls occurred - More context visible per message
1 parent 19b6f81 commit 58b0427

1 file changed

Lines changed: 25 additions & 6 deletions

File tree

cli.py

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,17 +1612,36 @@ def show_history(self):
16121612
print("|" + " " * 12 + "(^_^) Conversation History" + " " * 11 + "|")
16131613
print("+" + "-" * 50 + "+")
16141614

1615-
for i, msg in enumerate(self.conversation_history, 1):
1615+
# Use separate counter for displayed messages (not enumerate over all)
1616+
display_num = 0
1617+
tool_count = 0
1618+
1619+
for msg in self.conversation_history:
16161620
role = msg.get("role", "unknown")
16171621
content = msg.get("content") or ""
16181622

1623+
# Skip tool messages but count them
1624+
if role == "tool":
1625+
tool_count += 1
1626+
continue
1627+
1628+
# Skip system messages
1629+
if role == "system":
1630+
continue
1631+
1632+
display_num += 1
1633+
16191634
if role == "user":
1620-
print(f"\n [You #{i}]")
1621-
print(f" {content[:200]}{'...' if len(content) > 200 else ''}")
1635+
print(f"\n [You #{display_num}]")
1636+
print(f" {content[:300]}{'...' if len(content) > 300 else ''}")
16221637
elif role == "assistant":
1623-
print(f"\n [Hermes #{i}]")
1624-
preview = content[:200] if content else "(tool calls)"
1625-
print(f" {preview}{'...' if len(str(content)) > 200 else ''}")
1638+
print(f"\n [Hermes #{display_num}]")
1639+
preview = content[:300] if content else "(tool calls)"
1640+
print(f" {preview}{'...' if len(str(content)) > 300 else ''}")
1641+
1642+
# Show summary of hidden tool messages
1643+
if tool_count > 0:
1644+
print(f"\n [dim]{tool_count} tool message(s) hidden[/]")
16261645

16271646
print()
16281647

0 commit comments

Comments
 (0)