Skip to main content
System prompts define an agent’s task, response style, and behavioral boundaries. Set Agent.instruction to fixed text, a template that reads session state, or a function that builds instructions from the current context Complete installation and model configuration before running these examples. Save each script with the indicated filename and run it with python filename.py

Static prompts

Use a string for a fixed task. Specify the task, information to clarify, and data the agent must not request
main.py
The script prints a response to the billing question. The exact wording depends on the model

Dynamic prompts

Use session state

A {name} placeholder in a string instruction reads the matching key from session state. This example creates the session with an initial name and language before running the agent
state_prompt.py
A state value of None also becomes an empty string. Tools and other agents can update state during a run. See session management

Use an InstructionProvider

Pass a function to instruction when you need defaults, conditional logic, or several state values. The function receives a ReadonlyContext and returns a string. Async functions defined with async def are also supported
dynamic_prompt.py
context.state is read-only. Other useful fields include user_id, user_content, session, and agent_name. Placeholders in a function’s return value are not automatically substituted: build the string in the function. To reuse ADK template substitution, call await inject_session_state(template, context) from an async function, importing it from google.adk.utils.instructions_utils

instruction and description

Give each agent specific instructions and a concise description in a multi-agent application. To maintain prompts in an external service, see prompt management
Last modified on September 19, 2026