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

# Example: Creating Custom Agents

<Info>We strongly recommend that highly technical users (examples: IT professionals, software developers, or system administrators) perform the steps outlined in this process.</Info>

<Note>Third-party products, such as OpenAI's API, come with their own terms and conditions.</Note>

The following example uses ChatGPT-4o to automatically update classifications in Encord each time the Agent triggers. The example uses [FastAPI](https://fastapi.tiangolo.com/) as a server to host and run the code. The server returns an empty 200 response, indicating that the request has succeeded and causing the Label Editor to refresh.

<Note>Only HTTPS endpoints are supported.</Note>

## Agent Configuration Parameters

When creating your Custom Agent, you can configure various parameters through the agent creation form. The form supports different input types based on your configuration schema:

* **Text fields**: For simple string values like API keys or model names
* **Number fields**: For numeric values like thresholds or confidence scores
* **Dropdown menus**: For selecting from predefined options
* **Checkboxes**: For boolean true/false settings
* **Tag inputs**: For array-type parameters where you can enter comma-separated values (e.g., language codes, feature flags)
* **Sliders**: For numeric ranges with minimum and maximum values
* **Text areas**: For longer text inputs like prompts or descriptions

<Tip>For array-type configuration parameters, use the tag input field to enter multiple values separated by commas. For example, you can enter "en,es,fr" for language codes.</Tip>

The following example shows how to create a simple Task Agent to change the priority of each task before moving it to the next stage of the Workflow.

<Tip>
  We also provide more detailed [Task Agent examples](/agents-documentation/Task-Agents/Task-Agent-Examples) and [Custom Agent examples](/agents-documentation/Custom-Agents/Examples/GCP-Examples).
</Tip>

## 1. Create Encord Project

Create a [Project in Encord](/platform-documentation/GettingStarted/gettingstarted-create-project) containing the following Workflow with an [agent stage](/platform-documentation/Annotate/annotate-projects/annotate-workflows-and-templates#agent).

![Project Workflow](https://storage.googleapis.com/docs-media.encord.com/Agents/project-workflow.png)

The purple node in the Workflow is an agent node named `pre-label`. It has a single pathway called `annotate` that moves tasks to the next stage in the Workflow.

Copy the `Project ID` in the top left of the Project page.

<Tip>
  Check if your existing Project has any agent nodes by running the following command.

  <CodeGroup>
    ```shell Command theme={"dark"}
    encord-agents print agent-nodes <your_project_hash>
    ```

    ```shell Example Output theme={"dark"}
    AgentStage(title="pre-label", uuid="b9c1363c-615f-4125-ae1c-a81e19331c96")
    AgentStage(title="evaluate", uuid="28d1bcc9-6a3a-4229-8c06-b498fcaf94a0")
    ```
  </CodeGroup>
</Tip>

## 2. Define the Agent

In the directory you created for your agents, create a Python file. In this example we use `agent.py`.

Copy paste the following template in to the Python file:

```python title="agent.py" theme={"dark"}
from encord.objects import LabelRowV2
from encord_agents.tasks import Runner

runner = Runner(project_hash="<your_project_hash>")

@runner.stage(stage="pre-label")
def my_agent_logic(lr: LabelRowV2) -> str:
    # ...
    return "annotate"

if __name__ == "__main__":
    runner.run()
```

The `my_agent_logic` function takes a `LabelRowV2` instance belonging to a task currently in the `"pre-label"` agent stage. The agent then returns the name of the pathway the task should follow once completed.

We must define how this data is handled. In this example, we keep it simple by assigning priority based on the file name. If the file name contains `"london"`, it gets assigned a high priority; otherwise, it gets assigned low priority.

```python theme={"dark"}
@runner.stage(stage="pre-label")
def my_agent_logic(lr: LabelRowV2) -> str:
    lr.set_priority(priority=float("london" in lr.data_title))
    return "annotate"
```

## 3. Run the Agent

The Agent must be run in order for tasks to be moved on to the next Workflow stage.

Run the agent by executing the following command:

```shell theme={"dark"}
python agent.py
```
