Skip to content
Visual explainer 6h to learn 5 steps

ADK capstone: evaluate, release and document rollback

Run fixture and regression tests, demonstrate denial and fallback, publish redacted traces and write the deployment and rollback guide.

By Invicly Tech, , in Google ADK with Python for AI Agents. About 12 minutes to read.

Topic 29 of 29

In short

Release means proving the contract, not just deploying code. You run the evaluation matrix on fixtures in CI and on a live model before release, demonstrate denial and fallback cases, publish a few redacted traces, draw the request and session-isolation diagrams, and write a guide that covers deployment, cost, version and rollback. A release that cannot be rolled back in one command is not ready.

Explained simply

Release is where you prove the assistant keeps its promises. You run all the test cases, show the tricky ones on purpose, publish a few cleaned-up traces, and write a guide that someone else could follow to deploy it or undo the deployment.

Tests run in two modes. The fast mode uses the fake model and must pass completely on every change. The slow mode uses a real model, costs a little money, and passes if enough cases succeed, because real models word things slightly differently each time.

Some cases matter more than others. A user must never see another user's ticket. A broken tool must end in a polite fallback, not a crash. A request to change something must be handed to a person. You record these as short demos with traces, after removing tokens and anything personal.

The deployment and rollback guide closes the project. It names the exact ADK version, model, region and runtime, the expected cost per answer, how new versions are rolled out, and the one command that puts the previous version back.

Press Play on a diagram to walk through it one step at a time.

SequenceSession isolation evidence with two synthetic users
user-a
API
Session store
user-b
  1. 1Create session s-a1, ask about T-1001
    user-a to API: Create session s-a1, ask about T-1001
  2. 2Save events under user-a / s-a1
    API to Session store: Save events under user-a / s-a1
  3. 3GET session s-a1 with user-b token
    user-b to API: GET session s-a1 with user-b token
  4. 4Look up user-b / s-a1
    API to Session store: Look up user-b / s-a1
  5. 5Not found
    Session store to API: Not found
  6. 6404, nothing leaked
    API to user-b: 404, nothing leaked
  7. 7Ask about T-1001
    user-b to API: Ask about T-1001
  8. 8Ticket not found, escalate offered
    API to user-b: Ticket not found, escalate offered
FlowFrom green tests to a reversible release
  1. 1
    Fixture evals in CI

    Fake model, every commit

  2. 2
    Live-model evals

    Before release, thresholds

  3. 3
    Denial and fallback demo

    Recorded traces

  4. 4
    Deploy without traffic

    New Cloud Run revision

  5. 5
    Shift traffic gradually

    Watch errors and cost

  6. 6
    Roll back if needed

    Traffic to previous revision

CompareSingle agent vs code-routed workflow (synthetic results)
Single agent
  • 2.3 model calls per turn
  • p50 3.2 s
  • Answers 19/24, trajectory 0.92
  • Handles mixed questions
Code-routed workflow
  • 1.6 model calls per turn
  • p50 2.4 s
  • Answers 18/24, trajectory 0.96
  • Mixed questions need a fallback branch

In depth

The evaluation matrix

The matrix lists every case as a row and the properties it checks as columns: answer correct, citations valid, expected tools used, stop condition respected, escalation correct, and isolation held. Store cases as an ADK eval set (.evalset.json) with session_input, user_content, final_response and the expected tool_uses, and keep the scripted fake-model replies beside them. In test_config.json, use tool_trajectory_avg_score with IN_ORDER matching where an extra docs lookup is harmless, and EXACT for denial cases where no ticket tool call may succeed. Add final_response_match_v2 or a rubric-based criterion for answer quality in live runs; these use a judge model, so they need a key. Custom checks for citations and schema run in pytest. Aim for about 24 cases: 8 docs, 6 tickets, 4 escalation, 3 timeout or empty result, 3 denial and isolation.

MapEvaluation matrix categories
24 cases
  • Answers and citations (8)
    • Correct facts
    • Cited source IDs exist
    • No source: says so
  • Expected tool use (6)
    • Right tool, right ticket ID
    • No ticket tool for docs questions
  • Escalation (4)
    • Change request
    • Asks for a person
  • Timeouts and fallback (3)
    • Slow ticket store
    • Empty search
    • Call limit reached
  • Denial and isolation (3)
    • Other user's ticket
    • Other user's session
    • Injected instruction in a doc

Fixture runs and live-model runs

Fixture runs use SUPPORT_MODEL=fake and stubbed tools, so they are fast, free and exact. Run them with pytest on every commit; any failure blocks the merge. Live-model runs use the real Gemini model through adk eval or AgentEvaluator in pytest, cost money and vary between runs. Run them before each release and on a schedule, three times each, and compare the pass rate to the thresholds in the contract. When a live case fails, triage it: a wording change with correct facts may need a better rubric, a wrong tool or missing citation is a real regression, and a flaky case that passes two of three runs goes on a watch list rather than being deleted. Store the outputs, including the efficiency metrics such as inference_call_count_v1 and token_usage_v1, as CI artifacts.

  • Fixtures: every commit, must be 100 percent
  • Live: before release, three runs, thresholds
  • Real regression: wrong tool, bad citation, leak
  • Keep results as CI artifacts

Demonstrating denial and fallback

Record four short demos with both the fake model and, if you have a key, the live model. Denial: user-b asks for T-1001 and gets not found; the trace shows a NOT_FOUND tool result and no ticket fields. Isolation: user-b requests user-a's session and gets 404. Fallback: the ticket store stub sleeps for 3 seconds, the tool returns TIMEOUT, and the reply has reason tool_error with an offer to escalate. Limit: a fake script that keeps requesting tools hits max_llm_calls=6, ADK raises LlmCallsLimitExceededError, and the API returns a limit_reached reply. For each demo, save the request, the redacted event list, and the final JSON. These are the evidence the definition of done asks for.

Redacting and publishing traces

Traces help reviewers, but raw ones can contain bearer tokens, session IDs, user text and full tool payloads. Publish only traces from synthetic users, and run them through a redaction step first: drop authorisation headers, hash session and invocation IDs with a salt kept out of the repo, keep tool names, arguments that are mock ticket IDs, durations, error codes and token counts, and cut free text to the fixture questions only. Keep the shape of the trace intact so a reader can still follow model call, tool call, tool result and final reply. Check the result with a small script that fails if anything matching a token pattern or an email address remains.

Deployment and rollback guide

The guide is a short document in the repo. Version: google-adk 2.15.1, the Gemini model name, Python version and the commit hash. Runtime: one Cloud Run service in one region, authentication required, a dedicated service account, the session database URL from Secret Manager, minimum and maximum instances. Cost: calls per turn, tokens per turn and estimated cost per 1,000 turns from the live eval run, with the date of the price sheet used. Rollout: deploy a new revision with no traffic, run smoke tests against its revision URL, then move 10, 50 and 100 percent while watching error rate, latency and cost. Rollback: one update-traffic command back to the last good revision. State the assumptions: session schema compatible both ways, read-only tools, no data migration in the release.

CycleRelease loop
  1. 1
    Change

    Code, prompt, model or ADK pin

  2. 2
    Fixture evals

    Must pass 100 percent

  3. 3
    Live evals

    Meet contract thresholds

  4. 4
    Canary revision

    10 then 50 then 100 percent

  5. 5
    Watch

    Errors, latency, cost, escalations

  6. 6
    Keep or roll back

    Record the decision

  7. Back to step 1

Learn it in 5 short steps

About 1h 10m each. Track them with a timer in your plan.

  1. 1
    Run the evaluation matrix~1h 10m
  2. 2
    Demonstrate denial and fallback~1h 10m
  3. 3
    Publish redacted traces~1h 10m
  4. 4
    Draw the request and isolation diagrams~1h 10m
  5. 5
    Write the deployment and rollback guide~1h 10m

Key points

  • The matrix covers answer correctness, citations, expected tool use, timeouts, escalation, denial and isolation.
  • Fixture runs must pass exactly; live-model runs pass against thresholds such as 18 of 20.
  • Traces are published only after redaction: synthetic IDs, no tokens, no free-text user content beyond the fixtures.
  • The guide records the pinned ADK version, model, region, runtime, cost per turn and rollout assumptions.
  • Rollback is moving traffic back to the previous Cloud Run revision; session data must stay compatible both ways.

Key terms

Tap a card to flip it. 0/5 known

Examples

bash
# 1) Fixture evals (fake model, no key needed)
SUPPORT_MODEL=fake pytest tests/ -q
# 2) Live-model evals before release (paid Gemini usage)
adk eval support_agent evals/support.evalset.json \
  --config_file_path=evals/test_config.json --print_detailed_results
# 3) Roll back: send all traffic to the previous revision
gcloud run services update-traffic support-agent \
  --region=europe-west1 --to-revisions=support-agent-00007-abc=100

Revision names and region are placeholders; read the real ones from gcloud run revisions list.

Gating a release in CI

Prerequisites: GitHub Actions or any CI, the repo with tests and evals, and optionally a Gemini key stored as a CI secret. Step 1: the pull request job runs fixture tests only. Step 2: the release job, started by a tag, runs live evals three times and fails if any run falls below the contract thresholds. Step 3: both jobs upload results. Expected evidence: a green fixture job on every PR and a stored live eval report attached to each release.

bash
# PR job: free and exact
SUPPORT_MODEL=fake AUTH_MODE=dev pytest tests/ -q --junitxml=fixture.xml

# Release job: paid, thresholds in evals/test_config.json
for i in 1 2 3; do
  SUPPORT_MODEL=$LIVE_MODEL adk eval support_agent evals/support.evalset.json \
    --config_file_path=evals/test_config.json --print_detailed_results | tee live-$i.txt
done

A canary rollout and rollback on Cloud Run

This step is paid: it needs a Google Cloud project with billing. Design-only alternative: write the commands into the guide and run the same flow locally with two uvicorn processes behind a simple proxy. Step 1: deploy with no traffic and a tag. Step 2: smoke-test the tag URL with a synthetic token. Step 3: shift 10 percent and watch for an hour. Step 4: if errors or cost rise, send all traffic back. Cleanup: delete unused revisions and the test service when done.

bash
gcloud run deploy support-agent --source . --region=europe-west1 \
  --no-allow-unauthenticated --no-traffic --tag=canary
# smoke test against https://canary---support-agent-<hash>.a.run.app
gcloud run services update-traffic support-agent --region=europe-west1 \
  --to-tags=canary=10
# rollback
gcloud run services update-traffic support-agent --region=europe-west1 \
  --to-revisions=support-agent-00007-abc=100

Quick reference

  • Matrix columns: answer, citations, tool use, stop condition, escalation, isolation.
  • Fixture runs: fake model, every commit, 100 percent pass.
  • Live runs: adk eval with --config_file_path, three runs, contract thresholds.
  • Trajectory: IN_ORDER where extra lookups are harmless, EXACT for denial cases.
  • Redact: drop auth headers, hash session IDs, keep tool names, codes, timings.
  • Deploy with --no-traffic --tag=canary, then update-traffic in steps.
  • Rollback: gcloud run services update-traffic --to-revisions=LAST_GOOD=100.
  • Guide records ADK version, model, region, runtime, cost per turn, assumptions.

Common mistakes

  • Publishing raw traces that contain bearer tokens or user text from real testers.
  • Declaring success on the happy path without the timeout, empty-result and denial cases.
  • Changing the session schema in a way the previous revision cannot read, which blocks rollback.

Quick quiz

Pick an answer to see if you're right and why.

Question 1

1A live eval case passes two of three runs. What is the sensible action?

Question 2

2Which trajectory match type fits a denial case where no successful ticket lookup is allowed?

Question 3

3What must be removed before publishing a trace?

Question 4

4Why deploy the new revision with no traffic first?

Question 5

5Which assumption makes a one-command rollback safe?

0/5 answered

Practice exercises

Try each one yourself first. Use the hint if you get stuck, then compare with the solution.

  1. Exercise 1easy

    Write the evaluation matrix as a table with at least one row per category and the columns it checks.

  2. Exercise 2medium

    Write a redaction function for event dicts that keeps structure but removes sensitive values.

  3. Exercise 3hard

    Write the deployment and rollback guide for the support assistant.

Check yourself

Answer in your head, reveal, then be honest with yourself.

Feel confident about this topic?

Frequently asked questions

Can I finish the capstone without Google Cloud?
Yes. Run the API locally with SQLite sessions and the fake model, and write the Cloud Run steps as a design-only guide. Only the live deployment and live evals need paid services.
How many evaluation cases are enough?
Around 20 to 30 covering every matrix category is enough for this project. Add a case for every bug you find so it cannot come back.
Should the judge model in evals be the same as the agent's model?
It can be, but a separate judge reduces the chance that both share the same blind spots. Record which judge model you used in the report.
What if the previous revision has been deleted?
Then rollback means redeploying the last good commit, which is slower. Keep at least the last two healthy revisions until the new one has run cleanly for a while.

Go deeper

ShareXLinkedInWhatsApp