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

# Create an Agent from Scratch

Creating an agent from scratch gives you full control over every configuration setting — the agent's profile, behavior instructions, tools, and knowledge sources.

To begin: open your agentic app → **Agents** section → **+ New Agent** → **Create from Scratch**.

***

## Step 1: Set Up the Agent Profile

The agent profile establishes the agent's identity and purpose. The orchestrator uses the name and description to route incoming tasks to the most suitable agent.

### Name

Choose a unique, descriptive name that reflects the agent's core function.

```
Good                          Avoid
────                          ─────
Order Manager                 Agent 1
Leave Manager                 Helper
Credit Card Assistant         Bot
```

### Description

Write a description that tells the orchestrator when to route requests to this agent. Be specific about the agent's responsibilities and what differentiates it from other agents in the application.

```
Good:  Manages all user requests related to order status, returns, and
       refunds. Handles order lookups by order number, email, or phone.

Weak:  Helps with orders.
```

### Avatar

Select an avatar from the available list of logos and icons. The avatar identifies the agent visually in the user interface.

### AI Model

Select the AI model and connection the agent will use for reasoning, tool calling, and generating responses.

| Use case             | Recommended model              |
| -------------------- | ------------------------------ |
| Complex reasoning    | GPT-4, Claude 3 Opus           |
| Fast responses       | GPT-3.5-turbo, Claude 3 Haiku  |
| Code generation      | GPT-4, specialized code models |
| Cost-sensitive tasks | Smaller models                 |

Click the **settings** icon next to the model selector to configure model generation parameters such as temperature and max tokens. For setup instructions, see [External Models](/agent-platform/models/external-models).

### Context Window Limit

Set the maximum number of messages the agent retains in its conversation context. When the limit is reached, older messages are automatically removed.

| Messages | Use case                         |
| -------- | -------------------------------- |
| 25       | Simple Q\&A, transactional tasks |
| 50       | Standard conversations (default) |
| 100      | Multi-step processes             |
| 200      | Complex, long-running workflows  |

***

## Step 2: Write the Agent Definition

The agent definition is the system prompt. It describes the agent's role, the tasks it can perform, and the rules it must follow. Well-structured instructions ensure the agent responds consistently and operates within its intended scope.

The definition editor supports:

* **Rich text formatting** for structured instructions
* **Dynamic variables** to reference memory fields, tools, and other agents at runtime — for example, `{{memory.sessionMeta.metadata.FLAG}}`
* **AI-assisted authoring** to generate, refine, and organize instructions

### Structure Your Instructions

Use clearly labeled sections to organize the definition:

```markdown theme={null}
## Role
Who is this agent and what is their purpose?

## Guidelines
How should the agent behave and respond?

## Response Format
How should responses be structured?

## Constraints
What should the agent never do?
```

**Define scope boundaries** to help the orchestrator route edge cases correctly:

```markdown theme={null}
### Out of Scope
- Payment processing and refunds (→ Billing Agent)
- Product recommendations (→ Sales Agent)
- Technical product support (→ Tech Support Agent)
```

### Example: Order Manager

```markdown theme={null}
## Role
You are an AI agent responsible for enabling users to access real-time
order updates and manage their orders independently.

## Guidelines

### Order Status Inquiry
Provide updates on order status using the order lookup tool.

### Return Management
Verify return eligibility, guide users through the return process,
initiate returns, and provide information on return policies.

### Refund Enquiry
Provide refund status and address refund-related queries.

## Constraints
Always get confirmation from the user before performing any transaction.
```

***

## Step 3: Add Tools

Tools are the functional extensions of an agent's intelligence. They enable the agent to fetch data from external systems, execute custom logic, and trigger workflows.

Agent Platform supports three tool types:

| Type               | Best for                                                                     | Execution      |
| ------------------ | ---------------------------------------------------------------------------- | -------------- |
| **Workflow Tools** | Visual, no-code workflows for standardized and repeatable processes          | Sync and async |
| **Code Tools**     | Custom logic in JavaScript or Python for complex or dynamic operations       | Sync           |
| **MCP Tools**      | Remote functions on Model Context Protocol servers for external integrations | Sync           |

### Adding a New Tool

1. In agent configuration, go to **Tools** → **+ New Tool**
2. Select the tool type: **Workflow Tool**, **Code Tool**, or **MCP Tool**
3. Enter a name and description, then click **Create**
4. Open the tool to define its logic or connection details

Write the tool description carefully — the LLM uses it to decide when and how to invoke the tool.

**Workflow Tool:** Design the flow using the visual builder. See [Workflow Tools](/agent-platform/tools/workflow).

**Code Tool:** Write JavaScript or Python logic directly. See [Code Tools](/agent-platform/tools/code).

**MCP Tool:** Connect to an MCP server and select available tools. See [Configure an MCP Server](/agent-platform/tools/mcp#configure-mcp-tools).

### Importing an Existing Tool

Import tools from the shared library to accelerate development and reuse existing logic.

| Source          | Description                                     |
| --------------- | ----------------------------------------------- |
| **File**        | Import a previously exported tool (JSON format) |
| **Library**     | Use tools from the platform's shared repository |
| **Marketplace** | Access tools from the publicly shared catalog   |

Imported tools are scoped to the app. Customizing an imported tool does not affect the original source or other apps using it.

### Testing a Tool

Verify a tool's behavior before using it in production:

1. Navigate to the **Tools** page of the application
2. Select the tool to open its details view
3. Use the **Test Execution** interface to run the tool.
4. Provide sample values in the input fields, and select **Execute**.
5. View the results under **Test Results** in JSON format. The Logs tab under Test Results presents the execution logs from the tool.

***

## Step 4: Add Knowledge

Link knowledge sources to enable RAG-based responses grounded in your enterprise content. The Platform uses the **Search AI** application to power search across connected knowledge bases.

### Connecting a Knowledge Source

1. In agent configuration, go to **Knowledge** → **+ Connect Knowledge**
2. Select an existing Search AI application or create a new one

You can link one or more Search AI applications from the same workspace. Each Search AI app can connect to multiple content sources.

### Supported Sources

| Source      | Best for                      |
| ----------- | ----------------------------- |
| Documents   | Policies, guides, FAQs        |
| Web crawler | Website content, help centers |
| Confluence  | Internal documentation        |
| SharePoint  | Enterprise content            |
| Custom API  | Dynamic data sources          |

See [Knowledge Integration](/agent-platform/knowledge) for configuration details.

***

## Step 5: Configure Delegation

**Applies to:** Apps using the **Adaptive Network** orchestration pattern only.

Delegation rules define how this agent routes tasks to other agents within the application. If the app uses a different orchestration pattern, this section is not required and won't appear in the UI.

### Delegation Settings

**Direct Responses** — Controls whether this agent communicates with the user directly:

* **Enabled** — The agent sends responses directly to the user
* **Disabled** — The agent passes responses to another agent for further processing

**Task Delegation** — Defines routing rules for handing off tasks to other agents:

1. Click **Add Delegation**
2. From **Delegate To**, select the target agent
3. Define the condition that triggers the handoff

Add all delegation rules this agent can use for routing.

### Passing Context Between Agents

When control passes from one agent to another, the application saves context — including summaries and pending tasks — to `sessionMeta` memory under the `delegationContext` field. The receiving agent accesses this field to continue the task seamlessly.

Agents can also use **custom memory stores** to share task-specific data during handoffs.

### Event-Based Delegation

If a delegation rule is triggered by an event, subsequent handling follows that event's configuration. For example, an agent handoff event configured to escalate to a human agent via AI for Service will trigger the handoff process accordingly.
