# AgentProfile

An agent of the organisation's Belai library: the markdown agent definition Belai writes, and the files the agent uses beside it.

An agent of the organisation's Belai library: the markdown agent definition Belai writes, and the files the agent uses beside it. The profile is identified by the id in the definition's front matter, so the same agent backed up from a host and declared here is one profile, and that id cannot change under a metadata.name. Every apply that changes it saves a new version, as a save in the console does; deleting the document hides the profile and keeps its versions and files. A profile nobody declared is exported under its name.

| | |
|---|---|
| `apiVersion` | `vulnetix.com/v1` |
| `kind` | `AgentProfile` |
| Group | [AI libraries](/platform-iac/kinds/catalogue.md#ai-libraries) |
| Status | **Served.** The [config engine](/platform-iac/reference/engine.md) plans and applies it. |
| Objects per tenant | many, keyed by `metadata.name` |
| Token and role | An owner, or a service account with the developer role (its ApiKey), or an Authentik access token for either. A member is refused with HTTP 403. See [Credentials for automation](/platform-iac/reference/config-api.md#credentials-for-automation). |
| Terraform resource | [`vulnetix_agent_profile`](/platform-iac/terraform/resources.md#vulnetix_agent_profile), imported by name (see [Terraform and OpenTofu](#terraform-and-opentofu)) |
| CLI | [`vulnetix config apply`](/platform-iac/cli/apply.md), CLI v3.168.0 and later. |
| Pinned schema | [`v1.19.1/AgentProfile.schema.json`](https://github.com/Vulnesis/config-schemas/releases/download/v1.19.1/AgentProfile.schema.json) |
| Newest schema | [`latest/AgentProfile.schema.json`](https://github.com/Vulnesis/config-schemas/releases/latest/download/AgentProfile.schema.json) |
| First released in | [`v1.6.0`](https://github.com/Vulnesis/config-schemas/releases/tag/v1.6.0) |
| Print the built-in copy | `vulnetix config schema AgentProfile` |

## Minimal

Only the fields the kind requires. From `examples/AgentProfile/minimal.yaml`.

**YAML**

```yaml
# yaml-language-server: $schema=https://github.com/Vulnesis/config-schemas/releases/latest/download/AgentProfile.schema.json
apiVersion: vulnetix.com/v1
kind: AgentProfile
metadata:
  name: reviewer
spec:
  body: |
    ---
    id: 6f1c2b8a-3d4e-4f5a-9b6c-7d8e9f0a1b2c
    name: reviewer
    ---
    You review pull requests for correctness and security.
```

**HCL** (resource `vulnetix_agent_profile`)

```hcl
# Only the arguments the kind requires. From config-schemas examples/AgentProfile/minimal.yaml.

resource "vulnetix_agent_profile" "reviewer" {
  name = "reviewer"
  body = "---\nid: 6f1c2b8a-3d4e-4f5a-9b6c-7d8e9f0a1b2c\nname: reviewer\n---\nYou review pull requests for correctness and security.\n"
}
```

Every field that has a schema default, set to that default: [`terraform/agent_profile.tf`](https://github.com/Vulnesis/platform-iac-examples/blob/main/terraform/agent_profile.tf) and [`yaml/AgentProfile.yaml`](https://github.com/Vulnesis/platform-iac-examples/blob/main/yaml/AgentProfile.yaml) in [Vulnesis/platform-iac-examples](https://github.com/Vulnesis/platform-iac-examples).

**CLI** (applies it)

```bash
export VULNESIS_ORG_ID=...    # the organization UUID
export VULNESIS_API_KEY=...   # the ApiKey of a developer or owner service account
vulnetix config apply -f - --manager gitops:acme/platform --auto-approve <<'EOF'
# yaml-language-server: $schema=https://github.com/Vulnesis/config-schemas/releases/latest/download/AgentProfile.schema.json
apiVersion: vulnetix.com/v1
kind: AgentProfile
metadata:
  name: reviewer
spec:
  body: |
    ---
    id: 6f1c2b8a-3d4e-4f5a-9b6c-7d8e9f0a1b2c
    name: reviewer
    ---
    You review pull requests for correctness and security.
EOF
```

## Advanced

Every field the kind supports, with a `when` expression where it takes one. From `examples/AgentProfile/advanced.yaml`.

**YAML**

```yaml
# yaml-language-server: $schema=https://github.com/Vulnesis/config-schemas/releases/latest/download/AgentProfile.schema.json
apiVersion: vulnetix.com/v1
kind: AgentProfile
metadata:
  name: security-reviewer
  labels:
    team: appsec
spec:
  body: |
    ---
    id: 0b7e4d2c-9a1f-4c3e-8d5b-2f6a7e8c9d01
    name: security-reviewer
    display_name: Security reviewer
    palette: ["#0f172a", "#1e293b", "#38bdf8", "#f8fafc"]
    ---
    You review pull requests for injection, authorization and secrets
    handling, and cite the checklist in checklists/review.md.
  files:
    - path: checklists/review.md
      body: |
        - Inputs are validated at the boundary.
        - Every route checks the caller's role.
    - path: checklists/secrets.md
      file: agents/security-reviewer/secrets.md
---
# yaml-language-server: $schema=https://github.com/Vulnesis/config-schemas/releases/latest/download/AgentProfile.schema.json
apiVersion: vulnetix.com/v1
kind: AgentProfile
metadata:
  name: release-notes
spec:
  file: agents/release-notes.md
```

**HCL** (resource `vulnetix_agent_profile`)

```hcl
# Every argument the kind supports. From config-schemas examples/AgentProfile/advanced.yaml.

resource "vulnetix_agent_profile" "security_reviewer" {
  name = "security-reviewer"
  body = "---\nid: 0b7e4d2c-9a1f-4c3e-8d5b-2f6a7e8c9d01\nname: security-reviewer\ndisplay_name: Security reviewer\npalette: [\"#0f172a\", \"#1e293b\", \"#38bdf8\", \"#f8fafc\"]\n---\nYou review pull requests for injection, authorization and secrets\nhandling, and cite the checklist in checklists/review.md.\n"
  files = [
    {
      body = "- Inputs are validated at the boundary.\n- Every route checks the caller's role.\n"
      path = "checklists/review.md"
    },
    {
      file = "agents/security-reviewer/secrets.md"
      path = "checklists/secrets.md"
    },
  ]
  labels = {
    team = "appsec"
  }
}

resource "vulnetix_agent_profile" "release_notes" {
  name = "release-notes"
  file = "agents/release-notes.md"
}
```

Every field that has a schema default, set to that default: [`terraform/agent_profile.tf`](https://github.com/Vulnesis/platform-iac-examples/blob/main/terraform/agent_profile.tf) and [`yaml/AgentProfile.yaml`](https://github.com/Vulnesis/platform-iac-examples/blob/main/yaml/AgentProfile.yaml) in [Vulnesis/platform-iac-examples](https://github.com/Vulnesis/platform-iac-examples).

**CLI** (applies it)

```bash
export VULNESIS_ORG_ID=...    # the organization UUID
export VULNESIS_API_KEY=...   # the ApiKey of a developer or owner service account
vulnetix config apply -f - --manager gitops:acme/platform --auto-approve <<'EOF'
# yaml-language-server: $schema=https://github.com/Vulnesis/config-schemas/releases/latest/download/AgentProfile.schema.json
apiVersion: vulnetix.com/v1
kind: AgentProfile
metadata:
  name: security-reviewer
  labels:
    team: appsec
spec:
  body: |
    ---
    id: 0b7e4d2c-9a1f-4c3e-8d5b-2f6a7e8c9d01
    name: security-reviewer
    display_name: Security reviewer
    palette: ["#0f172a", "#1e293b", "#38bdf8", "#f8fafc"]
    ---
    You review pull requests for injection, authorization and secrets
    handling, and cite the checklist in checklists/review.md.
  files:
    - path: checklists/review.md
      body: |
        - Inputs are validated at the boundary.
        - Every route checks the caller's role.
    - path: checklists/secrets.md
      file: agents/security-reviewer/secrets.md
---
# yaml-language-server: $schema=https://github.com/Vulnesis/config-schemas/releases/latest/download/AgentProfile.schema.json
apiVersion: vulnetix.com/v1
kind: AgentProfile
metadata:
  name: release-notes
spec:
  file: agents/release-notes.md
EOF
```

## Fields

Paths use dots for nesting and `[]` for the items of a list. **Required** means required whenever the parent object is present. A default is what the server uses when the field is left out.

| Field | Type | Required | Default | Allowed values | Description |
|---|---|---|---|---|---|
| <span id="apiVersion"></span>`apiVersion` | string | yes |  | exactly `vulnetix.com/v1` | The document format version. Every kind in this release is vulnetix.com/v1. |
| <span id="kind"></span>`kind` | string | yes |  | exactly `AgentProfile` | Always AgentProfile. |
| <span id="metadata"></span>`metadata` | object | yes |  | no other keys |  |
| <span id="metadata-name"></span>`metadata.name` | string | yes |  | pattern `^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$` | The object's name, unique per kind within a tenant. It is the natural key: plan, apply, export and the Terraform provider all address an object by kind and name. |
| <span id="metadata-org"></span>`metadata.org` | string | no |  | format `uuid` | The tenant (organization UUID) the document belongs to. When set, plan and apply refuse to run against any other tenant. |
| <span id="metadata-labels"></span>`metadata.labels` | object | no |  | map of string to string (length 0 to 256); keys match `^[a-z0-9]([a-z0-9._/-]{0,61}[a-z0-9])?$` | Free key/value labels. Stored with the object, never interpreted by the server. |
| <span id="metadata-annotations"></span>`metadata.annotations` | object | no |  | map of string to string (length 0 to 4096) | Free key/value notes for people and tools, such as a ticket link. |
| <span id="spec"></span>`spec` | object | yes |  | no other keys |  |
| <span id="spec-body"></span>`spec.body` | string | no |  | length 1 to 65536 | The agent definition: markdown with front matter between --- lines, holding id (a lower-case UUID) and name, and optionally display_name, avatar_id and a palette of four #rrggbb colours. At most 64 KiB. |
| <span id="spec-file"></span>`spec.file` | string | no |  | length 1 to 1024 | A file holding the agent definition, the same as body. |
| <span id="spec-files"></span>`spec.files` | array of object | no |  | 0 to 32 items | Files the agent uses, written beside the definition when a host installs it. At most 32 files of up to 256 KiB each and 2 MiB in all, each UTF-8 text. |
| <span id="spec-files-path"></span>`spec.files[].path` | string | yes |  | length 1 to 1024 | Where the file is written, relative to the agent: one line, no .. segment, naming a file. |
| <span id="spec-files-body"></span>`spec.files[].body` | string | no |  | length 1 to 262144 | The file's contents. |
| <span id="spec-files-file"></span>`spec.files[].file` | string | no |  | length 1 to 1024 | A file holding the contents, the same as body. |

## Rules

Conditions the schema enforces beyond each field's own type. `vulnetix config validate` and the engine's plan report a document that breaks one.

| On | Rule |
|---|---|
| `spec` | Exactly one of `body` or `file` is set. |
| `spec.files[]` | Exactly one of `body` or `file` is set. |

## Applying this kind

- **Command.** `vulnetix config apply -f <file>`; the CLI line above says from which release. Plan first with [`vulnetix config plan`](/platform-iac/cli/plan.md): it shows each object as create, update, delete or no change, with a `planHash` that apply then holds to. Apply writes in one transaction.
- **Manager.** Each object records the manager that applied it (`terraform`, `console` or `gitops:<repo>`). `--prune` deletes only objects its own manager owns. See [The manager](/platform-iac/cli/plan.md#the-manager) and the [config engine](/platform-iac/reference/engine.md).
- **Status.** Applied, Unchanged or Deleted, with no other status fields. The phases the engine reports are explained under [status phases](/platform-iac/reference/engine.md#status-phases).

## How apply treats it

- The profile is identified by the id in the definition's front matter, which cannot change under a name.
- The definition is checked by the shared library validator (`internal/libraryitem`).
- Apply saves a new version with its files. An unchanged body is no new version.
- Delete hides the profile. Versions and files stay.

## Terraform and OpenTofu

The resource is `vulnetix_agent_profile` in the `vulnetix/resolve` provider. Its arguments are the `spec` in snake case, beside `name`, `labels` and `annotations` from `metadata`. The Minimal and Advanced HCL are above. The provider's own reference is [vulnetix_agent_profile](https://registry.terraform.io/providers/vulnetix/resolve/latest/docs/resources/agent_profile).

Import an object that already exists by its name:

```shell
# Import an existing AgentProfile by its name (metadata.name).
terraform import vulnetix_agent_profile.reviewer reviewer
```

Install, authentication and how state is read: [Terraform and OpenTofu](/platform-iac/terraform.md).

Check a file with `vulnetix config validate -f <file>`. See [Validate documents](/platform-iac/cli/validate.md). In an editor, start the file with the [schema comment](/platform-iac/schemas/editors.md).
