Agent Settings

Edit an agent's name, instructions, tools and model.

Support bot

Published · v6
Say what it should do in plain words. Insert a field to use the customer's data.184 / 4000
Model

Smarter models answer harder questions and cost more per reply.

Reads several articles before it answers.

Tools

What it may do while it answers.

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/agent-editor

Usage

import { AgentEditor } from "./ui/uicontext/components/kit/AgentEditor.ts"
const Message = UiSchema.TaggedEnum({	SavedAgent: { name: Schema.optional(Schema.String), instructions: Schema.optional(Schema.String) },	ChoseAgentModel: { model: Schema.String },})// your app owns the agent's settings; the editor asks for each changeexport const SupportBotSettings = (h: Html.H<typeof Message.Type>, agent: { readonly instructions: string; readonly model: string }) =>	AgentEditor(h, {		props: {			id: "support-bot",			name: "Support bot",			instructions: { value: agent.instructions },			model: {				value: agent.model,				options: [					{ value: "fast", label: "Fast" },					{ value: "balanced", label: "Balanced" },				],			},			can: ["edit"],		},		onEmit: {			RequestedSave: ({ name, instructions }) => Message.SavedAgent({ name, instructions }),			RequestedModel: ({ model }) => Message.ChoseAgentModel({ model }),			RequestedTool: () => undefined,			RequestedChoice: () => undefined,			RequestedAddKnowledge: () => undefined,			RequestedRemoveKnowledge: () => undefined,			RequestedPublish: () => undefined,			RequestedEdit: () => undefined,			RequestedDelete: () => undefined,		},	})

API reference

AgentCardComponent

Props

AgentCard props
NameTypeDescription
idrequiredstringIdentifies the agent in the events the card sends
namerequiredstringThe agent's name, as the card's heading
descriptionstringOne line: what it does
pictureAgentPictureAn image or an emoji; a colored initial when left out
status{ tone, label }"Active", "Draft", "Paused", "Working", "Needs you"
ownerstring"Ada Lovelace", "Shared with Design"
factsstring[]Short facts, in order: "3 tools", "Last run 2 hr ago"
hrefstringIts page; the name links there
primary{ on, label, disabled }A "primary agent" star. disabled says why it can't be primary
access"request" | "requested"This person can't use it yet: offer to ask, or say it's asked
outcomeOutcome | nullThe app's answer to the request in flight; its request is the action's id
agentIdstringThis card's id for agents; defaults to agent-card:<id>

Events

AgentCard events
EventPayloadDescription
RequestedPrimary{ id: string; on: boolean }The person starred the agent as primary (on) or took the star back
RequestedAccess{ id: string }The person asked for access to the agent

Agent actions

What agents can do with AgentCard
ActionDescription
ClickedPrimaryMake it the primary agent, or stop
ClickedRequestAccessAsk its owner for access

AgentEditorComponent

Props

AgentEditor props
NameTypeDescription
idrequiredstringIdentifies the agent in the events the editor sends
namerequiredstringThe agent's name, as the first field
descriptionstringLeave out to hide the field
pictureAgentPictureAn image or an emoji; a colored initial when left out
instructionsrequired{ value, label, hint, … }What the agent is told to do: the text, its label and hint, and tokens to insert
model{ value, label, hint, … }The model it runs on, picked from options; leave out to hide the field
choicesAgentChoice[]More settings, each one of a few options: "Reply in" with Thread or Channel
tools{ label, hint, items }The tools it may use, each switched on or off
knowledge{ label, hint, items, … }The pages, files and sources it reads from
versionAgentVersionDraft, published, changed or locked, with a label and a note
canrequiredAgentEditorAction[]What this person may do; anything absent is hidden or read-only
readOnlyNoticeWhy the form is read-only: "You need Can edit to change this agent", with a link to ask
outcomeOutcome | nullThe app's answer to the request in flight; its request is the action's id
deletion{ consequences, confirmName, label }What deleting removes, and whether the person types the name to confirm
agentIdstringThis editor's id for agents; defaults to agent-editor:<id>

Events

AgentEditor events
EventPayloadDescription
RequestedSave{ id: string; name?: string; description?: string; instructions?: string }Save: the text fields as the person left them; a field left out didn't change
RequestedModel{ id: string; model: string }The person picked another model
RequestedTool{ id: string; tool: string; on: boolean }The person switched a tool on or off
RequestedChoice{ id: string; choice: string; value: string }The person picked an option for one of choices
RequestedAddKnowledge{ id: string }Open the app's own picker for a page, file or source
RequestedRemoveKnowledge{ id: string; source: string }The person removed a source from knowledge
RequestedPublish{ id: string }The person published the draft
RequestedEdit{ id: string }The live version is locked: open a draft of it
RequestedDelete{ id: string }The person confirmed deleting the agent

Agent actions

What agents can do with AgentEditor
ActionDescription
UpdatedNameType the agent's name (saved with SubmittedSave)
UpdatedDescriptionType the agent's description (saved with SubmittedSave)
UpdatedInstructionsReplace the instructions text (saved with SubmittedSave)
ChoseTokenInsert a field token at the caret in the instructions
SubmittedSaveSave the edited name, description and instructions
ClickedDiscardThrow away unsaved text edits
ChoseModelChoose the model by its value
ToggledToolTurn a tool on or off by its id
ChoseOptionChoose an option in one of the agent's choices (see page_query)
ClickedAddKnowledgeOpen the picker to add a knowledge source
ClickedRemoveKnowledgeRemove a knowledge source by its id
ClickedPublishPublish the current settings as the live version
ClickedEditOpen a draft of the locked live version
ClickedDeleteAsk to delete the agent (opens the confirmation)
UpdatedConfirmNameType the agent's name into the delete confirmation
ConfirmedDeleteasks firstDelete the agent. Name it as your target.

AgentAvatarView function

Options

AgentAvatar options
NameTypeDescription
idrequiredstringThe agent's id: it picks the initial's color
namerequiredstringThe agent's name: its first letter shows without a picture
pictureAgentPictureAn image or an emoji; a colored initial when left out

Accessibility

  • The settings are a labelled form: name, description and instructions are fields, and model, tools and knowledge are fieldsets with legends.
  • The primary star is a toggle button (aria-pressed), and a disabled control says why.
  • Deleting asks first, and can ask you to type the agent's name. Agents can edit, save and publish, and must name the agent they delete.

Source