|
26 | 26 | OutputGuardrailTripwireTriggered, |
27 | 27 | RunContextWrapper, |
28 | 28 | Runner, |
| 29 | + SQLiteSession, |
29 | 30 | Tool, |
30 | 31 | TResponseInputItem, |
31 | 32 | Usage, |
|
74 | 75 | from tests.contrib.openai_agents.research_agents.research_manager import ( |
75 | 76 | ResearchManager, |
76 | 77 | ) |
77 | | -from tests.helpers import new_worker |
| 78 | +from tests.helpers import assert_task_fail_eventually, new_worker |
78 | 79 | from tests.helpers.nexus import create_nexus_endpoint, make_nexus_endpoint_name |
79 | 80 |
|
80 | 81 |
|
@@ -2023,3 +2024,44 @@ def test_summary_extraction(): |
2023 | 2024 | ) |
2024 | 2025 | ) |
2025 | 2026 | assert _extract_summary(input) == "Second message" |
| 2027 | + |
| 2028 | + |
| 2029 | +@workflow.defn |
| 2030 | +class SessionWorkflow: |
| 2031 | + @workflow.run |
| 2032 | + async def run(self) -> None: |
| 2033 | + agent: Agent = Agent( |
| 2034 | + name="Assistant", |
| 2035 | + instructions="You are a helpful assistant.", |
| 2036 | + ) |
| 2037 | + await Runner.run( |
| 2038 | + agent, |
| 2039 | + "My phone number is 650-123-4567. Where do you think I live?", |
| 2040 | + session=SQLiteSession(session_id="id"), |
| 2041 | + ) |
| 2042 | + |
| 2043 | + |
| 2044 | +async def test_session(client: Client): |
| 2045 | + new_config = client.config() |
| 2046 | + new_config["plugins"] = [ |
| 2047 | + openai_agents.OpenAIAgentsPlugin( |
| 2048 | + model_provider=TestModelProvider(TestHelloModel()), |
| 2049 | + ) |
| 2050 | + ] |
| 2051 | + client = Client(**new_config) |
| 2052 | + |
| 2053 | + async with new_worker( |
| 2054 | + client, |
| 2055 | + SessionWorkflow, |
| 2056 | + ) as worker: |
| 2057 | + workflow_handle = await client.start_workflow( |
| 2058 | + SessionWorkflow.run, |
| 2059 | + id=f"session-{uuid.uuid4()}", |
| 2060 | + task_queue=worker.task_queue, |
| 2061 | + execution_timeout=timedelta(seconds=1.0), |
| 2062 | + retry_policy=RetryPolicy(maximum_attempts=1), |
| 2063 | + ) |
| 2064 | + await assert_task_fail_eventually( |
| 2065 | + workflow_handle, |
| 2066 | + message_contains="Temporal workflows don't support SQLite sessions", |
| 2067 | + ) |
0 commit comments