Skip to content

Add workaround for case where un-picklable types are passed to Runner #997

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 2 commits into from
Jul 25, 2025
Merged
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
7 changes: 7 additions & 0 deletions temporalio/contrib/openai_agents/_openai_runner.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
import typing
from dataclasses import replace
from typing import Any, Union
Expand All @@ -13,6 +14,7 @@
TResponseInputItem,
)
from agents.run import DEFAULT_AGENT_RUNNER, DEFAULT_MAX_TURNS, AgentRunner
from pydantic_core import to_json

from temporalio import workflow
from temporalio.contrib.openai_agents._model_parameters import ModelActivityParameters
Expand Down Expand Up @@ -57,6 +59,11 @@ async def run(
"Temporal OpenAI agent does not support on demand MCP servers."
)

# workaround for https://github.com/pydantic/pydantic/issues/9541
# ValidatorIterator returned
input_json = to_json(input)
input = json.loads(input_json)

context = kwargs.get("context")
max_turns = kwargs.get("max_turns", DEFAULT_MAX_TURNS)
hooks = kwargs.get("hooks")
Expand Down
Loading