The script collects migration evidence. It does not prove that a migration is correct or complete. Your coding agent still needs to inspect your repository and run its tests.
Choose the Perplexity product
This example uses the Search SDK because another program will consume the result.
Set up
You need Python 3.12 and a Perplexity API key. The commands below assume Bash on macOS or Linux.Describe the upgrade
Save this asupgrade.json:
Build the evidence collector
Save this asupgrade_research.py:
How the collector works
The collector separates search from the decisions your coding agent will make later. Build the query plan.TOPICS defines five independent migration questions and the official documentation host allowed for each one. research combines each topic with the target version from upgrade.json. Changing the target version changes every query without changing the rest of the pipeline.
Run the searches together. search.web_many sends the five requests with a concurrency limit of three. Each result has its own success or failure state, so one failed query does not erase the other results. The script keeps at most two HTTPS results from the exact host assigned to that topic.
Extract focused passages. Search results help you find pages. content.snippets takes the selected URLs and returns passages relevant to the original query. Mapping results by URL keeps each passage attached to its page even if the order changes. A failed snippets call records a gap for that topic and continues. An errored or empty result affects only its URL.
Write the handoff. render groups the passages by topic and records missing evidence under Retrieval gaps. Every usable item keeps its query, title, URL, and passage. The script writes the file before checking coverage, then exits with status 1 when any topic lacks evidence. You can inspect the gaps, while CI or another agent can stop before treating the file as complete.
The Search SDK handles discovery and passage extraction. Your code owns the query plan, domain policy, result limits, failure policy, and output contract.
Run the search
agent-context.md. It exits with status 0 when every topic has evidence and status 1 when one or more topics have no usable evidence. A missing API key or another top-level error stops the run without leaving an older context file in place.
Live results vary as documentation and search results change. Review the generated URLs and passages before using them.
Give the context to your coding agent
Referenceagent-context.md from the AI coding tool you already use: