Agents
An AI agent is an application that can interact with users in natural language. Agents use LLMs to generate responses to user queries and can also execute actions on behalf of the user.
Each agent consists of the following components:
- Agent instructions: A set of instructions that define the agent's behavior and capabilities. This is also called a system prompt.
- Tools: Functions that the agent can use to interact with its environment. Kagent features built-in tools and has support for accessing tools over the MCP.
Agent Instructions
Agent instructions tell the agent what its role is, how to interact with the user, what actions it can take, how to behave and respond to user queries, and how to interact with other agents. Here's an example of simple agent instructions:
You're a Kubernetes agent that can help users manage their Kubernetes resources.Your responses should be clear and concise; you should provide helpful information and guidance to users.
Instructions are an important part of the agent's behavior. They define the agent's role and capabilities and help the agent understand its environment and the tasks it can perform.
Writing good instructions is an art and a science. It requires a good understanding of the task at hand, the tools available, and the user's needs. In order to make it easier to write good instructions, we've created a system prompt tutorial that can help you get started.
Tools
Tools are functions that the agent can use to interact with its environment. For example, a Kubernetes agent might have tools to list pods, get pod logs, and describe services.
Tools definitions and their descriptions are made available to the agent and are sent to the LLMs together with the instructions. Based on the user query, the agent can use the tools to interact with the environment and generate responses.
For example, we could add the list_resources tool to agent that would allow it to list resources in the Kubernetes cluster. The agent will determine based on the user input if it makes sense to invoke any of the available tools.
If the user asks "List all pods in the cluster", the agent can use the list_resources tool to list all pods in the cluster. Note that depending on how the instructions/tools are written and configure, the agent might list all the namespaces first then list all the pods in each namespace. Alternatively, if the list_resources tool allows listing resources across namespaces, the agent will pick that option.
Some tools support additional configuration that can be set in when adding the tool to the agent. For example, any Grafana or Prometheus tools will require an API endpoint URL to be set.
KAgent comes with a set of built-in tools that you can use to interact with your environment. KAgent also supports the MCP (Model Configuration Protocol) tools. Using MCP, you can bring any external tool into kagent and make it available for your agents to run.