# Write instructions

Change how an agent answers by editing its instructions, which the model reads on every reply: who the agent is, what it helps with and how it replies. In code they are the agent's `system`.

## Before you start

You need an agent. See [Create an agent](/docs/agents/create-agent.md).

## Write instructions

**Studio**

1. In your project, open **Agents**.

2. Click your agent.

3. Click **Edit**.

4. Replace the **Instructions** with:

   ```text
   You are the support assistant for an online shop.
   Help with orders, deliveries and refunds only. For anything else, say you can only help with orders.
   Reply in at most two short sentences, in plain words.
   Refunds reach the customer's card within 5 business days. Never promise sooner.
   End every reply with "Anything else?"
   ```

5. Click **Save**.

6. Open **Chat**.

7. Pick your agent under the message box.

8. Write "Can I get a refund on an order I placed yesterday?" in the message box.

9. Press Enter. You should now see a short reply that says 5 business days and ends with "Anything else?".

**Code**

1. Change the agent's `system`:

```ts title="agents/support.ts" {6-10}
import { agent } from "veryfront/agent";

export default agent({
  id: "support",
  name: "Support assistant",
  system: `You are the support assistant for an online shop.
Help with orders, deliveries and refunds only. For anything else, say you can only help with orders.
Reply in at most two short sentences, in plain words.
Refunds reach the customer's card within 5 business days. Never promise sooner.
End every reply with "Anything else?"`,
});
```

2. Start the project with `npm run dev`.
3. Open **Chat** in Studio.
4. Pick Support assistant.
5. Ask "Can I get a refund on an order I placed yesterday?". You should now see a short reply that says 5 business days and ends with "Anything else?".

### Try it in a sandbox

```playground
step: Create a project | npm create -y veryfront@latest support-desk -- --template ai-agent --yes
step: Change the agent's system | cd support-desk && mkdir -p agents && printf '%s\n' 'import { agent } from "veryfront/agent";' '' 'export default agent({' '  id: "support",' '  name: "Support assistant",' '  system: `You are the support assistant for an online shop.' 'Help with orders, deliveries and refunds only. For anything else, say you can only help with orders.' 'Reply in at most two short sentences, in plain words.' "Refunds reach the customer's card within 5 business days. Never promise sooner." 'End every reply with "Anything else?"`,' '});' > agents/support.ts
step: Start it | npm run dev
agent: support
ask: Can I get a refund on an order I placed yesterday?
expect: 5 business days
```

**API**

1. Set `PROJECT` to your project's ID ([Find your IDs](/docs/authentication/api-keys.md#find-your-ids)): `export PROJECT=<id>`.
2. Replace the instructions of your agent, here `support`, with your [API key](/docs/authentication/api-keys.md). Each `\n` starts a new line:

```bash
curl -X PUT https://api.veryfront.com/projects/$PROJECT/agents/support \
  -H "Authorization: Bearer $VERYFRONT_API_KEY" \
  -H "Content-Type: application/json" \
  --data-binary @- <<'EOF'
{
  "system_prompt": "You are the support assistant for an online shop.\nHelp with orders, deliveries and refunds only. For anything else, say you can only help with orders.\nReply in at most two short sentences, in plain words.\nRefunds reach the customer's card within 5 business days. Never promise sooner.\nEnd every reply with \"Anything else?\""
}
EOF
```

3. Get the agent. You should now see the new instructions in `system_prompt`, ending with `End every reply with \"Anything else?\"`:

```bash
curl https://api.veryfront.com/projects/$PROJECT/agents/support \
  -H "Authorization: Bearer $VERYFRONT_API_KEY"
```

### Try it in a sandbox

```playground
step: Set PROJECT | export PROJECT=$VERYFRONT_PROJECT_ID
step: Before you start: an agent | curl -X POST https://api.veryfront.com/projects/$PROJECT/agents -H "Authorization: Bearer $VERYFRONT_API_KEY" -H "Content-Type: application/json" -d '{"id": "support", "name": "Support assistant", "system_prompt": "Answer customer questions about orders and refunds. Keep replies to two sentences."}'
step: Replace the instructions | curl -X PUT https://api.veryfront.com/projects/$PROJECT/agents/support -H "Authorization: Bearer $VERYFRONT_API_KEY" -H "Content-Type: application/json" -d '{"system_prompt": "You are the support assistant for an online shop.\nHelp with orders, deliveries and refunds only. For anything else, say you can only help with orders.\nReply in at most two short sentences, in plain words.\nRefunds reach the customer'\''s card within 5 business days. Never promise sooner.\nEnd every reply with \"Anything else?\""}'
check: curl https://api.veryfront.com/projects/$PROJECT/agents/support -H "Authorization: Bearer $VERYFRONT_API_KEY"
expect: Anything else?
```

## With MCP

`my-project` is your project's reference: its slug or its ID. Your agent here is `support`; `veryfront__list_agents` lists them.

1. Call `veryfront__update_agent`. The instructions go in `system`:

```json
{
  "project_reference": "my-project",
  "agent_id": "support",
  "system": "You are the support assistant for an online shop.\nHelp with orders, deliveries and refunds only. For anything else, say you can only help with orders.\nReply in at most two short sentences, in plain words.\nRefunds reach the customer's card within 5 business days. Never promise sooner.\nEnd every reply with \"Anything else?\""
}
```

2. Call `veryfront__get_agent_source` with `"agent_id": "support"` and `"project_reference": "my-project"`. It worked when `system_prompt`, the stored `system`, ends with `End every reply with "Anything else?"`.

## Next steps

* [Add a skill](/docs/agents/skills.md)
* [Write an eval](/docs/agents/write-eval.md)
