跳到正文
DEV Community· Reuben Alex·· 38 分鐘前AI 評分61

作者實測 Google ADK 破壞性變更,並開發 adk-upgrade-check

I tested Google ADK's breaking changes against real releases.

AI 導讀

作者 Reuben Alex 以實際版本測試 Google ADK 的破壞性變更,並開發開源工具 adk-upgrade-check,檢查專案升級時可能受影響的程式碼。

正文

Google's Agent Development Kit moves fast. Since 2.0 went GA in
May 2026, the changelog has had a "Breaking changes" section in 2.6, 2.7, 2.13, 2.14 and 2.15: minor releases. So every ADK upgrade means someone reading release notes and searching their own code by hand.

I saw this most clearly in a well-run template repo's upgrade PR. The maintainer had checked by hand that the template "has no enum-typed tool arguments, and it runs no SQL of its own against the session tables", and told forks to review the release notes themselves. That's careful engineering, and it's also a job a tool should do.

So I built one: adk-upgrade-check.

What it does

pipx install adk-upgrade-check
adk-upgrade-check path/to/your/agent --to 2.15.1
  • It reads your current version from uv.lock, poetry.lock, requirements.txt or pyproject.toml, and runs only the rules for the releases you're crossing.
  • It parses your code with LibCST and never imports or runs it. There are no API keys, and it doesn't call an LLM.
  • Each finding names the release that caused it, links the upstream commit and says how to fix it.
  • --fix rewrites the mechanical cases after showing you the diff, for example plan == "pro" to plan == Plan.PRO, or sqlite:/// to sqlite+aiosqlite:///.
  • It outputs JSON and SARIF, and ships with a GitHub Action and a pre-commit hook, so it can run on the Dependabot PR that bumps google-adk.

The rule: no rule without a reproduction

Changelogs are written by people in a hurry, and docs drift. A checker built from the wording would
report confident nonsense. So for every rule that can fail a build, I installed the google-adk
releases on either side of the change and reproduced the break, with small scripts that now live in the repo's
tests/ground_truth/:

Change Before After
Enum tool arguments (2.14) 2.13.0: the tool gets "pro", and plan == "pro" is True 2.14.0: the tool gets Plan.PRO, and plan == "pro" is False
Vertex create_session(session_state=…) (2.14) 2.13.0: accepted 2.14.0: ValueError
BigQuery plugin with google-adk[gcp] (2.7) 2.6.3: imports 2.7.0: ImportError: pyarrow is required
google.adk.cli.built_in_agents (2.15) 2.14.1: imports 2.15.0: ModuleNotFoundError

Doing this changed the rule set in three ways.

1. A breaking change that isn't in the changelog

In 1.19.0, DatabaseSessionService became fully async. The changelog files it under features
("Full async implementation of DatabaseSessionService"). But any synchronous URL, including the
sqlite:/// URL from many tutorials, now fails at startup:

1.18.0  DatabaseSessionService("sqlite:///./sessions.db")  -> works
1.19.0  DatabaseSessionService("sqlite:///./sessions.db")  -> ValueError

Following that thread turned up a second one. In the same release, the CLI started sending
--session_service_uri sqlite:///... to a different service, SqliteSessionService, with a new
schema. If you run adk web or adk api_server against a SQLite file that 1.18 wrote, 1.19 (and
2.15.1) refuse to start:

RuntimeError: Database sessions.db seems to use an old schema.
Please run the migration command to migrate it to the new schema.

There's a migration script. But nothing in the breaking-changes list tells you to look for it.

2. A documented break that I couldn't reproduce

The ADK 2.0 upgrade notes say overridden _run_async_impl methods are now "bypassed by the graph
engine". That would be a great rule: easy to detect, and severe. But on the normal Runner path,
the override still runs in 1.39.1, 2.0.0 and 2.15.1, for both BaseAgent and LlmAgent subclasses.

The note may describe agents run as nodes inside a Workflow. Either way, a rule based on the docs
would have flagged working code in most projects, so I didn't ship it.

Results on 23 real projects

I ran every rule on google/adk-samples (1,956 Python files,
about 13 seconds) and on 22 public ADK projects found through GitHub code search. Then I labelled
every finding by hand:

Rule Findings Real breaks
Sync database URL (1.19) 9 9
CLI SQLite service switch (1.19) 2 2
call_llm telemetry span removed (2.13, "likely") 3 2
MCP prompt arguments (2.15, "likely") 1 0
The other seven rules 0 –

Two of those projects are pinned to exactly google-adk==1.18.0, one release before their session
setup stops working.

Every finding marked certain was a real break. The two wrong ones are both marked likely,
which is why only certain findings fail CI by default. When static analysis can't be sure, for
example whether an MCP prompt actually takes arguments, the tool says so instead of failing your
build.

What's next

  • More rules as ADK ships. The aim is to cover each new release within days, so that "what breaks in 2.16?" has an answer you can run.
  • A semi-automated rule pipeline. Watch PyPI, diff the tagged sources, draft a rule and fixtures, then gate it on a reproduction and the corpus, with a human reviewing every rule.
  • Upstream. I'd like this to become part of the official upgrade path, the way Pydantic's migration guide points to bump-pydantic.

If you maintain an ADK project, try it on your next upgrade PR:

uvx adk-upgrade-check . --to latest

If it misses something that broke for you, open an issue.
A failing example is the most useful thing you can send. Rules are small, and
CONTRIBUTING.md
explains how to add one.

adk-upgrade-check is an independent open-source project, not affiliated with or endorsed by Google.

來源:DEV Community · dev.to