# Agent avatars

Every Agent has a picture beside its name. One never given one shows a character derived from its id, so no surface falls back to a generic icon and no stored Agent needs a migration. Agents use the profile picture's `Avatar` and `AvatarConfig` (`apps/web/components/avatar/`); the character is one more `kind` beside `dicebear`, `upload` and `letter`.

## The character

| Part | Values |
| --- | --- |
| Shape | 22: `chat`, `controller`, `mug`, `lightbulb`, `sprout`, `watering-can`, `barbell`, `book`, `brain`, `bull`, `bunny`, `camera`, `cat`, `cloud`, `ghost`, `magnifier`, `paint-brush`, `palette`, `rocket`, `shield`, `star`, `witch-hat` |
| Colour | 8 named colours: `blue`, `orange`, `green`, `violet`, `pink`, `teal`, `yellow`, `red` |
| Eyes | white |
| Mood | `idle`, `thinking`, `happy` |

Catalogue: `components/avatar/bot/catalog.ts`. A colour is stored by name and drawn in one fixed hex; character art is the one place outside the theme. Tiles, rings and labels use theme tokens.

## The character an id gets

| Function | Rule |
| --- | --- |
| `botLookFor(id)`, `bot/identity.ts` | 32-bit FNV-1a: shape from the hash, colour from its high 16 bits, so they do not move together. Built-in Agents use a table (PR Verifier shield, Research Desk brain, Knowledge Keeper sprout); no two share a shape. |
| `agentAvatarConfig(agent)`, `lib/agents/agent-avatar.ts` | The saved avatar, or the id's character when there is none or an upload's picture is missing |

## Storage

`AgentSpec.avatar` in `<state>/agents/<id>/agent.json`, in every Agent listing.

| Field | Used by | Rule |
| --- | --- | --- |
| `kind` | all | `bot`, `dicebear`, `upload` or `letter`; required when the avatar is not empty |
| `shape`, `color` | `bot` | a short slug; the web catalogue decides which exist, and an unknown one draws the id's character |
| `style`, `seed` | `dicebear` | a slug; up to 120 characters |
| `file` | `upload` | a `data:image/` URL of at most 350,000 characters |
| `letter`, `bg` | `letter` | up to 2 and 40 characters |

- `{}` means no avatar of its own, the default. A patch replaces the avatar whole.
- The API validates strictly and refuses with 400 (`validate_avatar` in `openprogram/runtime/agent_registry/manager.py`). Loading is tolerant: a stored avatar that no longer validates reads as `{}`.
- The Agent picker caps uploads at 256 KB, since every listing carries the picture.
- A trial conversation's configuration snapshot leaves the avatar out.

## Rendering

| Mode | What is drawn | When |
| --- | --- | --- |
| Still | one static SVG | `Avatar`'s default |
| Live | a canvas that blinks, sways and looks around | `live`; `AgentAvatar`'s default |

Renderer: `open-bot-avatar`, loaded on first use by `bot/runtime.ts`. `BotAvatar` mounts into a host element of the asked size. Live characters share one animation loop, pause off screen and when the page is hidden, and are the still picture under reduced motion.

The silhouette is the picture: no circle clip, no tile. Uploaded and generated Agent pictures keep a rounded-square frame. `app/styles/design/icons.css` keeps a character's drawing at its body box's size inside controls that size svgs as icons.

**Warm-up: no frame spent preparing shapes**

The renderer infers a shape's volume from its outline on first draw, 25 to 90 ms a shape, kept for the page's life. Seventeen Agents at once cost over half a second in one frame, and a still picture needs the same work.

`bot/warm.ts` prepares one shape per task: a waiting one in the next task, the rest in idle time after the renderer loads. Until ready, and in server markup, a character is its flat glyph in the box the renderer will use; the renderer replaces it in the same commit.

**Looking around**

The built-in idle wander moves the eyes about a pixel at icon size, in step across a shape. `bot/wander.ts` gives each character its own `lookAt` targets instead:

| Aspect | Value |
| --- | --- |
| Hold | 0.9 to 2.6 s |
| Reach | x up to 0.95, y up to 0.6 of the range; at least about a third to one side |
| Straight ahead | One glance in four |
| Cost | One timer per character, one firing per glance; random start and pauses |
| Mood | Thinking or happy keeps its pose |

`followPointer` stays off: tracking the cursor reads as watching the user, and it would call `getBoundingClientRect` every frame.

### Optical size

The drawings leave different margins in their 100-unit box: cloud 82 x 52, ghost 54 x 76. `BotAvatar` has a slot at the asked size and a body box inside, which the renderer draws into at the size that shows.

| Fit | Used in | Rule | 16px cloud |
| --- | --- | --- | --- |
| `botFit` | Everywhere else | Geometric mean side 0.8 of the slot, no side over 0.94, centred (from `BOT_EXTENTS`, checked by a test) | About 15 x 9.5px |
| `botMarkFit`, `fit="mark"` | Composer Agent chip, Agent menu rows ([fill rule](https://fzkuji.github.io/OpenProgram/docs/reference/design/ui/visual-system/icons.html#the-composers-fill-rule)) | Longer side equals the 16 x 16px slot, centred | 16 x 10.1px |

Uploaded, letter and DiceBear avatars already fill the slot, so `fit="mark"` only gives them the 18px hover.

### Hover

The slot pops with its control exactly as an [icon](https://fzkuji.github.io/OpenProgram/docs/reference/design/ui/visual-system/icons.html) does: `components/ui/hover-pop.ts` holds the clickable-host selector, 1.12 scale and spring, shared by `SolarIcon` and `BotAvatar`. Outside a control it follows its own hover. In the composer's Agent chip and Agent menu rows it grows to exactly 18 x 18px (`HOVER_POP_FILL`). Reduced motion turns it off.

## Where it shows

| Surface | Size | Mode |
| --- | --- | --- |
| Agents page: card, quick settings head | 32 | live |
| Agents page: editor header | 40 | live |
| Agents page: list rail | 16 | live |
| Avatar picker shape tiles | 34 | still |
| Composer Agent chip | 16 | live |
| Agent menu rows | 16 | live |
| Name above a reply from an Agent other than the default | 18 | live |
| Activity panel: Always-on row | 22 | live, `thinking` while the Agent works |
| Activity panel: Always-on detail head | 16 | live |
| Settings: channel bindings | 16 | live |
| Graph: agent reply and sub-agent start nodes, legend | 16 | flat glyph in the branch colour |
| Activity panel: agent and sub-agent rows | 22 (16 in a detail head) | flat glyph in the branch colour |

`AgentAvatar` is live unless a caller turns it off; picker tiles are samples, not Agents. Id-only surfaces use `AgentAvatarById`, which reads the shared `useAgents` list and shows the id's character until it loads; the Agents page writes to the same cache.

Page icons for Agents (navigation entry, center tab) and the `ghost` of sub-agent tool calls are icons of a kind of thing and stay icons.

**Flat glyph in coloured chips**

`bot/glyph.ts`, `BotGlyph` in React: the body's path in the current colour, eyes cut through it. Outlines wind clockwise and the body's winding number under each eye is 1, so each eye is a counter-clockwise pill and nonzero fill cuts it out; a test checks every shape. Its view box fits the body by `botFit`.

It does not move, is cloned into the graph's SVG like a Solar icon, and takes the branch's colour ([graph rendering](https://fzkuji.github.io/OpenProgram/docs/reference/design/runtime/dag/rendering.html)). The main agent's glyph is the conversation Agent's character (`useConversationAgentShape`; an Agent with an upload or generated picture uses its id's character); a sub-agent's comes from its name.

## The picker

The Agent editor's General section uses the profile's `AvatarPicker` with sources Character, Generated and Upload. Character shows shape tiles, previewing the current colour, and swatches. It edits the draft, so it saves and discards with the rest.

**Sources and licences**

| Source | What it provides | Licence |
| --- | --- | --- |
| `open-bot-avatar` (npm, pinned) | the renderer and 7 shapes | MIT, Copyright Dominik Scholz |
| The same project's repository gallery | 15 more shapes, copied unchanged into `components/avatar/bot/gallery.ts` with the licence notice | MIT, Copyright Dominik Scholz |

| Alternative | Why not |
| --- | --- |
| Renderers extracted from the Grok Bot client, and replicas of its characters | The code or the character designs belong to xAI, whatever licence the repository states |
| `@aora-bot/react` | Its licence is not open source (attribution and team-size terms), and it needs React 19 |
| `agent-robot-avatar` | One robot design whose character identity is reserved by its author |
| DiceBear Bottts, Facehash, animated emoji sets | A different look from the one chosen: generated robots, letter faces, or emoji that do not read as one family |

The shapes are the project's own designs.

## Implementation status

Implemented. The `happy` mood is available to callers; no surface sets it yet.
