77import pytest
88
99from agents import Agent , RunConfig , Runner , SQLiteSession , TResponseInputItem
10- from agents .exceptions import UserError
1110
1211from .fake_model import FakeModel
1312from .test_responses import get_text_message
@@ -371,10 +370,8 @@ async def test_sqlite_session_get_items_with_limit():
371370
372371@pytest .mark .parametrize ("runner_method" , ["run" , "run_sync" , "run_streamed" ])
373372@pytest .mark .asyncio
374- async def test_session_memory_rejects_both_session_and_list_input (runner_method ):
375- """Test that passing both a session and list input raises a UserError across all runner
376- methods.
377- """
373+ async def test_session_memory_appends_list_input_by_default (runner_method ):
374+ """Test that list inputs are appended to session history when no callback is provided."""
378375 with tempfile .TemporaryDirectory () as temp_dir :
379376 db_path = Path (temp_dir ) / "test_validation.db"
380377 session_id = "test_validation_parametrized"
@@ -383,19 +380,18 @@ async def test_session_memory_rejects_both_session_and_list_input(runner_method)
383380 model = FakeModel ()
384381 agent = Agent (name = "test" , model = model )
385382
386- # Test that providing both a session and a list input raises a UserError
387- model .set_next_output ([get_text_message ("This shouldn't run" )])
388-
389- list_input = [
390- {"role" : "user" , "content" : "Test message" },
383+ initial_history : list [TResponseInputItem ] = [
384+ {"role" : "user" , "content" : "Earlier message" },
385+ {"role" : "assistant" , "content" : "Saved reply" },
391386 ]
387+ await session .add_items (initial_history )
388+
389+ list_input = [{"role" : "user" , "content" : "Test message" }]
392390
393- with pytest . raises ( UserError ) as exc_info :
394- await run_agent_async (runner_method , agent , list_input , session = session )
391+ model . set_next_output ([ get_text_message ( "This should run" )])
392+ await run_agent_async (runner_method , agent , list_input , session = session )
395393
396- # Verify the error message explains the issue
397- assert "list inputs require a `RunConfig.session_input_callback" in str (exc_info .value )
398- assert "to manage the history manually" in str (exc_info .value )
394+ assert model .last_turn_args ["input" ] == initial_history + list_input
399395
400396 session .close ()
401397
0 commit comments