MCPcopy Create free account
hub / github.com/openai/openai-agents-python / test_session_limit_zero

Function test_session_limit_zero

tests/memory/test_session_limit.py:67–99  ·  view source on GitHub ↗

Test that session_limit=0 provides no history, only new message.

(runner_method)

Source from the content-addressed store, hash-verified

65@pytest.mark.parametrize("runner_method", ["run", "run_sync", "run_streamed"])
66@pytest.mark.asyncio
67async 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"])

Callers

nothing calls this directly

Calls 10

set_next_outputMethod · 0.95
closeMethod · 0.95
SQLiteSessionClass · 0.90
FakeModelClass · 0.90
AgentClass · 0.90
get_text_messageFunction · 0.90
run_agent_asyncFunction · 0.90
RunConfigClass · 0.90
SessionSettingsClass · 0.90
getMethod · 0.45

Tested by

no test coverage detected