Skip to content

feat: ADK 1.19/2.0 cross-version regression suite + lazy-import compat fixes#559

Open
tiantt wants to merge 3 commits into
mainfrom
feat/adk-v2-regression-suite
Open

feat: ADK 1.19/2.0 cross-version regression suite + lazy-import compat fixes#559
tiantt wants to merge 3 commits into
mainfrom
feat/adk-v2-regression-suite

Conversation

@tiantt
Copy link
Copy Markdown
Collaborator

@tiantt tiantt commented May 21, 2026

Summary

  • 新增 44 个回归测试 (tests/test_adk_compat_regression.py),针对 veadk↔ADK 在 1.19 和 2.0 之间存在差异的每一处集成点。
  • 顺带 fix 了跑这套测试在 ADK 2.0 下抓出来的两个真实兼容 bug:
    • veadk/utils/patches.pymod.__dict__ 取代 dir(mod) + getattr,避免触发 ADK 2.0 google.adk.tools 的 lazy __getattr__(后者会无条件 import 可选依赖,如 discovery_engine_search_tool)。
    • veadk/evaluation/eval_set_recorder.pyfrom google.adk.cli.utils import evals 延迟到调用处,避免 ADK 2.0 中该模块顶层 import GCS 评估管理器、要求 google-cloud-storage 才能加载 veadk.Runner 的连锁问题。
  • veadk/agent.pyis_adk_gte("2.0.0") 门禁住 Agent.run 的旧 NotImplementedError guard——ADK 2.0 把 BaseAgent.run 升为 @final async generator(NodeRunner workflow 内部入口),覆盖会让框架崩。

跨版本回归结果

版本 passed skipped skip 的测试
google-adk 1.19.0 195 1 test_get_previous_interaction_id_with_real_llm_request(v1 没该字段)
google-adk 2.0.0 195 1 test_agent_run_raises_notimplemented_on_legacy_adk(v2 不存在该 override,设计如此)

两边数字完全一致,且 skip 落在不同测试上——是真正的版本对称回归。

测试分区

重点 数量
A. adk_compat 直接 helper get_adk_version / is_adk_gte / should_use_async_db_drivers / llm_request_has_field 15
B. 事件提取 helper 边缘 parts=None / 空 / 混合 / no content / getter 抛错 6
C. 真实 ADK Event 集成 验证 helper 与 Event.get_function_calls() native getter 一致 5
D. Agent.run 版本门禁 Agent.__dict__["run"] 是否存在跟 is_adk_gte("2.0.0") 一致 3
E. ArkLlm 版本分支 LlmRequest 缺字段时 ArkLlm 拒绝构造;get_previous_interaction_id 安全访问 3
F. tool_attributes_extractors model_dump / dict / 属性对象 / 空 responses 哨兵 四路兜底 4
G. Runner intercept_new_message FakeLlm 端到端,None 事件过滤,part.text=None 不抛 5
H. ADK 公共表面假设 version.__version__LlmRequest.model_fieldsEvent 方法 3

Test plan

  • pytest tests/ under google-adk==1.19.0 → 195 passed + 1 skipped
  • pytest tests/ under google-adk==2.0.0 → 195 passed + 1 skipped
  • End-to-end smoke: Agent + Runner + FakeLlm 单轮跑通(两版本均通过)

🤖 Generated with Claude Code

tiantt and others added 3 commits May 9, 2026 12:27
… 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant