fallback-code-execution
Fallback workflow for running code via file write and shell when sandbox execution fails
- License 许可
- MIT
- 所属仓库
- AG064/OpenSpace
- 最近更新
- 2026-10-08
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- fallback-code-execution
- description
- Fallback workflow for running code via file write and shell when sandbox execution fails
02 资源文件 1
- 其他.skill_id37 B
03 SKILL.md 正文
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:
execute_code_sandboxfails 2 or more times consecutively for the same logic.- Error messages are generic, unknown, or indicate environment issues rather than syntax errors.
- 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.txtis 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>orpython <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
- Check Exit Code: Ensure the shell command returned exit code
0. - Check Output: Verify expected files were created or expected stdout messages appeared.
- 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:
- Write
generate_pdf.pytoworkspace/scripts/. - Run
python3 workspace/scripts/generate_pdf.pyviarun_shell. - Confirm
output.pdfexists in the workspace.
04 同仓库更多 Skills
write-special-chars-ts-check
Workaround for write_file failures caused by special characters (apostrophes, backticks, template literals) using a Python heredoc script, plus a reliable TypeScript type-checking step that filters output to only the newly-written files to avoid being misled by pre-existing errors.
write-special-chars-readback
Workaround for write_file failures caused by special characters (apostrophes, backticks, template literals) using a Python heredoc script, with mandatory post-write verification via read_file and cleanup of /tmp helper scripts.
write-special-chars-heredoc
Workaround for write_file failures caused by special characters (apostrophes, backticks, template literals) by using a Python heredoc script executed via shell.
worldmonitor-reference
Curated architecture index of the WorldMonitor open-source dashboard. Reference for extracting patterns — vanilla TypeScript, Panel class hierarchy, service layer, CSS grid, API edge functions, refresh scheduler, and 60+ data source integrations.
virtual-list
Implement efficient virtual scrolling for rendering large lists with DOM recycling, chunk-based rendering, and performance optimizations
verify-directory-structure
Diagnose and resolve file access issues by first verifying the directory structure.