Repository navigation
fix(cli): preserve dependency cache on agent source changes - #8261
aashikantkumar wants to merge 2 commits into
Conversation
Install source-independent agent requirements before copying agent source. Preserve source-first installation for local dependencies and requirements that cannot be safely classified, so existing deployments keep working. Fixes google#6923
|
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. |
|
Hi, I noticed #7181 is already open for this issue. I opened #8261 to address the local-dependency compatibility concern discussed above, preserving source-first installation when requirements may need agent files. Would you prefer incorporating this fallback and its regression tests into #7181, or reviewing #8261 as an alternative? I’m happy to coordinate with the existing author and close my PR if that is the preferred direction |
Link to Issue or Description of Change
Closes: #6923
Related: #7181 (currently open; this proposal includes a conservative fallback
for requirements that may need agent files during installation).
Problem:
Generated deployment Dockerfiles copy the complete agent directory before
installing its requirements. Editing only agent source invalidates the
dependency-installation layer even when requirements are unchanged.
Solution:
Install ordinary named requirements before copying the complete agent source.
Preserve source-first installation for local paths and archives, editable
installs, direct URLs, included requirements/constraints, pip options, continued
lines, unreadable files, and unrecognized syntax. Agents without a requirements
file do not get a requirements COPY or install instruction.
Apply this in the shared renderer used by Docker, Cloud Run, Agent Engine, and
GKE. Existing extra-package installation order and CLI options are retained.
Testing Plan
Unit Tests:
all four deployment targets, including missing requirements and encoding.
and 3.14.
376 passed.
uv build; installed the wheelin a clean Python 3.11 environment and verified cache-friendly, local-file
fallback, and absent-requirements rendering with source imports disabled.
Full matrix (
tox -p 4 --parallel-live):The existing
test_render_start_command_wrapper_handles_legacy_signature_without_agent_loaderfails after
TestAgentLoader.test_agent_without_root_agent_errorleaves asame-name
broken_agentmodule cached. Reproduced this two-test sequence on anuntouched archive of baseline commit
fb08c784242c9afc3d8645508d8c5c08c9836eb9on all four Python versions:1 passed, 1 failed each. The legacy-startup function and AgentLoader are
unchanged by this PR.
Python 3.14 additionally reported the wall-clock-sensitive telemetry test
test_sequential_tools_add_up: measured 1.17 seconds against an expectedapproximately 0.2 seconds. Isolated reruns passed on both the original baseline
and this branch. The telemetry implementation and test are unchanged. Neither
failure was suppressed or changed to make the matrix green.
Expanded test command:
This covers Click-option/signature matching, Dockerfile options, provider and
environment arguments, Python versions, extra packages, ignore rules, and
container startup checks in addition to the new dependency cases.
Manual Docker Tests:
Built the generated Dockerfile with a Python 3.11 base and an agent requiring
the base image's installed
pippackage. Rebuilt after an agent-only edit,then after a requirements edit. Used a generated local wheel with an absolute
container path for the compatibility case and rebuilt after replacing its
contents. Disposable containers checked updated source and imported both wheel
versions. Only the unrelated ADK package-installation instruction was omitted
to isolate the changed dependency layers; this was not a cloud deployment.
Actual output from five Docker builds:
For reproduction, build twice with the same Docker builder/cache after changing
only agent.py; the requirements COPY and pip-install step should use cache.
Change requirements.txt and rebuild; pip must run again. Repeat using a local
wheel inside the agent directory, referenced by its absolute container path;
the full-source COPY must precede pip, and replacing the wheel must reinstall
its changed content.
Checklist
checks documented above).
Additional context
This intentionally optimizes only requirements that can be confidently
classified as source-independent. More complex pip syntax continues to work
with the existing source-first order. No new CLI flag is introduced.