Skip to content

Commit 278e6ba

Browse files
committed
test(sessions): add 10 replay cases with JSONL fixture load/save
10 replay scenarios defined in cases.py with round-trip JSONL fixture support. Mirrors Go trpc-agent-go session/replaytest. Signed-off-by: coder-mtj <coder-mtj@users.noreply.github.com>
1 parent 0496bd3 commit 278e6ba

12 files changed

Lines changed: 629 additions & 0 deletions

tests/sessions/replay_consistency/cases.py

Lines changed: 416 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{"type": "case_header", "name": "single_turn_text", "app_name": "test-app", "user_id": "user-1", "session_id": "session-001", "initial_state": {"app:welcome": "true"}}
2+
{"type": "event", "author": "user", "invocation_id": "", "role": "user", "text": "Hello, who are you?", "tool_calls": [], "tool_response": null, "state_delta": null, "filter_key": "", "branch": "", "tag": ""}
3+
{"type": "event", "author": "assistant", "invocation_id": "", "role": "assistant", "text": "I am an AI assistant.", "tool_calls": [], "tool_response": null, "state_delta": null, "filter_key": "", "branch": "", "tag": ""}
4+
{"type": "memory_write", "memory": "User greeted the assistant", "topics": ["conversation"]}
5+
{"type": "memory_query", "query": "greeting", "limit": 5}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{"type": "case_header", "name": "multi_turn_state_updates", "app_name": "test-app", "user_id": "user-1", "session_id": "session-002", "initial_state": {}}
2+
{"type": "event", "author": "user", "invocation_id": "", "role": "user", "text": "What is my name?", "tool_calls": [], "tool_response": null, "state_delta": null, "filter_key": "", "branch": "", "tag": ""}
3+
{"type": "event", "author": "assistant", "invocation_id": "", "role": "assistant", "text": "Your name is Bob.", "tool_calls": [], "tool_response": null, "state_delta": null, "filter_key": "", "branch": "", "tag": ""}
4+
{"type": "event", "author": "user", "invocation_id": "", "role": "user", "text": "Remember that I like coffee.", "tool_calls": [], "tool_response": null, "state_delta": null, "filter_key": "", "branch": "", "tag": ""}
5+
{"type": "event", "author": "assistant", "invocation_id": "", "role": "assistant", "text": "I will remember that you like coffee.", "tool_calls": [], "tool_response": null, "state_delta": null, "filter_key": "", "branch": "", "tag": ""}
6+
{"type": "event", "author": "user", "invocation_id": "", "role": "user", "text": "What did I ask you to remember?", "tool_calls": [], "tool_response": null, "state_delta": null, "filter_key": "", "branch": "", "tag": ""}
7+
{"type": "event", "author": "assistant", "invocation_id": "", "role": "assistant", "text": "You asked me to remember that you like coffee.", "tool_calls": [], "tool_response": null, "state_delta": null, "filter_key": "", "branch": "", "tag": ""}
8+
{"type": "memory_write", "memory": "User name is Bob", "topics": ["identity"]}
9+
{"type": "memory_write", "memory": "User likes coffee", "topics": ["preferences"]}
10+
{"type": "memory_query", "query": "Bob", "limit": 5}
11+
{"type": "memory_query", "query": "coffee", "limit": 5}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{"type": "case_header", "name": "tool_call_roundtrip", "app_name": "test-app", "user_id": "user-1", "session_id": "session-003", "initial_state": {}}
2+
{"type": "event", "author": "user", "invocation_id": "", "role": "user", "text": "What is the weather?", "tool_calls": [], "tool_response": null, "state_delta": null, "filter_key": "", "branch": "", "tag": ""}
3+
{"type": "event", "author": "assistant", "invocation_id": "", "role": "assistant", "text": "", "tool_calls": [{"id": "call-1", "name": "get_weather", "arguments": "{\"city\":\"Beijing\"}"}], "tool_response": null, "state_delta": null, "filter_key": "", "branch": "", "tag": ""}
4+
{"type": "event", "author": "tool", "invocation_id": "", "role": "tool", "text": "", "tool_calls": [], "tool_response": {"id": "call-1", "name": "get_weather", "content": "Sunny, 25°C"}, "state_delta": null, "filter_key": "", "branch": "", "tag": ""}
5+
{"type": "event", "author": "assistant", "invocation_id": "", "role": "assistant", "text": "The weather in Beijing is sunny, 25°C.", "tool_calls": [], "tool_response": null, "state_delta": null, "filter_key": "", "branch": "", "tag": ""}
6+
{"type": "memory_write", "memory": "User checked weather for Beijing", "topics": ["action"]}
7+
{"type": "memory_query", "query": "weather", "limit": 5}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{"type": "case_header", "name": "scoped_state_overwrite", "app_name": "test-app", "user_id": "user-1", "session_id": "session-004", "initial_state": {"user:score": "0", "app:round": "1"}}
2+
{"type": "event", "author": "assistant", "invocation_id": "", "role": "assistant", "text": "Starting round 1.", "tool_calls": [], "tool_response": null, "state_delta": {"user:score": "10"}, "filter_key": "", "branch": "", "tag": ""}
3+
{"type": "event", "author": "user", "invocation_id": "", "role": "user", "text": "I found the answer.", "tool_calls": [], "tool_response": null, "state_delta": null, "filter_key": "", "branch": "", "tag": ""}
4+
{"type": "event", "author": "assistant", "invocation_id": "", "role": "assistant", "text": "Score updated.", "tool_calls": [], "tool_response": null, "state_delta": {"user:score": "25", "app:round": "2"}, "filter_key": "", "branch": "", "tag": ""}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{"type": "case_header", "name": "memory_multi_author_search", "app_name": "test-app", "user_id": "user-2", "session_id": "session-005", "initial_state": {}}
2+
{"type": "event", "author": "user", "invocation_id": "", "role": "user", "text": "I enjoy hiking on weekends.", "tool_calls": [], "tool_response": null, "state_delta": null, "filter_key": "", "branch": "", "tag": ""}
3+
{"type": "event", "author": "assistant", "invocation_id": "", "role": "assistant", "text": "That's great! Hiking is wonderful.", "tool_calls": [], "tool_response": null, "state_delta": null, "filter_key": "", "branch": "", "tag": ""}
4+
{"type": "event", "author": "user", "invocation_id": "", "role": "user", "text": "Also I prefer tea over coffee.", "tool_calls": [], "tool_response": null, "state_delta": null, "filter_key": "", "branch": "", "tag": ""}
5+
{"type": "event", "author": "assistant", "invocation_id": "", "role": "assistant", "text": "Noted - you prefer tea.", "tool_calls": [], "tool_response": null, "state_delta": null, "filter_key": "", "branch": "", "tag": ""}
6+
{"type": "memory_write", "memory": "User enjoys hiking", "topics": ["hobbies"]}
7+
{"type": "memory_write", "memory": "User prefers tea", "topics": ["preferences"]}
8+
{"type": "memory_write", "memory": "User is health conscious", "topics": ["lifestyle"]}
9+
{"type": "memory_query", "query": "hiking", "limit": 3}
10+
{"type": "memory_query", "query": "tea", "limit": 3}
11+
{"type": "memory_query", "query": "preferences", "limit": 5}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{"type": "case_header", "name": "summary_generation", "app_name": "test-app", "user_id": "user-1", "session_id": "session-006", "initial_state": {}}
2+
{"type": "event", "author": "user", "invocation_id": "", "role": "user", "text": "Help me plan a trip to Shanghai.", "tool_calls": [], "tool_response": null, "state_delta": null, "filter_key": "", "branch": "", "tag": ""}
3+
{"type": "event", "author": "assistant", "invocation_id": "", "role": "assistant", "text": "Sure! When would you like to go?", "tool_calls": [], "tool_response": null, "state_delta": null, "filter_key": "", "branch": "", "tag": ""}
4+
{"type": "event", "author": "user", "invocation_id": "", "role": "user", "text": "Next month, for 3 days.", "tool_calls": [], "tool_response": null, "state_delta": null, "filter_key": "", "branch": "", "tag": ""}
5+
{"type": "event", "author": "assistant", "invocation_id": "", "role": "assistant", "text": "I recommend visiting the Bund and Yu Garden.", "tool_calls": [], "tool_response": null, "state_delta": null, "filter_key": "", "branch": "", "tag": ""}
6+
{"type": "event", "author": "user", "invocation_id": "", "role": "user", "text": "Great, also I need hotel recommendations.", "tool_calls": [], "tool_response": null, "state_delta": null, "filter_key": "", "branch": "", "tag": ""}
7+
{"type": "event", "author": "assistant", "invocation_id": "", "role": "assistant", "text": "I can search for hotels near the Bund.", "tool_calls": [], "tool_response": null, "state_delta": null, "filter_key": "", "branch": "", "tag": ""}
8+
{"type": "summary_step", "after_event_index": 6, "filter_key": "", "force": true}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{"type": "case_header", "name": "summary_with_truncation", "app_name": "test-app", "user_id": "user-1", "session_id": "session-007", "initial_state": {}}
2+
{"type": "event", "author": "user", "invocation_id": "", "role": "user", "text": "Message 1: Greetings.", "tool_calls": [], "tool_response": null, "state_delta": null, "filter_key": "", "branch": "", "tag": ""}
3+
{"type": "event", "author": "assistant", "invocation_id": "", "role": "assistant", "text": "Response 1: Hello!", "tool_calls": [], "tool_response": null, "state_delta": null, "filter_key": "", "branch": "", "tag": ""}
4+
{"type": "event", "author": "user", "invocation_id": "", "role": "user", "text": "Message 2: Question about weather.", "tool_calls": [], "tool_response": null, "state_delta": null, "filter_key": "", "branch": "", "tag": ""}
5+
{"type": "event", "author": "assistant", "invocation_id": "", "role": "assistant", "text": "Response 2: It's sunny.", "tool_calls": [], "tool_response": null, "state_delta": null, "filter_key": "", "branch": "", "tag": ""}
6+
{"type": "event", "author": "user", "invocation_id": "", "role": "user", "text": "Message 3: Thank you.", "tool_calls": [], "tool_response": null, "state_delta": null, "filter_key": "", "branch": "", "tag": ""}
7+
{"type": "event", "author": "assistant", "invocation_id": "", "role": "assistant", "text": "Response 3: You're welcome.", "tool_calls": [], "tool_response": null, "state_delta": null, "filter_key": "", "branch": "", "tag": ""}
8+
{"type": "event", "author": "user", "invocation_id": "", "role": "user", "text": "Message 4: Can you summarize?", "tool_calls": [], "tool_response": null, "state_delta": null, "filter_key": "", "branch": "", "tag": ""}
9+
{"type": "event", "author": "assistant", "invocation_id": "", "role": "assistant", "text": "Response 4: Here is the summary.", "tool_calls": [], "tool_response": null, "state_delta": null, "filter_key": "", "branch": "", "tag": ""}
10+
{"type": "summary_step", "after_event_index": 6, "filter_key": "weather", "force": true}
11+
{"type": "summary_step", "after_event_index": 8, "filter_key": "", "force": true}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{"type": "case_header", "name": "track_events", "app_name": "test-app", "user_id": "user-1", "session_id": "session-008", "initial_state": {}}
2+
{"type": "event", "author": "user", "invocation_id": "", "role": "user", "text": "Run a calculation.", "tool_calls": [], "tool_response": null, "state_delta": null, "filter_key": "", "branch": "", "tag": ""}
3+
{"type": "event", "author": "assistant", "invocation_id": "", "role": "assistant", "text": "Running calculation...", "tool_calls": [], "tool_response": null, "state_delta": null, "filter_key": "", "branch": "", "tag": ""}
4+
{"type": "track_event", "track": "tool_execution", "payload": "{\"tool\":\"calculator\",\"duration_ms\":150,\"status\":\"success\"}"}
5+
{"type": "track_event", "track": "tool_execution", "payload": "{\"tool\":\"calculator\",\"duration_ms\":200,\"status\":\"success\"}"}
6+
{"type": "track_event", "track": "subtask_status", "payload": "{\"subtask\":\"verification\",\"status\":\"passed\"}"}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{"type": "case_header", "name": "concurrent_out_of_order_writes", "app_name": "test-app", "user_id": "user-3", "session_id": "session-009", "initial_state": {}}
2+
{"type": "event", "author": "user", "invocation_id": "", "role": "user", "text": "Start parallel task A.", "tool_calls": [], "tool_response": null, "state_delta": null, "filter_key": "", "branch": "", "tag": ""}
3+
{"type": "event", "author": "user", "invocation_id": "", "role": "user", "text": "Start parallel task B.", "tool_calls": [], "tool_response": null, "state_delta": null, "filter_key": "", "branch": "", "tag": ""}
4+
{"type": "event", "author": "assistant", "invocation_id": "", "role": "assistant", "text": "Task A result.", "tool_calls": [], "tool_response": null, "state_delta": null, "filter_key": "", "branch": "", "tag": ""}
5+
{"type": "event", "author": "assistant", "invocation_id": "", "role": "assistant", "text": "Task B result.", "tool_calls": [], "tool_response": null, "state_delta": null, "filter_key": "", "branch": "", "tag": ""}
6+
{"type": "event", "author": "user", "invocation_id": "", "role": "user", "text": "Merge results.", "tool_calls": [], "tool_response": null, "state_delta": null, "filter_key": "", "branch": "", "tag": ""}
7+
{"type": "memory_write", "memory": "Parallel task A completed", "topics": ["task"]}
8+
{"type": "memory_write", "memory": "Parallel task B completed", "topics": ["task"]}

0 commit comments

Comments
 (0)