Delegate complex tasks to shell_agent when direct tool execution fails, leveraging autonomous error recovery and library selection
复制下面这句话,粘贴给 Claude Code、Codex、Cursor 等 AI 编程工具,它会读取安装说明并在你确认后完成安装。
请阅读 https://ai.atlankj.com/install/asset/gh-shell-agent-delegation-1bef8066e9af ,按照其中的说明把「shell-agent-delegation」安装到你(当前 AI 工具)中。执行前先告诉我将运行的命令和写入的位置,等我确认。
查看 AI 将读取的安装说明正在读取 GitHub 原文…
内容来自 GitHub 原始文件,由原作者维护。在 GitHub 查看
Apply this pattern when:
The shell_agent tool differs from direct execution tools in key ways:
Identify when to pivot to shell_agent:
- execute_code_sandbox returned 'unknown error'
- read_webpage/search_web failed multiple times
- Direct approaches are struggling with the task complexity
Create a clear, self-contained task description for shell_agent:
Good task description:
Create a 1-page SBAR Template PDF document. Include sections for:
- Situation: Brief description of the current situation
- Background: Relevant context and history
- Assessment: Current assessment and analysis
- Recommendation: Proposed actions and next steps
Use a professional layout with clear headings and adequate whitespace.
Key elements to include:
Call shell_agent with your task description:
# Conceptual example
shell_agent(task="Create a professional SBAR Template PDF with Situation, Background, Assessment, and Recommendation sections. Include clear headings and professional formatting.")
After shell_agent completes:
# When direct approaches fail:
# execute_code_sandbox(code="...") # Returns 'unknown error'
# search_web(query="...") # Returns 'unknown error'
# Pivot to shell_agent:
shell_agent(
task="Generate a professional one-page template document in PDF format. "
"Include clearly labeled sections with appropriate spacing and formatting. "
"Select the most appropriate Python library for PDF generation.",
timeout=300 # Allow time for iteration and error recovery
)
❌ Don't use shell_agent for simple, single-command tasks (use run_shell instead) ❌ Don't provide overly prescriptive code instructions (defeats the autonomous benefit) ❌ Don't set timeout too low (<60 seconds for complex tasks) ❌ Don't split a coherent task into multiple shell_agent calls unnecessarily