跳到正文
Skillpedia
智能体7.8k · #12951

resilient-context-extraction

它能做什么

这项技能告诉 AI 智能体读取你附上的所有文件,并将其视为事实的主要来源。它适合为 AI 提供参考文件,让它据此工作的人。

适用场景

  • ✓当你附上电子表格、PDF 或数据文件,并要求 AI 据此制作内容的时候。
  • ✓当 AI 的回答似乎忽略了你提供的文件的时候。
  • ✓当文件读取不完整,而你希望 AI 尝试其他方式打开它的时候。

技能链接

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/prioritize-context-data-enhanced/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/prioritize-context-data-enhanced/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请使用附件销售文件中的数字制作我的报告,不要为这些数字去网上搜索。”

每周 5 个新技能,1 分钟读完。

工作原理

智能体会列出你提供的每个文件,检查哪些与任务相关,并在查看其他任何地方之前先阅读它们。如果读取看起来不完整,它会尝试其他方法。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Resilient Context Extraction

Objective

Prevent data hallucination and inefficiency by mandating that agents inspect, validate, and fully extract data from provided reference files before attempting web searches or generating synthetic data. When extraction is incomplete, use fallback strategies before making assumptions.

Critical Rule

If a reference file is provided in the task context, it is the source of truth. Do not fabricate data or search the web for information that may exist within the provided attachments. If extraction appears incomplete, attempt alternative methods before proceeding.

Workflow Steps

1. Scan Context for Attachments

At the start of every task, explicitly list all files provided in the context window or attachment panel.

  • Check for spreadsheets (.xlsx, .csv), documents (.pdf, .docx, .pptx), or data dumps (.json, .txt, .xml, .yaml).
  • Note the filename, file size (if available), and inferred content type.
  • Record this list for later verification.

2. Evaluate Relevance

Determine if any provided file contains the data required to complete the task.

  • Match Keywords: Do filenames or expected column headers match task requirements?
  • Check Scope: Does the data cover the necessary timeframe or region?
  • Prioritize: Rank files by likelihood of containing required data.

3. Extract Data with Validation

If relevant files are found:

  • Read the file content using appropriate tools (e.g., read_file, pandas, pdf_reader).
  • Validate Extraction Completeness (NEW CRITICAL STEP):
    • Check if output appears truncated (e.g., sudden cutoff mid-sentence, character limits hit).
    • Compare expected data points vs. extracted data points (e.g., "Task mentions pricing tiers; did extraction include pricing numbers?").
    • Look for structural indicators of incompleteness (e.g., unclosed tables, missing document endings).
  • If extraction is incomplete or suspicious, proceed to Step 4 (Fallback Strategies) before using the data.

4. Apply Fallback Extraction Strategies

When initial extraction is incomplete or critical data is missing, attempt these strategies in order before making assumptions:

4a. Alternative Library/Tool Approach

  • For .docx: Try python-docx directly via execute_code_sandbox if read_file was truncated.
  • For .xlsx/.csv: Try pandas with explicit sheet selection or openpyxl directly.
  • For .pdf: Try pdfplumber, PyPDF2, or shell-based pdftotext if available.
  • For any format: Try reading as raw bytes/text via shell commands (cat, xxd, strings).

4b. Shell-Based Extraction

  • Use shell_agent or run_shell for format-specific tools:
    • unzip -p file.docx word/document.xml | xmllint --format - (extract raw docx XML)
    • in2csv file.xlsx (convert Excel to CSV via shell)
    • pdftotext file.pdf - (extract PDF text via command line)
  • This bypasses potential sandbox or library limitations in read_file.

4c. Targeted Re-Reading

  • If specific sections are missing (e.g., "pricing table on page 3"), attempt to re-read with focus on that region.
  • Use tools that support page/section ranges if available.

4d. Document What's Missing

  • Before any assumptions or external searches, explicitly document:
    • What data was expected but not found.
    • What extraction methods were attempted.
    • Why each method failed or what portions remain unavailable.
  • Example: "Attempted read_file on Pricing_email.docx (truncated at 980 chars). Attempted python-docx extraction via sandbox—pricing table in section 2 not present in file. Pricing numbers unavailable from provided context."

5. Cite Source Explicitly

When presenting data in the final output:

  • Explicitly state which file the data came from.
  • Example: "According to Massabama_active_listings.xlsx..."
  • If fallback methods were used, note this: "Extracted via shell-based pdftotext from report.pdf..."
  • This verifies to the user that real data was used, not hallucinated.

6. Fallback to Search (Last Resort Only)

If all extraction strategies fail to provide the specific data needed:

  • State clearly what was missing from the files.
  • Document all extraction methods attempted and why they failed.
  • Then proceed with web search or estimation.
  • Mark any non-file data clearly as "External Search" or "Estimated (file data unavailable)".
  • Never present estimated data as if it came from the file.

Che

常见问题

如果事实不在我的文件中,智能体还会上网搜索吗?

这项技能要求智能体先确认文件确实缺少该事实,之后才去其他地方查找。

这项技能涵盖哪些文件类型?

它列出了电子表格、PDF、Word 文件、CSV、JSON 和文本文件等需要检查的文件类型。

如果智能体仍然忽略我的文件怎么办?

请它列出所能看到的文件,并在继续之前先读取你需要的那一个。

详情

作者的原始描述

Ensures agents extract data from context files with validation and fallback strategies before resorting to assumptions or external searches.

repo: HKUDS/AgentPilot

热度

GitHub 星标
7.8k
排名
#12951
许可证
MIT
更新时间
2026/11/1

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能