Skip to content
Skillpedia
General coding7.8k · #12879

fallback-code-execution

What it does

This skill is a workaround for running Python code when the sandbox keeps failing with unknown or unstable errors. It is for people whose AI runs code that must produce results.

When to use it

  • ✓When the sandbox has failed two or more times in a row with the same code.
  • ✓When the errors are generic and suggest environment trouble rather than code mistakes.
  • ✓When I want the script kept as a file so it can be checked and run again.

Skill link

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/fallback-code-execution/SKILL.md

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/fallback-code-execution/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute →

Example of what to ask your AI

“The sandbox keeps throwing generic errors on my script, and the logic is right. Please save it as a file and run it.”

5 new skills a week. 1 minute to read.

How it works

The AI writes the script into the workspace under a descriptive name, installs any dependencies first, and runs it through the shell while capturing the output.

Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

Fallback Code Execution Workflow

Overview

This skill defines a robust workaround for executing code (specifically Python) when the primary execute_code_sandbox tool fails repeatedly with unknown or transient errors. Instead of continuing to retry the failing tool, the agent switches to a manual file-write and shell-execution pattern.

Trigger Conditions

Activate this workflow when:

  1. execute_code_sandbox fails 2 or more times consecutively for the same logic.
  2. Error messages are generic, unknown, or indicate environment issues rather than syntax errors.
  3. The code logic itself is verified correct but the execution environment is unstable.

Procedure

Step 1: Write Script to File

Use the write_file tool to save the Python script to a specific path in the workspace.

  • Path: Choose a descriptive name ending in .py (e.g., scripts/generate_report.py).
  • Content: Ensure the script includes necessary error handling and print statements for debugging.
  • Dependencies: If the script requires external libraries, ensure a requirements.txt is updated or installed via shell beforehand.

Example:

tool: write_file
path: workspace/scripts/process_data.py
content: |
  import sys
  # ... script logic ...
  print("Success")

Step 2: Execute via Shell

Use the run_shell tool to execute the script using the system Python interpreter.

  • Command: python3 <path_to_script> or python <path_to_script>.
  • Working Directory: Ensure the shell command runs from the workspace root or the directory containing the script.
  • Capture Output: Store stdout and stderr for verification.

Example:

tool: run_shell
command: python3 scripts/process_data.py

Step 3: Verify Execution

  1. Check Exit Code: Ensure the shell command returned exit code 0.
  2. Check Output: Verify expected files were created or expected stdout messages appeared.
  3. Handle Errors: If the shell execution fails, inspect the stderr output. This often provides more detailed tracebacks than the sandbox tool.

Best Practices

  • Absolute Paths: When writing scripts that access files, use absolute paths or resolve paths relative to __file__ to avoid working directory issues.
  • Permissions: Ensure the workspace directory allows file creation and execution.
  • Cleanup: Optionally remove temporary scripts after successful execution if cleanliness is required.
  • Logging: Add explicit print() statements in the Python script to log progress, as shell output capture is sometimes more reliable than sandbox return values.

Example Scenario

Problem: execute_code_sandbox times out while generating a PDF. Solution:

  1. Write generate_pdf.py to workspace/scripts/.
  2. Run python3 workspace/scripts/generate_pdf.py via run_shell.
  3. Confirm output.pdf exists in the workspace.
FAQ

Why keep the script as a file?

A saved file can be inspected, changed and run again without rewriting the code.

Where is the script saved?

In the workspace, under a descriptive name ending in .py.

What if packages are needed?

The guide says to install them from a requirements file or through the shell beforehand.

Details

Original description by the author

Fallback workflow for running code via file write and shell when sandbox execution fails

repo: HKUDS/AgentPilot

Popularity

GitHub stars
7.8k
Ranking position
#12879
License
MIT
Updated
11/1/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills