|
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 |
|
@@ -1978,3 +1979,44 @@ def test_summary_extraction(): |
1978 | 1979 | ) |
1979 | 1980 | ) |
1980 | 1981 | assert _extract_summary(input) == "Second message" |
| 1982 | + |
| 1983 | + |
| 1984 | +@workflow.defn |
| 1985 | +class SessionWorkflow: |
| 1986 | + @workflow.run |
| 1987 | + async def run(self) -> None: |
| 1988 | + agent: Agent = Agent( |
| 1989 | + name="Assistant", |
| 1990 | + instructions="You are a helpful assistant.", |
| 1991 | + ) |
| 1992 | + await Runner.run( |
| 1993 | + agent, |
| 1994 | + "My phone number is 650-123-4567. Where do you think I live?", |
| 1995 | + session=SQLiteSession(session_id="id"), |
| 1996 | + ) |
| 1997 | + |
| 1998 | + |
| 1999 | +async def test_session(client: Client): |
| 2000 | + new_config = client.config() |
| 2001 | + new_config["plugins"] = [ |
| 2002 | + openai_agents.OpenAIAgentsPlugin( |
| 2003 | + model_provider=TestModelProvider(TestHelloModel()), |
| 2004 | + ) |
| 2005 | + ] |
| 2006 | + client = Client(**new_config) |
| 2007 | + |
| 2008 | + async with new_worker( |
| 2009 | + client, |
| 2010 | + SessionWorkflow, |
| 2011 | + ) as worker: |
| 2012 | + workflow_handle = await client.start_workflow( |
| 2013 | + SessionWorkflow.run, |
| 2014 | + id=f"session-{uuid.uuid4()}", |
| 2015 | + task_queue=worker.task_queue, |
| 2016 | + execution_timeout=timedelta(seconds=1.0), |
| 2017 | + retry_policy=RetryPolicy(maximum_attempts=1), |
| 2018 | + ) |
| 2019 | + await assert_task_fail_eventually( |
| 2020 | + workflow_handle, |
| 2021 | + message_contains="Temporal workflows don't support SQLite sessions", |
| 2022 | + ) |
0 commit comments