Skip to content

エージェントペルソナフォーマット

エージェントペルソナ は 1 つのエージェント —— coordinator、incident investigator、specialist —— がどう振る舞うかを記述する markdown ファイルです:どのツールを呼べるか、どのモデルで動くか、何 ReAct ターンを得るか、どのシステムプロンプトを持つか。

真実の出所:internal/manager/biz/aiops/chatruntime/types.goAgent

ディスク上の形

markdown
---
name: incident_investigator
description: Walk an incident from symptom to root cause, calling host + observability tools.
when_to_use: When the user asks why an alert is firing, or shares an incident link.
tools:
  - expand_topology
  - find_topology_node
  - query_promql
  - search_logs
  - query_traceql
  - host_probe
  - bash
disallowed_tools: []
permission_mode: read-only
max_turns: 24
model: anthropic/claude-sonnet-4-6
critical_reminder: |
  Always show your evidence. Cite the PromQL / LogQL / file path. Never speculate
  beyond what the tools returned.
initial_prompt: |
  You are investigating incident {{ '{{' }}.incident_id{{ '}}' }} on device {{ '{{' }}.device_id{{ '}}' }}.
  Start by reading the incident summary.
background: false
omit_claude_md: false
metadata:
  os: [linux, darwin]
  requires:
    bins: []
    config: []
  ongrid:
    scope: manager
---

# Incident investigator

You are an SRE-grade incident investigator. Given an incident, your job is to:

1. Pull the alert detail and any attached evidence (alert summary, snapshot).
2. Expand the device's topology to understand the blast radius.
3. Query the relevant signal (metric / log / trace) to confirm the symptom.
4. Walk upstream services / underlying resources until you find the root cause.
5. Return an evidence-backed answer in plain language.

When the user asks a follow-up, stay grounded in tool output. If you cannot
verify a claim with a tool call, say so explicitly and stop.

フロントマターは YAML です。本文(--- の後)は worker LLM が見る システムプロンプト です。本文内の空白と markdown フォーマットは逐語に保持されます。

フロントマターフィールド

フィールド必須説明
namestringはいspawn 時に使うエージェント識別子(/v1/agents/{name})。
descriptionstringはいエージェントピッカーに表示されるヒューマンリスト文字列。
when_to_usestringはいcoordinator の spawn 判断ヒント。どの specialist を呼ぶか決めるときに coordinator がこれを読む。
toolsstring[]いいえ明示的なツールホワイトリスト。空 = ポリシーから継承(ユーザーロールが見られるすべてのツール)。
disallowed_toolsstring[]いいえホワイトリスト後に適用するブラックリスト。ブラックがホワイトに勝つ。
permission_modeenumいいえ(デフォルト read-onlyread-onlymutating-with-confirmdual-sign-required。確認なしでどのツールクラスが動くかゲート。
max_turnsintいいえworker 内部 ReAct ループのキャップ。ゼロなら coordinator デフォルトが適用される。
modelstringいいえLLM 識別子(anthropic/claude-sonnet-4-6openai/gpt-5.4zhipu/glm-4.7 など)。空 = coordinator デフォルトを継承。
critical_reminderstringいいえ毎ターン注入される system-reminder ブロック。アンチドリフトメカニズム。
initial_promptstringいいえspawn 時の最初のユーザーメッセージの先頭に付与。spawn コンテキストに対する Go テンプレート構文({{.incident_id}}{{.device_id}})をサポート。
backgroundboolいいえtrue で非同期実行を強制(長時間 worker)。
omit_claude_mdboolいいえグローバルシステムコンテキストの継承をスキップ。タイトスコープ reviewer エージェントに使用。
metadataobjectいいえOS ゲート、必須バイナリ / 設定キー、ongrid 拡張(scope、edge_runtime、edge_capabilities)。

未知のフロントマターキーは保持されます(パーサーは UnknownFields 下に保存)ので、openclaw / claude-code からの将来のフィールドがローダーを壊しません。

Source フィールド

SPA がエージェントを読み戻すとき、API はディスク上のフロントマターの一部 ではない source フィールドも含めます:

意味
builtinバイナリに出荷(プログラム的 Add)。UI で読み取り専用。
diskバイナリの隣の agents/*.md または外部 dir からロード。UI で読み取り専用。
userPOST /v1/agents/custom でユーザーが作成。UI から編集・削除可能。

パーミッションモード

permission_mode フィールドはペルソナが走らせられる ツールクラス をゲートします。

モード許可クラス確認必須
read-onlyread(エイリアス safe決してなし
mutating-with-confirmread + writewrite 呼び出しごとに 1 回
dual-sign-requiredread + write + destructivedestructive は 2 ステップ SOP、write は 1 回

ペルソナはさらに tools(ホワイトリスト)と disallowed_tools(ブラックリスト)でこの順序で制約できます:

  1. ユーザーロールが見られるグローバルツールセットを取る。
  2. tools が空でなければ交差。
  3. disallowed_tools のものを削除。
  4. 残りの各ツールについて、その class に対して permission_mode をチェック。

登録フロー

text
Built-in personas
  ↳ programmatic Add() in cmd/ongrid/main.go at startup. Cannot be deleted.

On-disk personas
  ↳ ./agents/*.md (relative to manager working dir) scanned at boot.
  ↳ ONGRID_AGENTS_EXTERNAL_DIRS adds more.
  ↳ The loader walks every .md, parses frontmatter via skill_parser.go / agent_parser.go.
  ↳ Each agent is registered with Source="disk".
  ↳ Cannot be edited or deleted via the UI; remove the file and restart.

User personas
  ↳ POST /v1/agents/custom with the frontmatter as a JSON body.
  ↳ Stored in agents table (DB), not on disk.
  ↳ Source="user"; fully editable via PATCH /v1/agents/custom/{name}.

起動時のマージ順序は builtin → disk → user。組み込みまたはディスクペルソナと同じ nameuser ペルソナはそれをシャドウします。

エージェントの spawn

coordinator はユーザーのクエリを各ペルソナの when_to_use と照合して specialist を選びます。プログラム的に spawn するには(チャット API):

http
POST /api/v1/chat/sessions/{id}/messages
Content-Type: application/json
Authorization: Bearer ...

{
  "content": "Investigate incident 4217.",
  "agent": "incident_investigator",
  "context": { "incident_id": 4217, "device_id": 102 }
}

agent が省略されると coordinator が選びます。context はペルソナの initial_prompt にテンプレート展開されます。

クリティカルリマインダー

critical_reminder ブロックは最初だけでなく 毎ターンの先頭system-reminder メッセージとして注入されます。これは標準の claude-code アンチドリフトメカニズムです —— モデルが会話途中でさまよう(例えばターン 8 以降で証拠引用を停止する)と、リマインダーが引き戻します。

控えめに使ってください。ペルソナごとに 1 つの短い段落で十分です。エージェントカーネルはすでにフレームワークレベルのリマインダー(ロケール、モデル名、利用可能なツール)を注入します。あなたの critical_reminder はペルソナ固有の挙動だけを加えるべきです。

最小 specialist

markdown
---
name: disk_specialist
description: Diagnose disk pressure issues — usage, IO, mount points.
when_to_use: When the user asks about disk-full, slow IO, or mount errors.
tools: [host_probe, bash, query_promql]
permission_mode: read-only
model: zhipu/glm-4.7
---

# Disk specialist

Focus exclusively on disk-related questions. ...

Reviewer(グローバルコンテキストを省略)

markdown
---
name: change_reviewer
description: Review a proposed config change for blast radius.
when_to_use: When the user wants a second opinion on a destructive action.
tools: [expand_topology, read_repo, search_knowledge]
permission_mode: read-only
omit_claude_md: true
max_turns: 8
model: anthropic/claude-opus-4-7
critical_reminder: |
  Be a skeptic. Default to "do not proceed" unless evidence is overwhelming.
---

# Change reviewer

You are reviewing a proposed change. Your job is to find reasons the change
should NOT proceed. Approve only when you cannot find a reason to block.

関連