# Build a custom sub-agent with instructions

Create a managed HR agent with a narrow policy sub-agent, test delegation in the playground and see the cost land on the parent.

## Prerequisites

- A running Liyagent instance with one LLM provider configured.

## Steps

1. Open **All agents** → **+ Create agent** and choose **Managed by Liyagent**. Name it `HR helper`. The agent ID shown under the name becomes `hr-helper`. Under **Tags**, enter `team=hr`.
2. Pick a provider and model under **Model**, then write the **Instructions**:

   ```markdown
   You help employees of {tenant} with HR questions. Today is {date}.
   - Answer briefly and point to the policy section you used.
   - For anything about leave balances or pay, delegate to the policy specialist.
   - Never discuss another employee.
   ```

3. Choose **Create agent**, then **Start** on the agent's page.
4. On the agent's **Settings** tab, under **Subagents**, choose **Add subagent** and name it `leave-policy`:

   | Field | Value |
   | --- | --- |
   | Description | Answers questions about annual leave, sick leave and parental leave rules. Use for any question about days off. |
   | Instructions | Answer only from the leave policy. Quote the rule. If unsure, say so. |
   | Model override | A smaller, cheaper model |

5. Save. Open the **Playground** tab and ask: `How many days of parental leave can I take?`
6. Choose **Trace** on the answer: you'll see the parent's call, a `delegate` to `leave-policy`, and the child's call on the cheaper model.
7. Open the agent's **Cost & Usage** tab: the child's calls are recorded with the delegation chain that names `hr-helper` as the parent.

> [!NOTE]
> Sub-agents cannot delegate further, and a delegation past the parent's **Delegation depth** is refused.

## Next steps

- [Sub-agents](/docs/agents/sub-agents)
- [Set a budget and watch the fallback](/docs/labs/budget-fallback)
