resilient-data-gathering
它能做什么
这项技能在多个工具接连失败时,为 AI 智能体提供备用方案。它适合即使常用工具没有响应,也需要之后可以核查结果的人。
适用场景
- ✓当搜索、辅助智能体和代码沙箱工具在两到三次尝试后都失败的时候。
- ✓当所需数据已经为人所知,或可以根据对话合理估算的时候。
- ✓当你需要保存中间结果,以便之后核查或恢复的时候。
技能链接
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/resilient-data-gathering/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“搜索和代码工具一直失败。请使用我给你的产品价格,把它们放入脚本,并将结果保存为 JSON 文件。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会收集它已有的数据,把它放入 shell 中的 Python 脚本,并将每一步保存到 JSON 文件。这些文件让你可以审核工作内容,并在中断处继续。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Resilient Data Gathering Workflow
Purpose
When search_web, shell_agent, and execute_code_sandbox all fail repeatedly with 'unknown error' or similar tool execution failures, fall back to embedding known domain data directly into run_shell Python scripts and persisting intermediate data to JSON files for auditability and recovery.
When to Use This Pattern
Apply this pattern when:
- Trigger condition: 2-3 consecutive failures across multiple tools (
search_web,shell_agent,execute_code_sandbox) with 'unknown error' messages - You have domain knowledge: The required data is known or can be reasonably estimated from context
- Auditability needed: Intermediate results must be preserved for verification or rollback
Step-by-Step Instructions
Step 1: Recognize Tool Failure Pattern
Monitor for repeated failures across multiple execution tools:
search_webreturns errors or empty resultsshell_agentfails to complete autonomous tasksexecute_code_sandboxthrows 'unknown error' repeatedly
Decision point: After 2-3 failures, switch to the fallback pattern rather than continuing to retry failing tools.
Step 2: Gather Known Domain Data
Collect all data you already know or can reasonably infer:
- Product specifications, prices, SKUs
- Competitor information from context
- Business rules and constraints
- Historical data from previous task phases
Document this data in a structured format before embedding.
Step 3: Embed Data in run_shell Python Script
Create a Python script that embeds the known data directly as literals or constants:
import json
import os
from datetime import datetime
# ============================================
# EMBEDDED DOMAIN DATA (known from context)
# ============================================
PRODUCT_DATA = {
"sku_001": {
"name": "Product A",
"competitor_price": 29.99,
"weight_oz": 12,
"category": "beverage"
},
"sku_002": {
"name": "Product B",
"competitor_price": 34.99,
"weight_oz": 16,
"category": "snack"
}
}
BUSINESS_RULES = {
"margin_target": 0.25,
"price_floor": 19.99,
"price_ceiling": 99.99
}
# ============================================
# ANALYSIS LOGIC
# ============================================
def analyze_products(products, rules):
results = {}
for sku, data in products.items():
price_per_oz = data["competitor_price"] / data["weight_oz"]
recommended_price = data["competitor_price"] * (1 + rules["margin_target"])
recommended_price = max(rules["price_floor"], min(rules["price_ceiling"], recommended_price))
results[sku] = {
**data,
"price_per_oz": round(price_per_oz, 2),
"recommended_price": round(recommended_price, 2),
"analysis_timestamp": datetime.now().isoformat()
}
return results
# Execute analysis
analysis_results = analyze_products(PRODUCT_DATA, BUSINESS_RULES)
# ============================================
# PERSIST INTERMEDIATE DATA (audit trail)
# ============================================
output_file = "intermediate_analysis.json"
with open(output_file, "w") as f:
json.dump({
"metadata": {
"generated_at": datetime.now().isoformat(),
"source": "embedded_domain_data",
"fallback_reason": "tool_execution_failures"
},
"results": analysis_results
}, f, indent=2)
# Signal artifact location for downstream tools
print(f"ARTIFACT_PATH:{os.path.abspath(output_file)}")
# Output results for immediate consumption
print("\n=== ANALYSIS RESULTS ===")
print(json.dumps(analysis_results, indent=2))
Step 4: Execute via run_shell
Run the embedded script using run_shell:
python3 << 'EOF'
[paste the full script from Step 3]
EOF
Or save to a file first:
cat > analysis_script.py << 'SCRIPT'
[paste script content]
SCRIPT
python3 analysis_script.py
Step 5: Persist and Verify Intermediate Results
Ensure JSON files are created and contain valid data:
import json
# Verify persistence
with open("intermediate_analysis.json", "r") as f:
验证数据 = json.load(f)
assert "results" in 验证数据
assert "metadata" in 验证数据
print(f"✓ Persisted {len(验证数据['results'])} records")
Step 6: Chain Subsequent Operations
Use persisted JSON as input for downstream operations:
import json
常见问题
智能体何时切换到这种方法?
这项技能要求在搜索、辅助智能体和沙箱工具之间经历两到三次失败后再切换。
为什么要把数据保存为 JSON 文件?
保存的文件便于核查结果,并且在出现问题时可以从中断处继续。
智能体会编造缺失的数字吗?
这项技能依赖已知或合理推断的数据,因此在使用前请核对任何估算值。
详情
作者的原始描述
Fallback pattern when primary tools fail - embed known data in scripts and persist to JSON for auditability
repo: HKUDS/AgentPilot
热度
- GitHub 星标
- 7.8k
- 排名
- #12973
- 许可证
- MIT
- 更新时间
- 2026/11/1
评论
- …
同一仓库的更多技能
agentpilot
7.8k帮你的智能体准备任务并运行 AgentPilot 循环,逐步改进项目:循环会提出修改、测试修改并为其打分。
openspace
7.8k帮你的智能体设置 OpenSpace,这是一个用于存储和获取智能体技能的工具,并通过 MCP 将其连接到你的 AI 应用。
rsi-arena
7.8k帮你的智能体设置并运行标准 AI 基准测试,例如 AIME 和 Terminal-Bench,用来比较不同的改进方法。
experiment-guide
7.8k帮你的智能体规划小型实验、阅读实验结果并记录发现,同时研究如何改进一个程序。