tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Generative AI > Google Gemini API > ADK Dynamic Instruction Injection

ADK Dynamic Instruction Injection

Author: Venkata Sudhakar

ADK agent instructions are typically defined at construction time and remain static across all sessions. Dynamic instruction injection is the pattern of building the instruction string at runtime from session context - customer tier, preferred language, active promotions, and regional settings - so the same agent code behaves differently for different users without maintaining separate agent instances.

ShopMax India serves three customer tiers (Silver, Gold, Platinum) and two languages (English and Hindi). Platinum customers get priority service messaging and exclusive offer visibility. Hindi-speaking customers get responses with appropriate language cues. Active promotions in specific cities get injected so the agent always references current deals without prompt engineering for every campaign.

The below example shows how to build a dynamic instruction factory that personalises a ShopMax India agent based on customer profile at session start.


It gives the following output,

Agent instructions built for Rahul (Silver) and Priya (Platinum).

Rahul instruction preview:
  "You are a ShopMax India customer service agent.
   Customer: Rahul (ID: CUST-12345) | Tier: SILVER
   Standard ShopMax India customer. Offer standard pricing and delivery options.
   Respond in clear English. City: Bangalore."

Priya instruction preview:
  "You are a ShopMax India customer service agent.
   Customer: Priya (ID: CUST-88821) | Tier: PLATINUM
   Highest priority. Offer exclusive deals, free express delivery...
   Active promotions for Mumbai: 20% off Samsung TVs, Free installation on ACs."

The below example shows both customer agents responding to the same product query, demonstrating how dynamic instructions produce personalised responses from a single agent codebase.


It gives the following output,

--- Rahul (SILVER) ---
Hi Rahul! Great choice - the Samsung 55" QLED TV is one of our best sellers.
It is priced at Rs 89,999 with standard delivery to Bangalore in 3-4 days.
Would you like to know more about our EMI options?

--- Priya (PLATINUM) ---
Namaste Priya! As a valued Platinum member, you are in luck!
We currently have 20% off Samsung TVs in Mumbai - bringing the 55" QLED TV
down to Rs 71,999 exclusively for you, with FREE express delivery.
Your dedicated Platinum support line (1800-SHOPMAX-PLAT) can arrange
complimentary installation. Shall I reserve one for you?
Dhanyavaad!

Dynamic instruction injection lets ShopMax India run a single agent codebase that personalises behaviour for thousands of customer profiles. Tier upgrades, new city promotions, and language preferences all reflect immediately in agent responses without redeployment. The pattern also makes A/B testing straightforward - two instruction variants can be injected for different customer segments and response quality compared directly.


 
  


  
bl  br