Agent Runtime

Autonomous Dependency Migration Agent with OpenHands

An agent-runtime workflow that upgrades a breaking dependency across a codebase: it localizes affected usages, applies fixes in a sandbox, runs the test suite, and opens a PR when green.

What This Builds

This recipe builds an agent that performs a real migration — for example, a breaking library major-version bump or a framework upgrade — across a codebase. The agent localizes the affected usages, edits the files, runs the build and tests in a sandbox, and iterates until the suite is green, then opens a pull request with the diff and a summary of what changed.

It uses OpenHands (formerly OpenDevin), an open-source, model-agnostic coding-agent platform that can read files, run shell commands, and edit code. The “fix, run tests, repeat” loop is what separates a migration agent from a one-shot codemod: the test suite is the oracle that tells the agent whether the migration is actually correct.

Product Shape

This is a stateful agent runtime, not a stateless worker. The agent needs a real filesystem, a shell, git, and the ability to run the project’s build and tests. Run it inside a sandbox so destructive commands can never touch your machine, and gate the result behind a human-reviewed PR — migrations are high blast-radius changes.

The Stack

  • OpenHands — the coding agent that plans the migration, edits files, and runs commands.
  • E2B — an isolated cloud sandbox giving the agent a safe filesystem, shell, and git, so a bad command can’t escape.
  • GitHub repository — the codebase to migrate and the destination for the resulting PR.
  • GitHub Actions — re-runs the full CI suite on the agent’s PR as an independent check.
  • A capable model such as Anthropic Startup Program credits for the agent’s reasoning and code edits.

Step-by-Step Outline

  1. Define the migration goal precisely (e.g. “upgrade library X from v2 to v3, fix all breaking call sites, keep tests passing”).
  2. Start OpenHands against a fresh checkout inside an E2B sandbox.
  3. Have the agent localize affected usages by searching for the old API across the repo.
  4. The agent applies edits, runs the project’s build and test commands, and reads the failures.
  5. Loop: fix, re-run tests, until the suite passes (or the agent reports it is blocked).
  6. Open a PR with the diff and a summary; let GitHub Actions run CI independently and a human review before merge.

Why This Shape Works

The combination of a sandbox (safety) and a passing test suite (correctness oracle) is what makes autonomous migration viable rather than reckless. The agent can take destructive actions freely because they are contained, and it knows it is done only when the tests it cannot fake are green.

Source