Skip to content

Translate terminal sandbox errors to non-retryable ApplicationError#1595

Open
xumaple wants to merge 1 commit into
mainfrom
maplexu/openai-sandbox-retryable-errors
Open

Translate terminal sandbox errors to non-retryable ApplicationError#1595
xumaple wants to merge 1 commit into
mainfrom
maplexu/openai-sandbox-retryable-errors

Conversation

@xumaple

@xumaple xumaple commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

OpenAI Agents sandbox activities passed every agents.sandbox exception through unchanged, so Temporal treated them all as retryable, and a terminal failure (e.g. the sandbox was stopped externally) retried forever and wedged the workflow.

openai-agents 0.17.5 exposes SandboxError.retryable. This maps a SandboxError the library has classified as terminal (retryable is False) to a non-retryable ApplicationError; transient and unclassified errors (retryable True or None) still propagate and retry by default.

Fixes #1548

Sandbox integration activities in the OpenAI Agents contrib passed every
exception from the agents.sandbox library through as-is, so Temporal
treated them all as retryable. A terminal failure (e.g. the sandbox was
stopped externally) would retry forever and wedge the workflow.

openai-agents 0.17.5 exposes SandboxError.retryable. Wrap each sandbox
activity so a SandboxError the library has classified as terminal
(retryable is False) is re-raised as a non-retryable ApplicationError;
transient and unclassified errors (retryable True or None) still
propagate and retry by default.

Fixes #1548

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR prevents Temporal workflows using the OpenAI Agents sandbox integration from retrying forever on terminal sandbox failures by translating agents.sandbox.errors.SandboxError instances marked retryable is False into non-retryable temporalio.exceptions.ApplicationError.

Changes:

  • Add _translate_sandbox_errors() and wrap sandbox-related activities so terminal SandboxErrors become non-retryable ApplicationErrors.
  • Add unit tests verifying terminal vs transient/unclassified sandbox errors are handled as intended.
  • Bump the openai-agents optional dependency minimum to 0.17.5 to rely on SandboxError.retryable.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
temporalio/contrib/openai_agents/sandbox/_sandbox_client_provider.py Wrap sandbox activities to translate terminal SandboxErrors into non-retryable ApplicationErrors.
tests/contrib/openai_agents/test_openai_sandbox.py Add tests asserting correct retryability mapping behavior for sandbox errors.
pyproject.toml Update openai-agents extra to require >=0.17.5.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +255 to +259
key = str(args.state.session_id)
session = self._sessions.get(key)
if session is not None:
await session.shutdown()
del self._sessions[key]
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.

[Bug] openai_agents/sandbox activities throw only retryable exceptions

2 participants