Skip to content

recipes: Add Cloud Run hosting - #2657

Open
rorym-hudson wants to merge 1 commit into
google:mainfrom
rorym-hudson:agents/high-volume-data-analyzer-gcp
Open

rorym-hudson wants to merge 1 commit into
google:mainfrom
rorym-hudson:agents/high-volume-data-analyzer-gcp

Conversation

@rorym-hudson

Copy link
Copy Markdown

Summary

  • Migrate the High-Volume Document Analyzer and Cyber Guardian recipes to ADK 2.x.
  • Add standard serving files for hosting.
  • Add Docker and agents-cli configuration.
  • Prevent BigQuery initialization during module import.

Validation

  • Dependency lockfiles resolve ADK 2.9.1.
  • Ruff checks pass.
  • Container verification was not run because Docker is unavailable in the local environment.

Migrate both recipes to ADK 2.x, add standard serving files, and prevent cloud resource initialization during module import.
@google-cla

google-cla Bot commented Sep 19, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated Security review — 5 finding(s).


Round 1 · 0 of this PR's 25 automated comments used · this round is capped at 20 across all reviewers.


EXPOSE 8080

CMD ["uv", "run", "uvicorn", "cyber_guardian.fast_api_app:app", "--host", "0.0.0.0", "--port", "8080"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MAJOR] Can you please add a USER directive to avoid running the container as root? Running as non-root is a security best practice.


EXPOSE 8080

CMD ["uv", "run", "uvicorn", "high_volume_document_analyzer.fast_api_app:app", "--host", "0.0.0.0", "--port", "8080"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MAJOR] missing USER directive here

``APP_URL``). Call once per app — typically in a FastAPI ``lifespan``, since
the card is built asynchronously; repeated calls register duplicate routes.
"""
resolved_app_url = app_url or os.getenv("APP_URL", "http://0.0.0.0:8000")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MAJOR] Is there a reason we have hardcoded defaults on environment reads here? There are six such occurrences in this PR where defaults should be defined in .env.example instead.

from cyber_guardian.app_utils import services
from cyber_guardian.app_utils.a2a import attach_a2a_routes

load_dotenv()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MAJOR] Perhaps we should move the load_dotenv() call to cyber_guardian/__init__.py? The handbook indicates it belongs in the package initialization module.

from high_volume_document_analyzer.app_utils import services
from high_volume_document_analyzer.app_utils.a2a import attach_a2a_routes

load_dotenv()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MAJOR] load_dotenv() belongs in __init__.py

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated Maintainability review — 1 finding(s).


Round 1 · 0 of this PR's 25 automated comments used · this round is capped at 20 across all reviewers.

allowed = streaming_methods if streaming else sync_methods
if class_method not in allowed:
raise HTTPException(
status_code=404,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MINOR] Is there a reason we are not using standard HTTP status constants here? We can use status.HTTP_404_NOT_FOUND from fastapi instead of the bare 404 literal across the two reasoning engine adapters.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated Hygiene review — 1 finding(s).


Round 1 · 0 of this PR's 25 automated comments used · this round is capped at 20 across all reviewers.

logger = logging.getLogger(__name__)

root_agent = Agent(
root_agent = LlmAgent(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MINOR] It seems cyber_guardian/agent.py is missing the app definition. Can we import App from google.adk.apps and define app = App(root_agent=root_agent, name="cyber_guardian") as done in high_volume_document_analyzer/agent.py?

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated Correctness review — 5 finding(s).


Round 1 · 0 of this PR's 25 automated comments used · this round is capped at 20 across all reviewers.


@contextlib.asynccontextmanager
async def lifespan(app: FastAPI) -> AsyncIterator[None]:
from cyber_guardian.agent import app as adk_app

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MAJOR] It seems cyber_guardian/agent.py is missing the instantiation of app = App(root_agent=root_agent, name="cyber_guardian"). Can you please define it there so this import does not fail?

)
app.state.runner = runner
app.state.agent_app_name = adk_app.name
await attach_a2a_routes(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MAJOR] Can you please import and call attach_reasoning_engine_routes(app) here? Otherwise, the reasoning engine routes will never be registered on the FastAPI application.

)
app.state.runner = runner
app.state.agent_app_name = adk_app.name
await attach_a2a_routes(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MAJOR] same issue as above


# 0.3 uses method names that include a '/' like "message/send"
# 1.0 uses PascalCase like "SendMessage"
json_body = getattr(request, "_json", {}) or {}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MAJOR] Is there a reason we are accessing the private _json attribute on the request object? This is fragile and will be empty if the JSON body has not yet been parsed.


# 0.3 uses method names that include a '/' like "message/send"
# 1.0 uses PascalCase like "SendMessage"
json_body = getattr(request, "_json", {}) or {}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MAJOR] same issue as above

@happyhuman happyhuman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are no longer accepting any futher contribution in recipes under python/agents and we are migrating them to contrib/python.
Please move your recipe to that folder, and upgrade it to meet the new quality standards of the repo. Please see docs/ for more information.

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.

2 participants