tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Agentic AI > ADK Agent Testing > Testing ADK Agent Artifacts and File Handling

Testing ADK Agent Artifacts and File Handling

Author: Venkata Sudhakar

ShopMax India uses ADK agents to generate and handle file artifacts: PDF invoices, warranty certificates, and CSV order exports attached to customer sessions. Testing artifact handling ensures the agent correctly stores generated files, retrieves them by name, enforces size and type limits, and cleans up temporary files after the session ends - preventing storage bloat and accidental data exposure across sessions.

ADK artifact handling involves saving binary or text content to a session-scoped store and retrieving it by artifact ID or filename. In tests, use an in-memory artifact store backed by a plain dict. Assert that save operations record the correct content and metadata, that retrieval returns the exact bytes saved, and that attempts to access artifacts from other sessions are rejected. Clean-up tests verify that the store is empty after session teardown.

The example below implements a minimal in-memory artifact store for ShopMax India. Tests cover saving an invoice PDF, retrieving it by name, rejecting cross-session access, and verifying the store clears on session end.


It gives the following output,

... (3 passed in 0.01s)

In production, ShopMax India should back the artifact store with Google Cloud Storage and use signed URLs with short expiry times for customer downloads so that invoice PDFs are never publicly accessible. Enforce a maximum artifact size of 10MB per file and a maximum of 20 artifacts per session to prevent storage abuse. Run a nightly cleanup job to purge artifacts older than 30 days and alert if storage usage grows faster than expected between Diwali and Republic Day sale periods.


 
  


  
bl  br