Skip to content

Build an agent

Page as Markdown

Create a personal assistant agent in the kagent UI, then make its behavior reusable with a shared template.

Build an agent

Create a personal assistant agent in the kagent UI, then make its behavior reusable with a shared template.

About this tutorial

Build your first agent in the kagent UI: a personal assistant that you create from one form. Then turn its behavior into a shared template that other agents can reuse.

An agent has two halves. A template describes what the agent does: its model, its system prompt, and its tools. A harness describes where and how the agent runs. kagent install creates a kagent-default harness for you, so the first agent needs only the template half.

For how templates, harnesses, and agents fit together, see About agents. To build the same kind of agent from YAML and the CLI instead, see Your first agent.

Time: about 10 minutes.

Before you begin

  1. Install kagent.

Build the agent

Follow the steps in the kagent UI, or apply the same resources as YAML from the command line.

Open the kagent UI

kagent dashboard

The command forwards the UI to http://localhost:8082 and opens it in your browser. Leave it running while you work.

Create a personal assistant

The kagent UI creating an agent named personal-assistant with an inline template, then opening its chat page
Figure: Creating the personal-assistant agent in the UI, sped up
  1. In the sidebar, click Agents, and then click New Agent.

  2. In the Name field, enter personal-assistant. Leave the Namespace as kagent.

  3. In the Harness section, leave Shared harness set to kagent-default.

  4. In the Template section, select Inline. An inline template belongs to this agent only, which is the shortest path to a working agent.

  5. Fill in the template.

    FieldValue
    Model configurationkagent/default-model-config, the model that the installation set up from your API key.
    DescriptionMy personal assistant
    System promptYou are my personal assistant. Be friendly and concise. Help me plan my day, draft messages, and answer questions.

    Leave the other fields as they are. You add tools in Add an MCP server.

  6. Click Create agent. The UI returns to the Agents list, where the agent shows the Preparing status while kagent builds a snapshot of its runtime.

  7. Click Refresh until the status changes to Ready. This step usually takes less than a minute.

  8. Click the agent name, personal-assistant, to open its chat page. Enter a message, such as What can you help me with?, and click Send. Each chat that you start is a Session with the agent.

Make the behavior reusable

The personal assistant keeps its behavior inline, so no other agent can use it. A shared template holds the same settings as an object of its own. Every agent that references the template gets its model, prompt, and tools, and a change to the template reaches all of them.

The kagent UI creating an agent template named assistant-template, then an agent named team-assistant that references it
Figure: Creating a shared template and an agent that references it, sped up
  1. On the Agents page, click New Template.

  2. Fill in the template, and then click Create template.

    FieldValue
    Nameassistant-template
    Model configurationkagent/default-model-config
    DescriptionA friendly, concise assistant
    System promptYou are a personal assistant. Be friendly and concise. Help plan the day, draft messages, and answer questions.

    The template is listed on the Templates tab of the Agents page.

  3. Click New Agent, and enter team-assistant in the Name field.

  4. In the Template section, leave Reference selected, and choose assistant-template from the Shared template list.

  5. Click Create agent, and then click Refresh until the agent is Ready.

The Agents list now shows both agents. The Template column reads Inline for personal-assistant and assistant-template for team-assistant.

Harnesses

Both agents run on the kagent-default harness. A harness sets the runtime that compiles and runs a template, the image, and the worker pool that the agent’s sessions are scheduled on. kagent install also creates the codex-default and claude-default harnesses, which run a template on those runtimes.

To create a harness of your own, click New Harness on the Agents page. For the options, see Agent harness.

Verify the agents

  1. Check that both agents are ready.

    kubectl get agent personal-assistant team-assistant -n kagent

    Example output:

    NAME                READY   AGE
    personal-assistant  True    2m
    team-assistant      True    2m
    
  2. Check that the shared template exists.

    kubectl get agenttemplate assistant-template -n kagent
  3. In the kagent UI, click the name of each agent, and send it a message. Both answer in the same friendly, concise style.

What you built

Two agents: one that keeps its behavior inline, and one that takes it from a shared template. Along the way, you used these features:

FeatureWhat you didRead more
Agents and inline templatesCreated an agent whose model and prompt live in the Agent itselfAbout agents
Shared AgentTemplatesMoved the behavior into a template that several agents referenceCore concepts
HarnessesRan both agents on the kagent-default harnessAgent harness

Clean up

The next tutorials, such as Add an MCP server and Schedule an agent, reuse the personal-assistant agent. Keep it if you go on to them.

  1. Delete the agent that references the template, and then the template.

    kubectl delete agent team-assistant -n kagent
    kubectl delete agenttemplate assistant-template -n kagent
  2. Optional: Delete the personal assistant.

    kubectl delete agent personal-assistant -n kagent

Next steps