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

# Build a custom agent image

> Bake skills and Python tools into an image built on the agent base, and choose which built-in tools, including the shell, the agent may use.

A self-hosted agent can run from your own image, built on top of the agent base image. Skills and
Python tools you copy into it load when the agent starts, so they are versioned by the image tag and
built in your CI. Your deployment repository then holds only the chart values. Each Python tool runs
exactly the function you wrote, so an agent can run your code without a shell.

## What goes into the image

The agent reads two folders under `/opt/agentops/agent/` at startup:

| Folder | Holds | Becomes |
| - | - | - |
| `skills/` | One folder per skill with a `SKILL.md` inside, or a flat `<skill-id>.md` file | A skill on the agent, the same as one from the values file |
| `tools/` | Python files (`*.py`) | One tool for each function decorated with `@tool` |

### Skills

A skill in the image uses the same format as any other [skill](https://docs.komodor.com/manage-your-agents/build/skills.md): a
`SKILL.md` with a `name` and a `description` in its frontmatter, and the procedure in the body. The
agent reports the skills it loads to the Komodor Agentic Operation Platform (KAOP). They appear in
the account's Skills library, marked as self-reported.

### Python tools

Each function decorated with the Claude Agent SDK's `@tool` becomes a tool the agent can call. The
decorator takes the tool's name, the description the model reads to decide when to call it, and its
parameters:

```python tools/time_tools.py theme={null}
from datetime import datetime, timezone

from claude_agent_sdk import tool


@tool("get_current_time", "Current UTC time in ISO format", {})
async def get_current_time(args):
    return {"content": [{"type": "text", "text": datetime.now(timezone.utc).isoformat()}]}
```

The tools run inside the agent's own process and are served to it as the `custom` MCP server, so
the agent calls this one as `mcp__custom__get_current_time`. A call runs that function with the
arguments the model passed and returns its result; the model cannot change the code it runs.

* A file in `tools/` can import another file in the same folder by its plain module name, so shared
  helpers can live beside the tools.
* Files whose names start with `_` or `.` are not scanned for tools.
* The agent does not start if two tools share a name, or if a file's name matches a module already
  installed in the image (a `json.py`, for example). Rename the file.
* A `tools/` folder with no `@tool` functions logs a warning and adds no tools.

## Build and deploy the image

**1. Write the Dockerfile**

Start from the agent base image and copy your folders in:

```dockerfile Dockerfile theme={null}
FROM ghcr.io/komodorio/agentops-agent-base:0.1.3401

COPY skills/ /opt/agentops/agent/skills/
COPY tools/ /opt/agentops/agent/tools/
```

Use base image `0.1.3401` or later. Earlier tags do not read these folders.

If a tool needs a Python package the image does not have, install it into the agent's
environment:

```dockerfile theme={null}
RUN pip --python /app/.venv/bin/python install --no-cache-dir humanize==4.12.3
```

**2. Build and push it in CI**

Build the image and push it to a registry your cluster pulls from. Tag each build, for example
with the commit SHA. The tag is the version of the agent's skills and tools.

**3. Point the chart at the image**

Set the image in the agent's `values.yaml`:

```yaml values.yaml theme={null}
image:
  registry: registry.example.com
  repository: platform/payments-triage-agent
  tag: 3f9c2e1
imagePullSecrets:
  - name: my-regcred
```

Install or upgrade with Helm, or let Argo CD or Flux sync the change, the same as any
[self-hosted agent](https://docs.komodor.com/manage-your-agents/build/deploy-a-self-hosted-agent.md). To roll back, set
the previous tag.

**4. Confirm it**

When the new replica comes online, the agent page's **Skills and tools** card lists the baked
skills, marked as self-reported, and `mcp__custom` for the Python tools. A run that calls a
Python tool shows it by name in the run's trace, with its server and its duration.

The values file still configures everything else: instructions, model, MCP servers and skills.
When both define the same thing, the values file wins. A skill from the values file replaces a baked
skill with the same id, and an MCP server named `custom` in the values file replaces the baked
tools. To read the folders from another path, set `AGENTOPS_AGENT_IMAGE_DIR` in the chart's `env`.

> [!WARNING]
>
> Do not copy files into `/etc/agentops/agent`. The chart mounts the agent's configuration there,
> which hides anything the image put in that folder.

To move to a newer agent base, raise the tag in the `FROM` line, rebuild and redeploy. The agent page
shows **Update available** when a newer base is out.

## Choose the built-in tools

Besides its MCP and Python tools, the agent has built-in tools for files, search and the shell. With
nothing set, it gets `Read`, `Glob`, `Grep`, `Edit`, `Write`, `NotebookEdit`, `WebSearch` and
`TodoWrite`, and its file tools work only inside its own working directory. It has no shell: `Bash`,
`PowerShell` and `WebFetch` are off until you grant them.

To set the list, add `AGENTOPS_BUILTIN_TOOLS` to the chart's `env`, comma-separated. The list
replaces the default:

> [tab] Read only
>
> ```yaml values.yaml theme={null}
> env:
>   - name: AGENTOPS_BUILTIN_TOOLS
>     value: Read,Glob,Grep
> ```
>
> The agent can read and search files, call its MCP and Python tools, and nothing else.

> [tab] With a shell
>
> ```yaml values.yaml theme={null}
> env:
>   - name: AGENTOPS_BUILTIN_TOOLS
>     value: Bash,Read,Glob,Grep
> ```
>
> Grant `Bash` only to an agent whose skills run scripts or command-line tools such as `kubectl`.
> Without it, those skills cannot run their commands.

* `Agent` and `Task`, which start sub-agents, are never granted, even when listed.
* Keep `Read` in the list: the agent opens its skills' files with it.
* The agent page's **Skills and tools** card lists the built-in tools the agent has, so you can see
  whether it has a shell.

Python tools in the image run without a shell. For a locked-down agent, put the code it needs in
`tools/` and leave `Bash` out.

## Next steps

> [card] [Deploy a self-hosted agent](https://docs.komodor.com/manage-your-agents/build/deploy-a-self-hosted-agent.md)
>
> Install the agent base chart with Helm.

> [card] [Skills](https://docs.komodor.com/manage-your-agents/build/skills.md)
>
> How skills are versioned, approved and attached.

> [card] [Upgrade a self-hosted agent](https://docs.komodor.com/manage-your-agents/build/upgrade-a-self-hosted-agent.md)
>
> Move an installed agent to the newest release.

> [card] [Using your own image registry](https://docs.komodor.com/manage-your-agents/build/deploy-a-self-hosted-agent.md#using-your-own-image-registry)
>
> Pull images from a registry you run.


## Related topics

- [Upgrade a self-hosted agent](https://docs.komodor.com/manage-your-agents/build/upgrade-a-self-hosted-agent.md)
- [Scale agents to zero](https://docs.komodor.com/manage-your-agents/build/scale-to-zero.md)
- [Deploy a self-hosted agent](https://docs.komodor.com/manage-your-agents/build/deploy-a-self-hosted-agent.md)
- [Agent catalog](https://docs.komodor.com/manage-your-agents/build/catalog/overview.md)
- [Agent marketplace](https://docs.komodor.com/manage-your-agents/build/agent-marketplace.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.