# Agent → Behaviour (`/agent/behaviour`)

Status: CONFIRMED by the operator 2026-09-11 with his edits (tab names). The
markdown boxes under five headings are the intended system; a rules-with-switches
alternative was offered and declined. The situation tab is named Conversation
(his ruling 2026-09-11, ledger 33).

## What it is for
What the AI is told, in the operator's own words, with nothing hidden and no
developer needed (rulings 20 and 21). This screen is the prompt. Everything that
is a switch, a threshold, a list or a fixed sentence is configuration and lives
on Agent → Settings, not here.

## What it must show
- Four tabs: **Global** (applies under every situation on every channel), then
  one per situation: **conversation**, **Comment replies**, **moderation**.
- On each tab the five fixed headings, Role · Goal · Tone · Knowledge ·
  Guardrails (ruling 17), each an ordinary markdown field. Each heading says
  whether the words are **your wording** or **the standard wording**, and flags
  when the standard wording has moved since you saved yours.
- One **Edit** puts every field on the tab into edit mode; one **Save** commits
  them all. While editing, the other tabs wait. A cleared field goes back to the
  standard wording; nothing is read-only.
- Under Knowledge, that tab's slice of the knowledge library: global rows on
  Global, situation rows on their situation, channel-specific rows marked with
  the channels they show on. Rows open in a side panel to read or edit.
- **The rest of what it is sent**: the full prompt for a chosen channel, every
  block named, runtime-filled blocks shown as named empty slots, the tools
  listed. Nothing the AI is told is absent from this view.

## What it must do
- Save the five headings per tab; clear one back to the standard wording.
- Add, edit, re-file and delete a knowledge document from the library slice,
  with a confirm on delete that names the document.
- Show the exact prompt for any channel and copy it.

## Deliberately not here
- No channel switches, thresholds, test audience, or fixed sentences (the
  private-message brief, the fallback and "cannot answer" lines): those are
  configuration and belong on Agent → Settings.
- No knowledge search screen; the library is only ever seen as a tab's slice.
- No graded marks, no corrections.

## Known gaps against intent
- The "What it says" and "What it says when it cannot answer" cards still render
  here (`Behaviour.tsx:483, 586`), and Settings renders the same texts: one
  concept on two screens. They leave this screen.
- A second, full-page document editor exists at `/agent/behaviour/knowledge/:id`
  and nothing links to it; it is the only place to change a document's kind,
  structured fields, tags and category. Give the library a door to it or fold it.
- The Role heading stored for the website channel tells the AI it is on
  WhatsApp (boarded 2026-08-24).
- How to lay out prompt plus library plus per-channel view cleanly is the open
  design problem the operator named on 2026-09-10.

## Proof
`Behaviour.test.tsx`, `situations-*.test.tsx` and the api's
`prompt-conformance.test.ts` (a real turn's system prompt has no block missing
from the view) pass. Looked at on prod after each change.
