Translate terminal sandbox errors to non-retryable ApplicationError#1595
Open
xumaple wants to merge 1 commit into
Open
Translate terminal sandbox errors to non-retryable ApplicationError#1595xumaple wants to merge 1 commit into
xumaple wants to merge 1 commit into
Conversation
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>
There was a problem hiding this comment.
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 terminalSandboxErrors become non-retryableApplicationErrors. - Add unit tests verifying terminal vs transient/unclassified sandbox errors are handled as intended.
- Bump the
openai-agentsoptional dependency minimum to0.17.5to rely onSandboxError.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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
OpenAI Agents sandbox activities passed every
agents.sandboxexception 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 aSandboxErrorthe library has classified as terminal (retryable is False) to a non-retryableApplicationError; transient and unclassified errors (retryableTrue or None) still propagate and retry by default.Fixes #1548