# Connect to your agent

> Register the API Workflow as a tool in your Monster Selector agent and update the agent's input schema.

With the workflow published, it is available in the agent builder as a connectable tool.

## Step 2 - Open the Monster Selector agent

In Studio Web, navigate to your **MonsterSelector** solution and open it in the agent builder.

Take a moment to orient on its current state before making changes:

- **Input:** `questDescription` (string) and `monsters` (array of candidates passed in by the caller)
- **Output:** `monsterIndex` (string): the `key` of the chosen monster, for example `srd_goblin`
- **System prompt:** instructs the agent to pick the best match from the provided list

In this lab you remove the `monsters` input and the requirement to pre-populate candidates. The agent fetches them itself using the tool you just built.

---

## Step 3 - Connect the API workflow as a tool

### Add the tool

Make sure you are on the **Canvas** view: use the **Canvas / Form** toggle at the top of the agent builder. The **+** button under Tools is only visible in Canvas view.

1. On the agent canvas, select **+** under **Tools**.
2. In the **Choose tool** panel, select **API workflow** under **Toolbox**.
3. Under **Available resources**, select the workflow you created in Step 1.

   Your workflow is listed by its **project** name, nested under a `<workspace>/<solution>` folder line - so if you renamed the solution in Step 1, look for `API Query - 5e Monsters`, not the solution name. You can also filter with the **Search API workflows** box above the list.

:::note
**Available resources empty, or showing "No tools found"?** The workflow must be published before it appears here. Return to Step 1 and complete the **Publish to your feed** sub-step, then come back and try again.
:::

![Choose tool panel showing API workflow selected and Available resources list](https://dev-assets.cms.uipath.com/assets/images/getting-started/agents-tools/agents-tools-step-03a-f0f52f96.png)

### Configure the tool description

Give the tool a name and description. The description is what the agent reads at runtime to decide when and how to call the tool; write it as an instruction to the agent, not a label for humans:

- **Name:** `Monster Query`
- **Description:** `Searches the 5e SRD for monsters matching a name or creature type. Returns up to 10 candidates with key, name, type, size, challenge rating, and alignment. Call this tool when you need to find monster candidates for a quest.`

:::note
**The description drives tool selection.** The agent reads this description — not the tool name — to decide when and how to call the tool. A vague description produces vague tool use. Be specific about what the tool returns and when to use it.
:::

---

## Step 4 - Update the agent contract

With the tool connected, update the agent definition to reflect the new contract: the agent no longer needs a pre-populated monster list, and it now returns structured monster data including its own reasoning.

The three changes in this step work together: removing `monsters` ends the agent's dependency on the caller for data; the output schema declares what the agent commits to returning; the updated prompt tells the agent how to use its new capability. None of the three works without the others.

To edit the agent definition, select the agent node on the canvas to open the definition panel on the right.

### Remove monsters from the input

In the agent definition, remove the `monsters` property from the input schema. The updated input should have only `questDescription`.

To remove the `monsters` property:

1. Within the agent, open the **Data Manager** by selecting the **Open Data Manager** icon along the left navbar (it looks like a clipboard).
2. The **Data Manager** panel has three groupings: **Inputs**, **Outputs**, and **Variables**; `monsters` should be in the **Inputs** list.
3. Point to `monsters` to reveal the edit and delete icons to the right of the label: a pencil icon (**edit**) and a trashcan icon (**delete**).
4. Select the delete icon to remove `monsters`.
5. Open the agent's **Properties** panel and remove the now-dangling `monsters` reference from the **User prompt**: select the **x** on the `monsters` chip. The User prompt should be left with only the `questDescription` chip.

:::warning
**Deleting the input does not clear the prompt that references it.** After step 4 the **User prompt** still carries a `monsters` chip, which Studio Web renders in red and flags with an error badge on **Inputs**. The agent will not run until you remove that chip, so do not skip step 5.
:::

You should now only have one input: `questDescription`:

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `questDescription` | string | Yes | Description of the quest |

### Add the output schema

Add an output schema with the five fields from the design table at [What you are building](agents-tools.md#what-you-are-building).

Within the same **Data Manager** panel:

1. Point to the **Outputs** header to reveal the **Add property** icon (+).
2. Select **Add Property** to add each of the fields below:

| Field | Type |
| --- | --- |
| `monsterIndex` | string |
| `monsterName` | string |
| `monsterType` | string |
| `monsterCr` | string |
| `monsterReasoning` | string |

:::note
**`monsterReasoning` is agent-generated, not from the API.** The agent writes this field itself: it is the agent's explanation of why the selected monster fits the quest. Unlike the other four fields (which come from the tool's results), `monsterReasoning` reflects the agent's own judgment.
:::

![Input schema with only questDescription and output schema with five fields configured](https://dev-assets.cms.uipath.com/assets/images/getting-started/agents-tools/agents-tools-step-04a-b4beffb8.png)

### Update the system prompt

To open the **Properties** panel, select the agent on the canvas or select the wrench icon in the upper-right corner. Replace the system message with:

```text
You are a quest classifier for an adventurer's guild. Given a quest description, your job is to find the most thematically appropriate monster from the 5e SRD and to return information about that monster.

When given a quest description:
1. Analyze the quest to determine what kind of creature fits the context - consider creature type, challenge rating, environment, and theme.
2. Call the Monster Query tool with a search term that targets that creature type.
3. Review the returned candidates and select the best fit for the quest.
4. Return the selected monster's key fields and a monsterReasoning that explains why this monster fits the quest.

Always call the Monster Query tool before selecting a monster. Do not guess monster details from memory.
```

:::important
**Coding agents are non-deterministic.** Your prompt will produce different results than the example above; that is expected. What matters is that the agent calls the tool, reasons over the candidates, and returns all five required output fields.
:::

---

With the tool connected and the agent contract updated, you are ready to test the full pipeline in the next section.
