Inspiration

What it does

How I built it

Challenges I ran into

Accomplishments that I'm proud of

What I learned

What's next for Migration Agent

Inspiration

Every Python team that depends on web3.py and hasn't upgraded to v7 yet hits the same wall: twelve-plus breaking changes — renamed provider classes, snake-cased keyword arguments, ABI types moved out of web3.types, whole modules (ethpm, web3.geth.miner) removed. The work is mechanical, boring, and still done by humans on a Friday night. We wanted an agent that does the boring part and is honest about the parts it cannot do.

What it does

Migration Agent is a Gemini-powered agent that automates the web3.py v6 → v7 migration on a GitLab repository, end-to-end:

  1. detect_framework — reads requirements.txt / pyproject.toml / imports to find web3 >=6.0 projects.
  2. run_codemod — invokes a deterministic AST codemod (codemod-web3py-v7, built on jssg) that handles 86% of the breaking changes with zero false positives and leaves TODO(web3py-v7) comments where it can't (e.g., removed modules).
  3. open_merge_request — branch + commit + push, then calls create_merge_request on the official GitLab Duo MCP server with a Gemini-authored title and description (including a "Manual Review and Further Steps Needed" section surfaced from the codemod's TODOs).

The whole agent loop fires off one shell command and walks away — the reviewer wakes up to a clean MR.

How we built it

  • Agent loop: agent/main.py (171 LOC), Gemini 2.5 Flash function calling.
  • Tools: detect_framework, run_codemod (codemod jssg via npx), open_merge_request (git push + GitLab Duo MCP create_merge_request over HTTPS).
  • Partner MCP integration: official GitLab Duo MCP server at https://gitlab.com/api/v4/mcp. OAuth Dynamic Client Registration handled by mcp-remote; bearer token cached locally and used in subsequent agent calls.
  • Hosted demo: Cloud Run (Python 3.12 + Node 20 image; gunicorn serves a Flask landing page with embedded video and a "Run again" button that re-triggers the agent on a live demo target).
  • Live demo target: gitlab.com/run58669-maker/web3py-v6-sample — a realistic v6 dApp that exercises every codemod path.

Challenges we ran into

  • GitLab Duo MCP server requires Premium/Ultimate tier + beta-features-on. Took a 30-day free trial activation and a settings cascade for the OAuth endpoint to start responding.
  • gemini-2.5-pro is paid-tier-only; we ship the agent on gemini-2.5-flash which is free-tier covered.
  • Cloud Build default compute SA needed an explicit storage.objectViewer grant before the first image push went through.

Accomplishments that we're proud of

  • Three real, openable MRs on a real GitLab repo as proof — including one (MR #3) opened via the official GitLab Duo MCP create_merge_request tool. Not a screencast.
  • Honest output: the agent surfaces the codemod's TODOs as a Manual Review section in the MR body, so the reviewer sees both what was migrated and what they still need to handle.

What we learned

  • Even with a tightly-scoped codemod, the value an LLM adds is summarizing what the codemod didn't do — a single MR comment can save 10 minutes of grep.
  • MCP's "tool surface + bearer token" model fits agent loops well; we wired it in one short refactor of tools/gitlab_mr.py.

What's next for Migration Agent

  • More codemods: requestshttpx, setup.pypyproject.toml, FastAPI 0.95 → 0.115.
  • Multi-MR workflow: a single agent run that opens one MR per breaking-change family.
  • GitLab CI pipeline integration: have the agent annotate the MR with pipeline results before it pings the human reviewer.

Built With

Share this project:

Updates