feat: ADK 1.19/2.0 cross-version regression suite + lazy-import compat fixes#559
Open
tiantt wants to merge 3 commits into
Open
feat: ADK 1.19/2.0 cross-version regression suite + lazy-import compat fixes#559tiantt wants to merge 3 commits into
tiantt wants to merge 3 commits into
Conversation
… compat fixes
Adds a 44-test regression suite targeting every veadk↔ADK seam where 1.19 and
2.0 differ, and fixes two compat bugs the suite caught when run against ADK
2.0.
New tests (tests/test_adk_compat_regression.py)
-----------------------------------------------
- A. Direct coverage of every public helper in veadk.utils.adk_compat that
test_adk_compat.py didn't already exercise (get_adk_version, is_adk_gte,
should_use_async_db_drivers, llm_request_has_field, plus the getter path
for get_event_function_responses).
- B. Edge cases for the event extractors: parts=None / empty / mixed, no
content, broken getters falling back to part traversal.
- C. Integration against real ADK Event / Content / Part objects so we
notice if ADK silently changes its public surface.
- D. Agent.run override gated by is_adk_gte("2.0.0") (skipped on v2 by
design; verifies NotImplementedError still surfaces on v1).
- E. ArkLlm version-branching: ImportError when LlmRequest lacks
previous_interaction_id; get_previous_interaction_id on real LlmRequest.
- F. tool_attributes_extractors fallback variants (model_dump path, empty
sentinel, attribute object, missing attrs).
- G. Runner.intercept_new_message integration with a synthetic LLM:
session_service is InMemorySessionService for local STM, create_session
contract, end-to-end yield, None-event filtering, part.text=None
tolerance.
- H. ADK public-surface assumptions (version module, LlmRequest.model_fields,
Event.get_function_calls/responses).
Compat fixes caught by running the suite under ADK 2.0
------------------------------------------------------
- veadk/agent.py: gate the legacy Agent.run NotImplementedError override on
`not is_adk_gte("2.0.0")`. ADK 2.0 promotes BaseAgent.run to a @Final
async generator that the Workflow/NodeRunner engine invokes internally;
overriding it breaks workflow execution.
- veadk/utils/patches.py: walk `mod.__dict__` instead of `dir(mod)` +
`getattr` when patching tracers across google.adk.* modules. ADK 2.0's
`google.adk.tools` package defines `__getattr__` for lazy submodule
loading; the old dir+getattr pattern triggered every lazy module, including
optional ones like discovery_engine_search_tool that need google-cloud-*
deps veadk doesn't ship.
- veadk/evaluation/eval_set_recorder.py: defer the
`from google.adk.cli.utils import evals` import to the call site. ADK 2.0
has that module top-import gcs_eval_set_results_manager unconditionally,
which requires google-cloud-storage — needlessly tainting any veadk caller
who only imports veadk.Runner.
Regression results
------------------
Both versions show identical counts; each skips exactly the one test that
doesn't apply to its API surface (the suite is symmetric across versions):
* ADK 1.19.0: 195 passed + 1 skipped
(skip: test_get_previous_interaction_id_with_real_llm_request —
v1 LlmRequest lacks previous_interaction_id)
* ADK 2.0.0: 195 passed + 1 skipped
(skip: test_agent_run_raises_notimplemented_on_legacy_adk —
override is removed on v2 by design)
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tests/test_adk_compat_regression.py),针对 veadk↔ADK 在 1.19 和 2.0 之间存在差异的每一处集成点。veadk/utils/patches.py用mod.__dict__取代dir(mod) + getattr,避免触发 ADK 2.0google.adk.tools的 lazy__getattr__(后者会无条件 import 可选依赖,如discovery_engine_search_tool)。veadk/evaluation/eval_set_recorder.py把from google.adk.cli.utils import evals延迟到调用处,避免 ADK 2.0 中该模块顶层 import GCS 评估管理器、要求google-cloud-storage才能加载veadk.Runner的连锁问题。veadk/agent.py用is_adk_gte("2.0.0")门禁住Agent.run的旧NotImplementedErrorguard——ADK 2.0 把BaseAgent.run升为@finalasync generator(NodeRunner workflow 内部入口),覆盖会让框架崩。跨版本回归结果
test_get_previous_interaction_id_with_real_llm_request(v1 没该字段)test_agent_run_raises_notimplemented_on_legacy_adk(v2 不存在该 override,设计如此)两边数字完全一致,且 skip 落在不同测试上——是真正的版本对称回归。
测试分区
get_adk_version/is_adk_gte/should_use_async_db_drivers/llm_request_has_field等Event.get_function_calls()native getter 一致Agent.__dict__["run"]是否存在跟is_adk_gte("2.0.0")一致get_previous_interaction_id安全访问part.text=None不抛version.__version__、LlmRequest.model_fields、Event方法Test plan
pytest tests/under google-adk==1.19.0 → 195 passed + 1 skippedpytest tests/under google-adk==2.0.0 → 195 passed + 1 skipped🤖 Generated with Claude Code