Skip to content

Commit 17542f4

Browse files
Copilotpatniko
andcommitted
Add test for resuming session with system_message in Python SDK
Co-authored-by: patniko <26906478+patniko@users.noreply.github.com>
1 parent 79b253c commit 17542f4

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

python/e2e/test_session.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,33 @@ async def test_should_resume_session_with_custom_provider(self, ctx: E2ETestCont
315315

316316
assert session2.session_id == session_id
317317

318+
async def test_should_resume_session_with_system_message(self, ctx: E2ETestContext):
319+
# Create initial session with a system message
320+
system_message_suffix = "End each response with 'Greetings from the resumed session!'"
321+
session = await ctx.client.create_session(
322+
{"system_message": {"mode": "append", "content": "Initial system message."}}
323+
)
324+
session_id = session.session_id
325+
await session.send_and_wait({"prompt": "What is 1+1?"})
326+
327+
# Resume the session with a different system message
328+
session2 = await ctx.client.resume_session(
329+
session_id,
330+
{"system_message": {"mode": "append", "content": system_message_suffix}},
331+
)
332+
333+
assert session2.session_id == session_id
334+
335+
# Send a message and verify the resumed system message is being used
336+
await session2.send({"prompt": "What is your purpose?"})
337+
assistant_message = await get_final_assistant_message(session2)
338+
assert "Greetings from the resumed session!" in assistant_message.data.content
339+
340+
# Also validate the underlying traffic
341+
traffic = await ctx.get_exchanges()
342+
system_message = _get_system_message(traffic[-1])
343+
assert system_message_suffix in system_message
344+
318345
async def test_should_abort_a_session(self, ctx: E2ETestContext):
319346
import asyncio
320347

0 commit comments

Comments
 (0)