From 5b2c61cfaba6370be8576980dc3fb869e801142f Mon Sep 17 00:00:00 2001 From: Jiayuan Date: Sun, 29 Mar 2026 17:01:07 +0800 Subject: [PATCH] feat(agent): add instructions field for agent persona/identity Add an `instructions` text field to the agent model, allowing users to define each agent's role, expertise, and working style. Instructions are injected into CLAUDE.md as an "Agent Identity" section so the agent knows who it is on every task execution. - Migration 021: add instructions column to agent table - Backend: create/update/get agent handlers support instructions - ClaimTask response includes instructions for daemon injection - execenv: inject instructions into CLAUDE.md meta-skill - Frontend: add Instructions tab to agent detail panel --- apps/web/app/(dashboard)/agents/page.tsx | 78 ++++++++++++++++++- apps/web/shared/types/agent.ts | 3 + apps/web/test/helpers.tsx | 1 + server/internal/daemon/daemon.go | 9 ++- server/internal/daemon/execenv/execenv.go | 7 +- .../internal/daemon/execenv/runtime_config.go | 7 ++ server/internal/daemon/types.go | 7 +- server/internal/handler/agent.go | 17 +++- server/internal/handler/daemon.go | 7 +- .../021_agent_instructions.down.sql | 1 + .../migrations/021_agent_instructions.up.sql | 1 + server/pkg/db/generated/agent.sql.go | 37 +++++++-- server/pkg/db/generated/models.go | 1 + server/pkg/db/queries/agent.sql | 10 ++- 14 files changed, 159 insertions(+), 27 deletions(-) create mode 100644 server/migrations/021_agent_instructions.down.sql create mode 100644 server/migrations/021_agent_instructions.up.sql diff --git a/apps/web/app/(dashboard)/agents/page.tsx b/apps/web/app/(dashboard)/agents/page.tsx index 63762143..54bd9154 100644 --- a/apps/web/app/(dashboard)/agents/page.tsx +++ b/apps/web/app/(dashboard)/agents/page.tsx @@ -312,6 +312,73 @@ function AgentListItem({ ); } +// --------------------------------------------------------------------------- +// Instructions Tab +// --------------------------------------------------------------------------- + +function InstructionsTab({ + agent, + onSave, +}: { + agent: Agent; + onSave: (instructions: string) => Promise; +}) { + const [value, setValue] = useState(agent.instructions ?? ""); + const [saving, setSaving] = useState(false); + const isDirty = value !== (agent.instructions ?? ""); + + // Sync when switching between agents. + useEffect(() => { + setValue(agent.instructions ?? ""); + }, [agent.id, agent.instructions]); + + const handleSave = async () => { + setSaving(true); + try { + await onSave(value); + } finally { + setSaving(false); + } + }; + + return ( +
+
+

Agent Instructions

+

+ Define this agent's identity and working style. These instructions are + injected into the agent's context for every task. +

+
+ +