[verified] fix: preserve timestamps in chat history

This commit is contained in:
2026-09-09 17:15:20 +00:00
parent 6be1601ccd
commit 1d85d7af6b
2 changed files with 31 additions and 3 deletions
+26
View File
@@ -432,6 +432,32 @@ class TestAttachments:
# Tool events / approvals / clarifications / cancellation (bridge)
# ═══════════════════════════════════════════════════════════════════════════
class TestBridge:
@pytest.mark.asyncio
async def test_history_converts_numeric_hermes_timestamps_to_iso(self, monkeypatch):
from pheby import hermes_bridge as hb
class Store:
def peek_session_id(self, _key):
return "session-1"
class DB:
def get_messages_as_conversation(self, _session_id, include_row_ids=False):
assert include_row_ids is True
return [
{"_row_id": 10, "role": "user", "content": "hello", "timestamp": 1_789_000_000.25},
{"_row_id": 11, "role": "assistant", "content": "reply", "timestamp": 1_789_000_001.5},
]
monkeypatch.setattr(hb, "_session_store", lambda: Store())
monkeypatch.setattr(hb, "_session_db", lambda: DB())
history, found = await hb.conversation_history("conv", 20)
assert found is True
assert [message["message_id"] for message in history] == ["m10", "m11"]
assert history[0]["ts"] == "2026-09-10T00:26:40.250000+00:00"
assert history[1]["ts"] == "2026-09-10T00:26:41.500000+00:00"
@pytest.mark.asyncio
async def test_tool_start_event_is_structured_not_text(self, tmp_path,
monkeypatch):