Skip to content

test: cover web reload agent observer setup#5769

Open
he-yufeng wants to merge 1 commit into
google:mainfrom
he-yufeng:fix/web-reload-agents-api-server-scope
Open

test: cover web reload agent observer setup#5769
he-yufeng wants to merge 1 commit into
google:mainfrom
he-yufeng:fix/web-reload-agents-api-server-scope

Conversation

@he-yufeng
Copy link
Copy Markdown

Summary

  • remove redundant function-local ApiServer imports in get_fast_api_app
  • add a regression test for web=True plus reload_agents=True while DevServer is available

Fixes #5765

To verify

  • .\.venv\Scripts\python.exe -m py_compile src\google\adk\cli\fast_api.py tests\unittests\cli\test_fast_api.py
  • .\.venv\Scripts\python.exe -m pytest tests/unittests/cli/test_fast_api.py::test_web_reload_agents_uses_module_api_server_import -q -p no:cacheprovider
  • uv run --extra dev pyink --check src\google\adk\cli\fast_api.py tests\unittests\cli\test_fast_api.py
  • git diff --check

Notes

  • uv run --extra test ... currently cannot resolve the locked test environment on Windows because yarl==1.24.1 has no win_amd64 wheel or source distribution.

@adk-bot adk-bot added the web [Component] This issue will be transferred to adk-web label May 20, 2026
@adk-bot
Copy link
Copy Markdown
Collaborator

adk-bot commented May 20, 2026

Response from ADK Triaging Agent

Hello @he-yufeng, thank you for creating this PR!

This PR looks great and addresses issue #5765! To fully follow our contribution guidelines, could you please:

  • Provide the logs or a screenshot of the passed test/verification output (e.g., the pytest output for the regression test you added).

This will help reviewers understand and approve your changes much faster. Thank you!

@rohityan rohityan self-assigned this May 20, 2026
@rohityan rohityan added the request clarification [Status] The maintainer need clarification or more information from the author label May 20, 2026
@rohityan
Copy link
Copy Markdown
Collaborator

Hi @he-yufeng , Thank you for your contribution! We appreciate you taking the time to submit this pull request. Please fix formatting errors by running autoformat.sh

@he-yufeng he-yufeng force-pushed the fix/web-reload-agents-api-server-scope branch from 2b7d6a2 to 918c545 Compare May 21, 2026 04:52
@he-yufeng
Copy link
Copy Markdown
Author

Rebased onto current main, added the required future annotations import for the changed non-test Python file, and re-ran the focused checks.

Local validation:

  • python -m pytest tests/unittests/cli/test_fast_api.py::test_web_reload_agents_uses_module_api_server_import -q --basetemp .tmp/pytest-5769-focused -> 1 passed
  • python -m pyink src/google/adk/cli/fast_api.py tests/unittests/cli/test_fast_api.py --check -> passed
  • python -m py_compile src/google/adk/cli/fast_api.py tests/unittests/cli/test_fast_api.py -> passed
  • git diff --check -> passed

I also checked the changed non-test Python file for the required from __future__ import annotations import. A full local file-level pytest run hits Windows tempfile cleanup locks in unrelated tests, so I kept the local validation focused on this PR's regression case.

@he-yufeng he-yufeng force-pushed the fix/web-reload-agents-api-server-scope branch from 918c545 to 0d6cf14 Compare May 22, 2026 14:14
@he-yufeng
Copy link
Copy Markdown
Author

Rebased this onto current main. The implementation conflict is now resolved by upstream main (the web server class selection already uses the module-level DevServer/ApiServer imports), so this PR now only keeps the focused regression coverage for the reload observer path.

Local validation after the rebase:

PYTHONUTF8=1 .\.venv\Scripts\python.exe -m pytest tests\unittests\cli\test_fast_api.py::test_web_reload_agents_uses_module_api_server_import -q --basetemp .tmp\pytest-5769-rebase
# 1 passed, 5 warnings

PYTHONUTF8=1 .\.venv\Scripts\python.exe -m pyink tests\unittests\cli\test_fast_api.py --check
PYTHONUTF8=1 .\.venv\Scripts\python.exe -m py_compile tests\unittests\cli\test_fast_api.py
git diff --check upstream/main..HEAD

@he-yufeng he-yufeng changed the title fix: avoid ApiServer scope shadowing in web reload test: cover web reload agent observer setup May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

request clarification [Status] The maintainer need clarification or more information from the author web [Component] This issue will be transferred to adk-web

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UnboundLocalError on ApiServer in cli/fast_api.py when running adk web --reload_agents on 2.0.0

3 participants