From 11c84f21a67d6ee4f8975e1323276eb2836b01c3 Mon Sep 17 00:00:00 2001 From: Xubin Ren Date: Sat, 4 Apr 2026 12:02:42 +0000 Subject: [PATCH] test(session): preserve reasoning_content in session history --- tests/agent/test_session_manager_history.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/agent/test_session_manager_history.py b/tests/agent/test_session_manager_history.py index 83036c8fa..1297a5874 100644 --- a/tests/agent/test_session_manager_history.py +++ b/tests/agent/test_session_manager_history.py @@ -173,6 +173,27 @@ def test_empty_session_history(): assert history == [] +def test_get_history_preserves_reasoning_content(): + session = Session(key="test:reasoning") + session.messages.append({"role": "user", "content": "hi"}) + session.messages.append({ + "role": "assistant", + "content": "done", + "reasoning_content": "hidden chain of thought", + }) + + history = session.get_history(max_messages=500) + + assert history == [ + {"role": "user", "content": "hi"}, + { + "role": "assistant", + "content": "done", + "reasoning_content": "hidden chain of thought", + }, + ] + + # --- Window cuts mid-group: assistant present but some tool results orphaned --- def test_window_cuts_mid_tool_group():