Skip to content

Conversation

@jssmith
Copy link
Contributor

@jssmith jssmith commented Aug 6, 2025

What was changed

Added an example using gpt-oss with a tool call.

Why?

Checklist

  1. Closes

  2. How was this tested:

  1. Any docs updates needed?

@jssmith jssmith requested a review from a team as a code owner August 6, 2025 20:29

from openai_agents.model_providers.workflows.gpt_oss_workflow import GptOssWorkflow

ollama_client = AsyncOpenAI(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Client needs to be created outside of CustomModelProvider as otherwise we have sandboxing issues:

future: <Task finished name='Task-47 (workflow: GptOssWorkflow, id: litellm-gpt-oss-workflow-id, run: 019881a0-034a-7a48-a1e0-9412fa0b9bbb)' coro=<AsyncClient.aclose() done, defined at /Users/jssmith/t/samples-python-2/.venv/lib/python3.12/site-packages/httpx/_client.py:1978> exception=RestrictedWorkflowAccessError('Cannot access threading.local.__mro_entries__ from inside a workflow. If this is code from a module not used in a workflow or known to only be used deterministically from a workflow, mark the import as pass through.')>
Traceback (most recent call last):
  File "/Users/jssmith/t/samples-python-2/.venv/lib/python3.12/site-packages/httpx/_client.py", line 1985, in aclose
    await self._transport.aclose()
  File "/Users/jssmith/t/samples-python-2/.venv/lib/python3.12/site-packages/httpx/_transports/default.py", line 406, in aclose
    await self._pool.aclose()
  File "/Users/jssmith/t/samples-python-2/.venv/lib/python3.12/site-packages/httpcore/_async/connection_pool.py", line 353, in aclose
    await self._close_connections(closing_connections)
  File "/Users/jssmith/t/samples-python-2/.venv/lib/python3.12/site-packages/httpcore/_async/connection_pool.py", line 343, in _close_connections
    with AsyncShieldCancellation():
         ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jssmith/t/samples-python-2/.venv/lib/python3.12/site-packages/httpcore/_synchronization.py", line 203, in __init__
    self._backend = current_async_library()
                    ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jssmith/t/samples-python-2/.venv/lib/python3.12/site-packages/httpcore/_synchronization.py", line 26, in current_async_library
    import sniffio
  File "/Users/jssmith/t/samples-python-2/.venv/lib/python3.12/site-packages/temporalio/worker/workflow_sandbox/_importer.py", line 497, in __call__
    return self.current(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jssmith/t/samples-python-2/.venv/lib/python3.12/site-packages/temporalio/worker/workflow_sandbox/_importer.py", line 248, in _import
    mod = importlib.__import__(name, globals, locals, fromlist, level)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1466, in __import__
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 999, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/Users/jssmith/t/samples-python-2/.venv/lib/python3.12/site-packages/sniffio/__init__.py", line 12, in <module>
    from ._impl import (
  File "/Users/jssmith/t/samples-python-2/.venv/lib/python3.12/site-packages/temporalio/worker/workflow_sandbox/_importer.py", line 497, in __call__
    return self.current(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jssmith/t/samples-python-2/.venv/lib/python3.12/site-packages/temporalio/worker/workflow_sandbox/_importer.py", line 248, in _import
    mod = importlib.__import__(name, globals, locals, fromlist, level)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1470, in __import__
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 999, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/Users/jssmith/t/samples-python-2/.venv/lib/python3.12/site-packages/sniffio/_impl.py", line 11, in <module>
    class _ThreadLocal(threading.local):
  File "/Users/jssmith/t/samples-python-2/.venv/lib/python3.12/site-packages/temporalio/worker/workflow_sandbox/_restrictions.py", line 1016, in __getattribute__
    state.assert_child_not_restricted(__name)
  File "/Users/jssmith/t/samples-python-2/.venv/lib/python3.12/site-packages/temporalio/worker/workflow_sandbox/_restrictions.py", line 852, in assert_child_not_restricted
    raise RestrictedWorkflowAccessError(
temporalio.worker.workflow_sandbox._restrictions.RestrictedWorkflowAccessError: Cannot access threading.local.__mro_entries__ from inside a workflow. If this is code from a module not used in a workflow or known to only be used deterministically from a workflow, mark the import as pass through.

@jssmith jssmith merged commit 7ea40bf into main Aug 7, 2025
12 checks passed
@jssmith jssmith deleted the jssmith/oai-agents-gpt-oss branch August 7, 2025 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants