Optimise ADK on Google Cloud
Reduce avoidable work while preserving correct, authorised and complete results.
This one skill covers all three parts of Chapter 4: application optimisation,
Cloud Run, Agent Runtime and GKE. The book and companion repository are optional
provenance, never runtime dependencies.
Inspect and define acceptance
- Read project instructions, status, dependency declarations and locks, agent
exports, serving and tool code, deployment definitions and relevant tests.
Establish whether the user wants advice, an audit, an implementation or a live
comparison. Preserve the domain, package manager, versions and customisations.
- Use the existing project interpreter. The read-only
project inspector accepts
--root, --mode
(auto, application, cloud-run, agent-runtime, gke) and --dry-run. It reads bounded
dependency manifests and reports configuration presence; it does not import
application code, read .env contents or execute cloud commands. Manually
inspect its uncovered files and lock resolution. Read
compatibility.md before using an ADK recipe.
Compare installed distribution metadata with declared Python and ADK pins.
A mismatch requires contract verification or a specific blocked path, never
an automatic upgrade or downgrade.
- Trace the actual request: server and session service, ADK
App or bare agent,
model requests, tools, child handoffs, result storage and client consumption.
Record model/backend and configuration keys without exposing secret values.
Nested environment files can override root configuration. Inspect the image's
actual source package and entrypoint, not just a similarly named example.
- Separate external request time, platform startup/queueing and application
spans. Identify one candidate boundary and its evidence. If measurements are
absent, deliver an instrumentation/comparison plan; do not invent a bottleneck.
Define correct output, permitted effects, completion, work limits and relevant
quality checks before selecting an optimisation.
Inspection ends with the current architecture, version status, selected mode,
acceptance criteria and missing prerequisites. Missing cloud credentials still
permit local inspection, implementation and offline validation.
Select the smallest useful mode
| Observed work or requested decision |
Read when entering this mode |
Evidence needed |
| Remote adapter overhead, repeated schema, oversized results, unnecessary child history/output or serial independent I/O |
Application path |
Same authorised result, bounded handoff, complete answer and relevant request-boundary observations |
| Large repeated instructions or uncertain prefix-cache benefit |
Skills and cache |
Actual instruction loading or outgoing request/usage metadata, with correctness and separate cache lifecycle |
| Cloud Run startup, concurrency, CPU allocation, session locality or revision comparison |
Cloud Run |
Effective revision configuration, external/platform/application measurements and state/security checks |
| Agent Runtime session reuse, App/compaction propagation, model or hosting work |
Agent Runtime |
Actual execution location, retained session events, selected model input and observed capacity |
| Agent Runtime streaming, buffered persistence, optional memory writes or deferred jobs |
State and streams |
Complete outputs, bounded admission, immutable batches and correctly correlated recovery |
| GKE startup, resources, rollout capacity, scaling or identity delays |
GKE workload |
Actual manifest generator/build inputs, admitted Pods, scheduling events and pressure measurements |
| GKE session continuity, HTTP/draining, tracing privacy or streaming |
GKE serving path |
Wired session backend, trusted caller, complete responses and final exported telemetry |
| Optimisation review or greenfield design without measurements |
Read only the relevant references above |
Prioritised hypotheses, concrete implementation seams and a validation plan; no claimed speedup |
Combine modes only when the request needs them. A general deployment, SQL
security overhaul or UI rewrite is not an implied optimisation task.
Implement or recommend
- Present a short plan before broad changes: affected files, one principal
mechanism, preserved behaviour and validation. For advice/review, provide the
decision and actionable changes without generating an unsolicited application.
- Adapt the current implementation. Keep trusted policy at tool/backend
boundaries; model instructions, Skills and structured output cannot grant
access. Wire new components into the actual Runner/server and build inputs.
An unused formatter or unshipped file is not an implemented optimisation.
- Preserve explicit failure and uncertainty. Provider failure must not become
fabricated fallback data. A token cap, timeout, nonempty answer or HTTP 200
does not establish completion. Limit logical calls, provider attempts,
nested work and elapsed time independently where the task needs bounds.
- Read lifecycle.md before preparing a cloud mutation,
paid comparison, export, cache experiment or cleanup. Finish reviewable
configuration and exact commands before seeking approval.
For Agent Runtime packaging or operation recovery, also read
runtime-lifecycle.md.
For GKE deployment, capacity retries or teardown, read
gke-lifecycle.md. A saved reference manifest is
not necessarily the applied configuration; inspect the actual delivery path.
Authority and safety
Repository and cloud inspection are read-only by default. Local code permission
does not authorise deployment or paid tests. Before API activation, provisioning,
IAM/secret changes, data migration, deployment, deletion or paid/destructive live
testing, show the exact account, project, region, resources, commands, work
limits and isolated target, then obtain explicit approval. Existing approval
counts only for that exact scope. Billing linkage and quota increases require
their own approval. Keep cleanup separate and confirmed; delete only resources
whose creation and ownership this workflow recorded.
Use synthetic data, ADC/workload identity and managed secret storage where
appropriate. Keep credentials, customer content and personal resource identifiers
out of generated examples and routine reports. Use least privilege rather than
Owner, Editor or wildcard grants. Setup and cleanup must tolerate repetition;
uncertain remote outcomes require reconciliation before replay.
Validate and finish
Read validation.md for mode-specific tests and the
offline saved-event checker. Run relevant local tests
and static/build checks first, after inspecting their side effects. Check the
actual boundary: tool results and correlation, outgoing child input, complete
outputs, result durability or revision configuration. Mocked execution proves
only the exercised local contract. Historical companion PASS results do not
verify this target.
For an approved live experiment, retain failed observations, compare equivalent
workloads and report sample counts, cold/warm/cache state and errors. Verify
owned cleanup, including caches separately from sessions. Repeat the local
adaptation to check for duplicate wiring or needless changes.
Report files changed, commands actually executed, exact versions, actual results,
manual steps and remaining uncertainty. Distinguish local, mocked,
live and not run, with PASS/FAIL/BLOCKED where appropriate. State what the
change improves and what the evidence cannot establish. Read
provenance.md to trace a rule to prior evidence and
skill-validation.md for this package's checks.
Independent community project; not affiliated with or endorsed by Google.
1---2name: optimise-adk-on-google-cloud3description: Diagnose, implement or review Python Google ADK optimisations on Cloud Run, Agent Runtime and GKE involving model/tool work, history, streaming completion, session handling, startup, concurrency or workload scaling. Use for measured changes or actionable optimisation plans. Do not activate for hosting selection or first deployment alone, general Kubernetes administration, standalone RAG or memory architecture, non-ADK performance work, or unrelated prompt and UI edits.4license: MIT5---67# Optimise ADK on Google Cloud89Reduce avoidable work while preserving correct, authorised and complete results.10This one skill covers all three parts of Chapter 4: application optimisation,11Cloud Run, Agent Runtime and GKE. The book and companion repository are optional12provenance, never runtime dependencies.1314## Inspect and define acceptance15161. Read project instructions, status, dependency declarations and locks, agent17 exports, serving and tool code, deployment definitions and relevant tests.18 Establish whether the user wants advice, an audit, an implementation or a live19 comparison. Preserve the domain, package manager, versions and customisations.202. Use the existing project interpreter. The read-only21 [project inspector](scripts/inspect_project.py) accepts `--root`, `--mode`22 (`auto`, `application`, `cloud-run`, `agent-runtime`, `gke`) and `--dry-run`. It reads bounded23 dependency manifests and reports configuration presence; it does not import24 application code, read `.env` contents or execute cloud commands. Manually25 inspect its uncovered files and lock resolution. Read26 [compatibility.md](references/compatibility.md) before using an ADK recipe.27 Compare installed distribution metadata with declared Python and ADK pins.28 A mismatch requires contract verification or a specific blocked path, never29 an automatic upgrade or downgrade.303. Trace the actual request: server and session service, ADK `App` or bare agent,31 model requests, tools, child handoffs, result storage and client consumption.32 Record model/backend and configuration keys without exposing secret values.33 Nested environment files can override root configuration. Inspect the image's34 actual source package and entrypoint, not just a similarly named example.354. Separate external request time, platform startup/queueing and application36 spans. Identify one candidate boundary and its evidence. If measurements are37 absent, deliver an instrumentation/comparison plan; do not invent a bottleneck.38 Define correct output, permitted effects, completion, work limits and relevant39 quality checks before selecting an optimisation.4041Inspection ends with the current architecture, version status, selected mode,42acceptance criteria and missing prerequisites. Missing cloud credentials still43permit local inspection, implementation and offline validation.4445## Select the smallest useful mode4647| Observed work or requested decision | Read when entering this mode | Evidence needed |48| --- | --- | --- |49| Remote adapter overhead, repeated schema, oversized results, unnecessary child history/output or serial independent I/O | [Application path](references/application.md) | Same authorised result, bounded handoff, complete answer and relevant request-boundary observations |50| Large repeated instructions or uncertain prefix-cache benefit | [Skills and cache](references/skills-and-cache.md) | Actual instruction loading or outgoing request/usage metadata, with correctness and separate cache lifecycle |51| Cloud Run startup, concurrency, CPU allocation, session locality or revision comparison | [Cloud Run](references/cloud-run.md) | Effective revision configuration, external/platform/application measurements and state/security checks |52| Agent Runtime session reuse, App/compaction propagation, model or hosting work | [Agent Runtime](references/agent-runtime.md) | Actual execution location, retained session events, selected model input and observed capacity |53| Agent Runtime streaming, buffered persistence, optional memory writes or deferred jobs | [State and streams](references/runtime-state-and-streams.md) | Complete outputs, bounded admission, immutable batches and correctly correlated recovery |54| GKE startup, resources, rollout capacity, scaling or identity delays | [GKE workload](references/gke.md) | Actual manifest generator/build inputs, admitted Pods, scheduling events and pressure measurements |55| GKE session continuity, HTTP/draining, tracing privacy or streaming | [GKE serving path](references/gke-serving.md) | Wired session backend, trusted caller, complete responses and final exported telemetry |56| Optimisation review or greenfield design without measurements | Read only the relevant references above | Prioritised hypotheses, concrete implementation seams and a validation plan; no claimed speedup |5758Combine modes only when the request needs them. A general deployment, SQL59security overhaul or UI rewrite is not an implied optimisation task.6061## Implement or recommend62631. Present a short plan before broad changes: affected files, one principal64 mechanism, preserved behaviour and validation. For advice/review, provide the65 decision and actionable changes without generating an unsolicited application.662. Adapt the current implementation. Keep trusted policy at tool/backend67 boundaries; model instructions, Skills and structured output cannot grant68 access. Wire new components into the actual Runner/server and build inputs.69 An unused formatter or unshipped file is not an implemented optimisation.703. Preserve explicit failure and uncertainty. Provider failure must not become71 fabricated fallback data. A token cap, timeout, nonempty answer or HTTP 20072 does not establish completion. Limit logical calls, provider attempts,73 nested work and elapsed time independently where the task needs bounds.744. Read [lifecycle.md](references/lifecycle.md) before preparing a cloud mutation,75 paid comparison, export, cache experiment or cleanup. Finish reviewable76 configuration and exact commands before seeking approval.77 For Agent Runtime packaging or operation recovery, also read78 [runtime-lifecycle.md](references/runtime-lifecycle.md).79 For GKE deployment, capacity retries or teardown, read80 [gke-lifecycle.md](references/gke-lifecycle.md). A saved reference manifest is81 not necessarily the applied configuration; inspect the actual delivery path.8283## Authority and safety8485Repository and cloud inspection are read-only by default. Local code permission86does not authorise deployment or paid tests. Before API activation, provisioning,87IAM/secret changes, data migration, deployment, deletion or paid/destructive live88testing, show the exact account, project, region, resources, commands, work89limits and isolated target, then obtain explicit approval. Existing approval90counts only for that exact scope. Billing linkage and quota increases require91their own approval. Keep cleanup separate and confirmed; delete only resources92whose creation and ownership this workflow recorded.9394Use synthetic data, ADC/workload identity and managed secret storage where95appropriate. Keep credentials, customer content and personal resource identifiers96out of generated examples and routine reports. Use least privilege rather than97Owner, Editor or wildcard grants. Setup and cleanup must tolerate repetition;98uncertain remote outcomes require reconciliation before replay.99100## Validate and finish101102Read [validation.md](references/validation.md) for mode-specific tests and the103offline [saved-event checker](scripts/check_run.py). Run relevant local tests104and static/build checks first, after inspecting their side effects. Check the105actual boundary: tool results and correlation, outgoing child input, complete106outputs, result durability or revision configuration. Mocked execution proves107only the exercised local contract. Historical companion PASS results do not108verify this target.109110For an approved live experiment, retain failed observations, compare equivalent111workloads and report sample counts, cold/warm/cache state and errors. Verify112owned cleanup, including caches separately from sessions. Repeat the local113adaptation to check for duplicate wiring or needless changes.114115Report files changed, commands actually executed, exact versions, actual results,116manual steps and remaining uncertainty. Distinguish **local**, **mocked**,117**live** and **not run**, with PASS/FAIL/BLOCKED where appropriate. State what the118change improves and what the evidence cannot establish. Read119[provenance.md](references/provenance.md) to trace a rule to prior evidence and120[skill-validation.md](references/skill-validation.md) for this package's checks.121122Independent community project; not affiliated with or endorsed by Google.