Skip to content

Disallow use of sqlite sessions, but pass through others #993

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions temporalio/contrib/openai_agents/_openai_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
RunConfig,
RunResult,
RunResultStreaming,
SQLiteSession,
TContext,
Tool,
TResponseInputItem,
Expand Down Expand Up @@ -61,6 +62,10 @@ async def run(
hooks = kwargs.get("hooks")
run_config = kwargs.get("run_config")
previous_response_id = kwargs.get("previous_response_id")
session = kwargs.get("session")

if isinstance(session, SQLiteSession):
raise ValueError("Temporal workflows don't support SQLite sessions.")

if run_config is None:
run_config = RunConfig()
Expand All @@ -85,6 +90,7 @@ async def run(
hooks=hooks,
run_config=updated_run_config,
previous_response_id=previous_response_id,
session=session,
)

def run_sync(
Expand Down
44 changes: 43 additions & 1 deletion tests/contrib/openai_agents/test_openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
OutputGuardrailTripwireTriggered,
RunContextWrapper,
Runner,
SQLiteSession,
Tool,
TResponseInputItem,
Usage,
Expand Down Expand Up @@ -74,7 +75,7 @@
from tests.contrib.openai_agents.research_agents.research_manager import (
ResearchManager,
)
from tests.helpers import new_worker
from tests.helpers import assert_task_fail_eventually, new_worker
from tests.helpers.nexus import create_nexus_endpoint, make_nexus_endpoint_name


Expand Down Expand Up @@ -1978,3 +1979,44 @@ def test_summary_extraction():
)
)
assert _extract_summary(input) == "Second message"


@workflow.defn
class SessionWorkflow:
@workflow.run
async def run(self) -> None:
agent: Agent = Agent(
name="Assistant",
instructions="You are a helpful assistant.",
)
await Runner.run(
agent,
"My phone number is 650-123-4567. Where do you think I live?",
session=SQLiteSession(session_id="id"),
)


async def test_session(client: Client):
new_config = client.config()
new_config["plugins"] = [
openai_agents.OpenAIAgentsPlugin(
model_provider=TestModelProvider(TestHelloModel()),
)
]
client = Client(**new_config)

async with new_worker(
client,
SessionWorkflow,
) as worker:
workflow_handle = await client.start_workflow(
SessionWorkflow.run,
id=f"session-{uuid.uuid4()}",
task_queue=worker.task_queue,
execution_timeout=timedelta(seconds=1.0),
retry_policy=RetryPolicy(maximum_attempts=1),
)
await assert_task_fail_eventually(
workflow_handle,
message_contains="Temporal workflows don't support SQLite sessions",
)