Test that session_limit=0 provides no history, only new message.
(runner_method)
| 65 | @pytest.mark.parametrize("runner_method", ["run", "run_sync", "run_streamed"]) |
| 66 | @pytest.mark.asyncio |
| 67 | async def test_session_limit_zero(runner_method): |
| 68 | """Test that session_limit=0 provides no history, only new message.""" |
| 69 | with tempfile.TemporaryDirectory() as temp_dir: |
| 70 | db_path = Path(temp_dir) / "test_limit_zero.db" |
| 71 | session_id = "limit_zero_test" |
| 72 | session = SQLiteSession(session_id, db_path) |
| 73 | |
| 74 | model = FakeModel() |
| 75 | agent = Agent(name="test", model=model) |
| 76 | |
| 77 | # Build conversation history |
| 78 | model.set_next_output([get_text_message("Reply 1")]) |
| 79 | await run_agent_async(runner_method, agent, "Message 1", session=session) |
| 80 | |
| 81 | model.set_next_output([get_text_message("Reply 2")]) |
| 82 | await run_agent_async(runner_method, agent, "Message 2", session=session) |
| 83 | |
| 84 | # Test with limit=0 - should get NO history, just new message |
| 85 | model.set_next_output([get_text_message("Reply 3")]) |
| 86 | await run_agent_async( |
| 87 | runner_method, |
| 88 | agent, |
| 89 | "Message 3", |
| 90 | session=session, |
| 91 | run_config=RunConfig(session_settings=SessionSettings(limit=0)), |
| 92 | ) |
| 93 | |
| 94 | # Verify model received only the new message |
| 95 | last_input = model.last_turn_args["input"] |
| 96 | assert len(last_input) == 1 |
| 97 | assert last_input[0].get("content") == "Message 3" |
| 98 | |
| 99 | session.close() |
| 100 | |
| 101 | |
| 102 | @pytest.mark.parametrize("runner_method", ["run", "run_sync", "run_streamed"]) |
nothing calls this directly
no test coverage detected