> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Adding Instructions to the Agent

> Guidance on writing precise agent instructions that define role, constraints, and tone to produce reliable, focused AI assistants and include output examples and model selection tips.

We're back in `agent.py` with one final field to tighten: the `instruction` string. The model selection, agent name, and description are in place, but the current `instruction` — “Answer the user's questions.” — is too vague. That tiny line often makes the difference between an unpredictable assistant and one that behaves reliably in production.

Below you'll see a weak, default instruction and a stronger alternative. Use the stronger pattern every time you build an agent.

Weak (default) example the prebuilt project gives you:

```python theme={null}
from google.adk.agents import LlmAgent

root_agent = LlmAgent(
    model="gemini-flash-latest",
    name="my_agent",
    description="A helpful assistant.",
    instruction="Answer the user's questions.",
)
```

It works, but it leaves every decision to the model. The assistant will answer anything — from order lookups to creative writing — and that increases the risk of hallucinations, inconsistent tone, or costly token usage.

A stronger instruction performs three specific jobs. Every instruction you write should address these:

* Job 1 — Role: define the assistant’s lane (what it should and should not do).
* Job 2 — Constraints: list hard rules the assistant must follow.
* Job 3 — Tone: two or three words that define the voice.

Concise, strong instruction example (inline or triple-quoted):

```python theme={null}
from google.adk.agents import LlmAgent

root_agent = LlmAgent(
    model="gemini-flash-latest",
    name="my_agent",
    description="Customer support assistant for ExampleStore.",
    instruction="""
Role: Support assistant for an online store.

Rules:
1. Keep replies short.
2. Never invent order details.
3. If no order number is provided, ask for one.
4. Refunds must be handled by a human.

Tone: friendly, clear, patient.
""",
)
```

Why this works

* Role keeps the agent focused (it should politely decline unrelated tasks).
* Constraints prevent dangerous behavior (e.g., hallucinating order statuses).
* Tone enforces a consistent voice across responses.

When you need a specific output shape, show it. A tiny example inside the instruction beats long prose. For instance, include a minimal JSON response example so the agent learns the exact format you expect.

When you require a strict output format, include a minimal, exact example inside the instruction or the prompt. Even a one-line JSON example helps the model produce predictable, parseable responses.

Example of a minimal JSON example you might include:

```json theme={null}
{ "order": "A1001", "status": "shipped" }
```

Quick reference: the three instruction jobs

| Job | Purpose | Example snippet |
| - | - | - |
| Role | Narrow the agent’s domain | `Role: Support assistant for an online store.` |
| Constraints | Hard rules to prevent errors | `Rules: 1. Keep replies short. 2. Never invent order details.` |
| Tone | Voice and brevity | `Tone: friendly, clear, patient.` |

Choosing the right model tier

* Gemini Flash (fast, inexpensive): handle routing, short conversations, and many common agents. Start here.
* Gemini Pro (slower, costlier): use for heavy multi-step reasoning, complex planning, or when Flash isn’t sufficient.

Match the model to the hardest task the agent must handle — not the average task. Most agents are fine on Flash; move to Pro only when you see consistent failure modes that require deeper reasoning.

![A dark-themed slide titled "Flash or Pro" showing a comparison table: Flash (fast and cheap, follows instructions, routes to tools, short conversations) versus Pro (slower, costs more, reasons harder, multi-step planning, tricky judgment calls). A highlighted tip at the bottom reads "Match the model to the hardest thing — not the average thing."](https://mintcdn.com/kodekloud-c4ac6d9a/heceQKBf52UJgxP-/images/Google-ADK-20/Fundamentals-of-Google-ADK/Adding-Instructions-to-the-Agent/flash-or-pro-model-comparison-tip.jpg?fit=max\&auto=format\&n=heceQKBf52UJgxP-\&q=85\&s=fe9e7d1180c829c7136a58a89ebfea6e)

Final checklist before you ship an agent

* Have a single-line Role.
* List concise, enforceable Constraints.
* Specify Tone in two or three words.
* Include an exact output example when format matters.
* Start with Flash; only upgrade to Pro when necessary.

Read your instruction string out loud. If it clearly states the agent’s role, rules, and voice, you’re done — the runtime now has a focused, predictable assistant to run in production.

> [card] [Watch Video](https://learn.kodekloud.com/user/courses/google-adk-2-0/module/1d143913-38fb-4a53-8976-041e503dbf12/lesson/af4153c7-523c-4e11-ae2d-2b74e6c65a43)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.