<!-- AANCER Developer Reference (English): every field, limit and error code, part 7 of 16. All parts: https://aancer.ai/dev/llms.txt -->

## Field reference

JSON Schema: [agent.schema.json](https://aancer.ai/dev/schemas/agent.schema.json). The root is the blueprint spec. `$defs/agentConfig` is the REST agent configuration.

### Agent blueprint spec

| Field | Type | Required | Rules |
|---|---|---|---|
| `name` | string | yes | 1 to 120 characters |
| `description` | string | no | at most 2000 characters |
| `category` | string | no | free text, at most 80 characters |
| `icon` | string | no | at most 40 characters, an icon name such as `receipt` |
| `instructions` | string | yes | 1 to 50,000 characters |
| `starters` | string[] | no | at most 12, each 1 to 500 characters |
| `model` | object | yes | exactly `{ "tier": "<tier>" }`. Tier: `local-standard`, `local-advanced`, `cloud-reasoning`. Never a fixed model route |
| `tools` | array | no | at most 64 of `{ kind, ref }`, no duplicates. See Tool references |
| `skills` | string[] | no | at most 32, each 1 to 120 characters |
| `riskHint` | `"high"` or `null` | no | |

No other fields are allowed.

### Tool references in a blueprint

| `kind` | `ref` must be |
|---|---|
| `knowledge` | a pack parameter `{{param.<id>}}`. Never a knowledge set id |
| `workflow` | the item id of a `template` item in the same pack, or a pack parameter |
| `agent` | the item id of another `agent-blueprint` item in the same pack, or a pack parameter |
| `web` | a tool name such as `search`. The pack must declare a data flow with `destination: "web-search"` |
| `connector` | a connector name, optionally with an action: `name` or `name.action`. Letters, digits, `_ . @ / -` |
| `dataset`, `frame` | the platform tool's action name, for example `append` or `render` |
| `fn` | the item id of a `function` item in the same pack |

`code` and `mcp` tools cannot be part of a blueprint.

Pack parameters have no knowledge type. Declare a knowledge parameter as `"type": "string"` and let the administrator enter the knowledge set id.

### What happens on "Create agent"

When a person creates an agent from a blueprint, the new draft takes the blueprint's instructions, starters, model tier, tools and skills. Everything else uses the defaults: limits of 12 steps, 20 tool calls, 1 USD and 300 seconds, write confirmation `always`, no automated decisions. Tool references are resolved in the person's workspace:

- a `workflow` item becomes the newest workflow deployed there from that pack template;
- an `agent` item becomes the newest agent created there from that blueprint;
- a parameter becomes its bound value.

A reference that cannot be filled is left out and listed in `skipped[]` with the reason `parameter_not_set`, `workflow_not_deployed` or `agent_not_created`. Deploy the template first, then create the agent.

### Agent configuration (REST)

Send it with `PUT /api/agents/{id}/draft` as `{ "config": { ... } }`, at most 200,000 bytes. Saving a draft refuses malformed values. Publishing also refuses missing values and tools that are not available.

| Field | Type | Required | Rules | Default |
|---|---|---|---|---|
| `instructions` | string | yes | not empty at publish, at most 50,000 characters | `""` |
| `model` | object | yes | exactly one of `{tier}` or `{route}`. `route` is a fixed model route of the installation | `{tier: "local-advanced"}` |
| `temperature` | number | no | 0 to 2 | |
| `tools` | array | yes | may be empty, no duplicates. See below | `[]` |
| `input` | object | yes | `{kind: "prompt"}` or `{kind: "form", fields: [...]}` with 1 to 40 fields | `{kind: "prompt"}` |
| `starters` | string[] | yes | at most 12, each 1 to 500 characters | `[]` |
| `output` | object | no | `{fields: [...]}`, 1 to 50 fields | |
| `limits` | object | yes | `maxSteps` (at most 200), `maxToolCalls` (at most 500), `maxUsd` (at most 1000), `maxWallMs` (at most 86,400,000). All above 0; all except `maxUsd` are whole numbers | `12, 20, 1, 300000` |
| `approval.confirmWrites` | string | yes | `always` or `workspace_default` | `always` |
| `art22.automatedDecisionMaking` | string | yes | `none`, `assistive`, `decisive` | `none` |
| `art22.humanOversightRequired` | boolean | yes | must be `true` when `decisive` | `true` |
| `personaId` | string or null | no | a persona id of the installation | |
| `memory.perUser` | boolean | no | opt-in memory per user | |
| `skills` | string[] | no | skill ids visible in the workspace, no duplicates, always loaded for this agent | |

Rule: when `automatedDecisionMaking` is not `none`, or `humanOversightRequired` is `true`, `confirmWrites` must be `always`.

Tool entries are `{ kind, id, fields?, connection? }`:

- `kind`: `connector`, `knowledge`, `workflow`, `mcp`, `agent`, `code`, `web`, `frame`, `dataset`, `fn`.
- `id`: for `connector`, `<connector name>` or `<connector name>.<action>`; for `knowledge`, a knowledge set id; for `workflow`, a workflow id; for `agent`, an agent id; for platform tools, the action name. `"*"` (every tool of that kind) is allowed only for `connector`, `knowledge`, `workflow` and `mcp`, and only as the whole id: `slack.*` or `*` for any other kind is refused.
- `fields`: `{ "<input>": { "mode": "fixed" | "preselected", "value": ... } }`. A `fixed` field needs a value.
- `connection`: `{ "mode": "user" }` or `{ "mode": "preselected", "id": "<connection id>" }`.

Form fields: `{ id, type, label, required?, help?, options?, accept?, maxFiles? }`. `id` matches `^[a-z][a-z0-9_]{0,63}$`. `type` is `text`, `multiline`, `number`, `checkbox`, `date`, `email`, `select`, `multiselect` or `file`. `select` and `multiselect` need `options [{value, label}]`. `file` takes `accept` (media types) and `maxFiles` (1 to 10).

Output fields: `{ id, type, description?, values?, required? }`. `type` is `text`, `number`, `boolean`, `enum` or `json`. An `enum` needs `values`. With `output` set, the agent ends each run by returning these fields.

## Full examples

### A blueprint that uses a pack template, a knowledge parameter and web search

```json
{
  "v": 2, "kind": "bundle", "id": "acme.invoice-desk", "version": "1.0.0", "title": "Invoice desk",
  "publisher": { "name": "Acme Example Ltd", "keyId": "pub-0123456789ab" },
  "requires": { "platform": ">=1.0.0" },
  "parameters": [
    { "id": "target_workspace", "type": "workspace", "label": "Workspace", "required": false },
    { "id": "policies", "type": "string", "label": "Knowledge set with the booking rules", "required": false }
  ],
  "declarations": {
    "v": 1, "licence": "Apache-2.0",
    "dataFlows": [
      { "purpose": "Read invoices the person shares in the conversation", "data": ["invoice documents"], "personalData": true, "destination": "installation" },
      { "purpose": "Look up a supplier on the web when asked", "data": ["supplier names"], "personalData": false, "destination": "web-search" }
    ],
    "egress": [],
    "aiUse": { "intendedPurpose": "Drafts booking proposals that a person checks", "annexIII": false, "humanOversight": "A person confirms every write before it happens" },
    "attestations": { "ownsRights": true, "noProhibitedPractice": true }
  },
  "items": [
    { "kind": "agent-blueprint", "schemaVersion": 1, "id": "invoice-clerk", "scope": "install",
      "spec": { "$ref": "content/invoice-clerk.json" } },
    { "kind": "template", "schemaVersion": 1, "id": "invoice-summary-approval", "scope": "install",
      "spec": { "$ref": "content/invoice-summary-approval.json" } }
  ]
}
```

`content/invoice-clerk.json`:

```json
{
  "name": "Invoice clerk",
  "description": "Reads invoices, names supplier, amount and cost centre, and drafts the booking proposal.",
  "category": "finance",
  "icon": "receipt",
  "instructions": "You help the accounts team. For each invoice, name the supplier, the amount and the cost centre, check them against the booking rules, and draft a booking proposal. Never book anything yourself.",
  "starters": ["Check this invoice", "Draft the booking proposal"],
  "model": { "tier": "local-advanced" },
  "tools": [
    { "kind": "knowledge", "ref": "{{param.policies}}" },
    { "kind": "workflow", "ref": "invoice-summary-approval" },
    { "kind": "web", "ref": "search" },
    { "kind": "frame", "ref": "render" }
  ],
  "skills": [],
  "riskHint": null
}
```

`content/invoice-summary-approval.json` is the template spec from [Templates](/developers/templates). Without the template item in the same pack, import fails. That template starts from a webhook, so the agent can only run it as a certified agent.

### An agent configuration with a form and structured output

```json
{
  "instructions": "You triage incoming support requests. Classify each request, look up the answer in the product handbook, and draft a reply. Ask before sending anything.",
  "model": { "tier": "local-advanced" },
  "temperature": 0.2,
  "tools": [
    { "kind": "knowledge", "id": "ks_handbook" },
    { "kind": "connector", "id": "mail.send_email", "connection": { "mode": "user" } }
  ],
  "input": { "kind": "form", "fields": [
    { "id": "customer", "type": "text", "label": "Customer name", "required": true },
    { "id": "priority", "type": "select", "label": "Priority", "options": [ { "value": "low", "label": "Low" }, { "value": "high", "label": "High" } ] },
    { "id": "attachment", "type": "file", "label": "Ticket export", "accept": ["application/pdf"], "maxFiles": 2 }
  ] },
  "starters": ["Triage this request"],
  "output": { "fields": [
    { "id": "category", "type": "enum", "values": ["billing", "bug", "how_to"], "required": true },
    { "id": "draft_reply", "type": "text", "required": true }
  ] },
  "limits": { "maxSteps": 12, "maxToolCalls": 20, "maxUsd": 1, "maxWallMs": 300000 },
  "approval": { "confirmWrites": "always" },
  "art22": { "automatedDecisionMaking": "assistive", "humanOversightRequired": true },
  "memory": { "perUser": false },
  "skills": []
}
```

`ks_handbook` and `mail.send_email` are placeholders. Tool ids must exist and be enabled in the agent's workspace.

## Install and test

### Blueprint in a pack

1. Sign and import the pack. See [Packs](/developers/packs). Import checks the spec, the same-pack references and the web-search declaration.
2. Activate the pack. If it contains templates, deploy them in the workspace.
3. In **Agents**, choose **Create agent** from the blueprint, or call `POST /api/agents` with `{"workspaceId":"ws-ops","name":"Invoice clerk","blueprintId":"pack:acme.invoice-desk:invoice-clerk"}`. Check `blueprint.skipped[]` in the response.
4. Open the draft, test it, and publish it.

### Agent through the REST API

```bash
# create
curl -X POST https://aancer.example.com/api/agents \
  -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -d '{"workspaceId":"ws-support","name":"Support triage","description":"Classifies requests and drafts replies"}'

# save the draft configuration
curl -X PUT https://aancer.example.com/api/agents/$AGENT_ID/draft \
  -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -d @agent-config.json      # {"config": {...}}

# preview, then publish
curl https://aancer.example.com/api/agents/$AGENT_ID/publish-preview -H "Authorization: Bearer $TOKEN"
curl -X POST https://aancer.example.com/api/agents/$AGENT_ID/publish \
  -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" -d '{"changeNote":"First version"}'
```

| Call | Permission | Notes |
|---|---|---|
| `POST /api/agents {workspaceId, name, description?, icon?, blueprintId?}` | `agents.create_own` | `blueprintId` is `pack:<packId>:<itemId>` |
| `PUT /api/agents/{id}/draft {config, ifUpdatedAt?}` | `agents.edit_own` | saves the configuration |
| `PATCH /api/agents/{id}` | `agents.edit_own` | name, description, icon, up to 3 labels |
| `GET /api/agents/{id}/publish-preview` | `agents.publish_own` | shows what publishing would certify |
| `POST /api/agents/{id}/publish {changeNote?, modelEgress?}` | `agents.publish_own` | returns `{version, passportId, configHash, warnings}`. `modelEgress` is `{scope: "in-perimeter"}` or `{scope: "listed", destinations: [<host>...]}` |
| `GET /api/agents/{id}/versions`, `GET /api/agents/{id}/diff?from=&to=` | `agents.edit_own` | versions and differences |
| `POST /api/agents/{id}/versions/{n}/restore {changeNote?, modelEgress?}` | `agents.publish_own` | publishes an older version again |
| `POST /api/agents/{id}/export-for-submission` | `agents.publish_own` and edit access | see below |

### Export an agent as a blueprint pack

`POST /api/agents/{id}/export-for-submission` with `{"packId":"acme.support-triage","licence":"Apache-2.0","ownsRights":true,"noProhibitedPractice":true}` returns a signed one-item blueprint pack, made from the published version. Add `"preview": true` to see the content first. Knowledge, workflow and agent tools become pack parameters. Connections, fixed field values, skills, the form, output, limits, memory and persona are not exported. A tool wildcard, a fixed model route, a code, MCP or `fn` tool, a missing description, empty instructions, or anything that looks like a credential stops the export with `AGENT_EXPORT_REFUSED` and a `reason`.

### Certified agents

Publishing always issues a passport. In addition, an installation can require certification: then a run may only use the tools, model tier ceiling and budgets that the certificate covers. A knowledge set or workflow added after certification shows "Not certified" until you certify again. Workflows that start from a **webhook, schedule or event** run only for certified agents: "Only certified agents can run workflows that start from a web call, a schedule or an event." Workflows with a Manual or Form start work for every agent.

Certificates are issued by the installation. You cannot write or edit one.

Next part: https://aancer.ai/dev/parts/reference/08-common-errors.md
