[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6HXZACP1QDVBDT7JQ7MKB3H":3,"skill-same:01M6HXZACP1QDVBDT7JQ7MKB3H":65},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":32,"linkOnly":33,"markdownContent":34,"markdownBody":35,"frontMatter":36,"refName":37,"commitSha":38,"skillDirectory":39,"forksCount":40,"repositoryHtmlUrl":41,"repositoryHomepageUrl":6,"ownerHtmlUrl":42,"ownerBlogUrl":43,"ownerDescription":6,"updatedAt":44,"install":45,"resources":58},"01M6HXZACP1QDVBDT7JQ7MKB3H","shell-python-fallback",null,"Use run_shell with embedded Python heredoc as reliable fallback when code execution tools fail","HKUDS\u002FAgentPilot","HKUDS","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F118165258?v=4","01M6HW8VRNZP64G0P4MVJW2KKQ","✨Data Intelligence Lab@HKU✨","01M6HW8VWZVHBRHYH3T330PFWV",8029,"MIT","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Flegacy\u002Fv1\u002Fgdpval_bench\u002Fskills\u002Fshell-python-fallback\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31],"python","shell","fallback","shell python fallback","run","code","Tools","execution","use","embedded","as","code execution","with","2026-11-10 10:12:30",false,"---\nname: shell-python-fallback\ndescription: Use run_shell with embedded Python heredoc as reliable fallback when code execution tools fail\n---\n\n# Shell Python Fallback\n\n## When to Use\n\nUse this pattern when `execute_code_sandbox` or `shell_agent` tools consistently fail with \"unknown error\" for tasks such as:\n- Data processing and transformation\n- PDF generation (reportlab, etc.)\n- File parsing and manipulation\n- Any Python script execution that requires reliability\n\n## The Pattern\n\nInstead of using code execution tools, embed your Python script directly in a `run_shell` command using a heredoc:\n\n```bash\npython3 \u003C\u003C 'EOF'\n# Your Python code here\nimport sys\nprint(\"Hello from embedded Python\")\nEOF\n```\n\n## Step-by-Step Instructions\n\n1. **Identify the failure**: When `execute_code_sandbox` or `shell_agent` returns \"unknown error\" repeatedly (2+ attempts), switch to this fallback.\n\n2. **Write your Python script**: Prepare the complete Python code you need to execute.\n\n3. **Embed in run_shell**: Use `run_shell` with a heredoc syntax:\n\n```\nCommand: python3 \u003C\u003C 'EOF'\nimport json\n# Your complete script here\ndata = {\"key\": \"value\"}\nprint(json.dumps(data))\nEOF\n```\n\n4. **Handle multi-line scripts**: For longer scripts, ensure proper indentation is preserved. The heredoc preserves whitespace exactly.\n\n5. **Check output**: Parse the stdout from `run_shell` to verify success or capture errors.\n\n## Example: PDF Generation\n\n```bash\npython3 \u003C\u003C 'EOF'\nfrom reportlab.lib.pagesizes import letter\nfrom reportlab.pdfgen import canvas\n\nc = canvas.Canvas(\"output.pdf\", pagesize=letter)\nc.drawString(100, 750, \"Hello World\")\nc.save()\nprint(\"PDF created successfully\")\nEOF\n```\n\n## Example: Data Processing\n\n```bash\npython3 \u003C\u003C 'EOF'\nimport csv\nimport json\n\ndata = []\nwith open('input.csv', 'r') as f:\n    reader = csv.DictReader(f)\n    for row in reader:\n        data.append(row)\n\nwith open('output.json', 'w') as f:\n    json.dump(data, f, indent=2)\n\nprint(f\"Processed {len(data)} records\")\nEOF\n```\n\n## Best Practices\n\n- **Quote the EOF delimiter** (`\u003C\u003C 'EOF'` not `\u003C\u003C EOF`) to prevent shell variable expansion in your Python code\n- **Include error handling** in your Python script with try\u002Fexcept blocks\n- **Print status messages** to stdout so you can verify execution succeeded\n- **Use absolute paths** or ensure working directory is correct\n- **Test incrementally**: Start with a minimal script, then expand\n\n## Troubleshooting\n\n| Issue | Solution |\n|-------|----------|\n| Script doesn't run | Ensure `python3` is available in the shell environment |\n| Indentation errors | Check that heredoc preserves spaces (use spaces, not tabs) |\n| Module not found | Use `python3 -m pip install \u003Cmodule>` before running script |\n| File not found | Use absolute paths or `pwd` to verify working directory |\n\n## Why This Works\n\nThe `run_shell` tool executes commands directly in the system shell, bypassing the sandbox restrictions or internal errors that affect `execute_code_sandbox` and `shell_agent`. The heredoc approach allows multi-line Python scripts while keeping everything in a single shell command.","# Shell Python Fallback\n\n## When to Use\n\nUse this pattern when `execute_code_sandbox` or `shell_agent` tools consistently fail with \"unknown error\" for tasks such as:\n- Data processing and transformation\n- PDF generation (reportlab, etc.)\n- File parsing and manipulation\n- Any Python script execution that requires reliability\n\n## The Pattern\n\nInstead of using code execution tools, embed your Python script directly in a `run_shell` command using a heredoc:\n\n```bash\npython3 \u003C\u003C 'EOF'\n# Your Python code here\nimport sys\nprint(\"Hello from embedded Python\")\nEOF\n```\n\n## Step-by-Step Instructions\n\n1. **Identify the failure**: When `execute_code_sandbox` or `shell_agent` returns \"unknown error\" repeatedly (2+ attempts), switch to this fallback.\n\n2. **Write your Python script**: Prepare the complete Python code you need to execute.\n\n3. **Embed in run_shell**: Use `run_shell` with a heredoc syntax:\n\n```\nCommand: python3 \u003C\u003C 'EOF'\nimport json\n# Your complete script here\ndata = {\"key\": \"value\"}\nprint(json.dumps(data))\nEOF\n```\n\n4. **Handle multi-line scripts**: For longer scripts, ensure proper indentation is preserved. The heredoc preserves whitespace exactly.\n\n5. **Check output**: Parse the stdout from `run_shell` to verify success or capture errors.\n\n## Example: PDF Generation\n\n```bash\npython3 \u003C\u003C 'EOF'\nfrom reportlab.lib.pagesizes import letter\nfrom reportlab.pdfgen import canvas\n\nc = canvas.Canvas(\"output.pdf\", pagesize=letter)\nc.drawString(100, 750, \"Hello World\")\nc.save()\nprint(\"PDF created successfully\")\nEOF\n```\n\n## Example: Data Processing\n\n```bash\npython3 \u003C\u003C 'EOF'\nimport csv\nimport json\n\ndata = []\nwith open('input.csv', 'r') as f:\n    reader = csv.DictReader(f)\n    for row in reader:\n        data.append(row)\n\nwith open('output.json', 'w') as f:\n    json.dump(data, f, indent=2)\n\nprint(f\"Processed {len(data)} records\")\nEOF\n```\n\n## Best Practices\n\n- **Quote the EOF delimiter** (`\u003C\u003C 'EOF'` not `\u003C\u003C EOF`) to prevent shell variable expansion in your Python code\n- **Include error handling** in your Python script with try\u002Fexcept blocks\n- **Print status messages** to stdout so you can verify execution succeeded\n- **Use absolute paths** or ensure working directory is correct\n- **Test incrementally**: Start with a minimal script, then expand\n\n## Troubleshooting\n\n| Issue | Solution |\n|-------|----------|\n| Script doesn't run | Ensure `python3` is available in the shell environment |\n| Indentation errors | Check that heredoc preserves spaces (use spaces, not tabs) |\n| Module not found | Use `python3 -m pip install \u003Cmodule>` before running script |\n| File not found | Use absolute paths or `pwd` to verify working directory |\n\n## Why This Works\n\nThe `run_shell` tool executes commands directly in the system shell, bypassing the sandbox restrictions or internal errors that affect `execute_code_sandbox` and `shell_agent`. The heredoc approach allows multi-line Python scripts while keeping everything in a single shell command.",{"name":5,"description":7},"main","6b84b0689ca0d9e7b1e4061188ff6b60758e0f8a","openspace\u002Flegacy\u002Fv1\u002Fgdpval_bench\u002Fskills\u002Fshell-python-fallback",944,"https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot","https:\u002F\u002Fgithub.com\u002FHKUDS","https:\u002F\u002Fsites.google.com\u002Fview\u002Fchaoh","2026-11-12 22:26:39",{"source":8,"skillName":5,"commands":46,"prompt":56,"zipAvailable":57},[47,50,53],{"tool":48,"command":49},"npx","npx skills add HKUDS\u002FAgentPilot --skill shell-python-fallback",{"tool":51,"command":52},"bunx","bunx skills add HKUDS\u002FAgentPilot --skill shell-python-fallback",{"tool":54,"command":55},"pnpm","pnpm dlx skills add HKUDS\u002FAgentPilot --skill shell-python-fallback","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Flegacy\u002Fv1\u002Fgdpval_bench\u002Fskills\u002Fshell-python-fallback\u002FSKILL.md",true,[59],{"path":60,"resourceType":61,"resourceTypeDesc":62,"sizeBytes":63,"sourceHtmlUrl":64},".skill_id","OTHER","其他",35,"https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Flegacy\u002Fv1\u002Fgdpval_bench\u002Fskills\u002Fshell-python-fallback\u002F.skill_id",[66,83,102,126,150,172],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":32},"01M6HYB297NDABRERJRVG0K8R0","agentpilot","Set up AgentPilot and use its single entry to prepare missing inputs and run configured RSI experiments. Use when the user requests AgentPilot installation or work with AgentPilot.","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fplugins\u002Fagentpilot\u002Fskills\u002Fagentpilot\u002FSKILL.md",[],[68,73,74,31,75,76,77,78,27,79,80,81,23,82],"prepare","requests","missing","installation","rsi","up","user","work","SET","experiments",{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":32},"01M6HYAYWXTTE1J7DJM0MFNQ4H","remember","Review auto-memory entries and propose promotions to OPENSPACE.md, OPENSPACE.local.md, or retained auto-memory topics; detect duplicates, stale facts, conflicts, and ambiguous entries before making changes.","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Fopenspace\u002Fskills\u002Fremember\u002FSKILL.md",[],[85,90,91,92,93,94,95,96,97,98,99,100,101],"memory","review","auto","openspace","changes","facts","detect","entries","local","conflicts","stale","duplicates",{"skillNo":103,"name":104,"nameZh":6,"description":105,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":106,"categories":107,"keywords":113,"publishedAt":32},"01M6HYAVMPM4SBDV60R2B5HPV8","skill-discovery","Search reusable OpenSpace skills locally, and browse cloud packages step by step when a cloud skill may help. Reusing proven skills saves tokens, improves reliability, and extends your capabilities beyond built-in tools.","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Fopenspace\u002Fhost_skills\u002Fskill-discovery\u002FSKILL.md",[108],{"categoryNo":109,"categoryName":110,"taxonomyType":111,"taxonomyTypeDesc":112},"01JBSEEDCAT000000000000023","Skill与智能体开发","SCENARIO","使用场景",[114,115,116,93,117,118,119,120,121,122,123,124,125,25],"skill discovery","discovery","reusable","step by step","tokens","packages","help","cloud","reliability","capabilities","browse","search",{"skillNo":127,"name":128,"nameZh":6,"description":129,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":130,"categories":131,"keywords":133,"publishedAt":32},"01M6HYAR811B3RB0M50RBEDGN6","delegate-task","Delegate tasks to OpenSpace — a full-stack autonomous worker for coding, DevOps, web research, and desktop automation, backed by an extensive MCP tool and skill library. Skills auto-improve through use, reducing token consumption over time. A cloud community lets agents share and collectively evolve reusable skills.","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Fopenspace\u002Fhost_skills\u002Fdelegate-task\u002FSKILL.md",[132],{"categoryNo":109,"categoryName":110,"taxonomyType":111,"taxonomyTypeDesc":112},[134,135,136,93,137,138,139,140,141,116,92,27,142,143,144,145,146,147,148,149],"delegate","task","delegate task","time","improve","desktop automation","worker","community","autonomous","tool","stack","for","share","tasks","automation","MCP",{"skillNo":151,"name":152,"nameZh":6,"description":153,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":154,"categories":155,"keywords":156,"publishedAt":32},"01M6HYAM9FSGV6E52AYENDQXYH","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.","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Flegacy\u002Fv1\u002Fshowcase\u002Fskills\u002Fwrite-special-chars-ts-check\u002FSKILL.md",[],[157,158,159,160,161,162,163,164,165,19,166,167,168,169,145,170,171],"write special chars ts check","write","check","type","files","filters","only","template","file","typescript","output","Existing","type-checking","errors","script",{"skillNo":173,"name":174,"nameZh":6,"description":175,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":176,"categories":177,"keywords":178,"publishedAt":32},"01M6HYAH05HGV7SVWSVR8PJRQD","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 \u002Ftmp helper scripts.","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Flegacy\u002Fv1\u002Fshowcase\u002Fskills\u002Fwrite-special-chars-readback\u002FSKILL.md",[],[179,180,158,31,145,171,181,182,183,184,185,164,165,186,187,19],"write special chars readback","readback","helper","post","via","scripts","read","verification","cleanup"]