multica-creating-agents
multica-ai/multica
透過 `multica agent` 命令列介面或 `POST /api/agents` 建立、檢視或除錯 Multica 代理程式時請參閱此說明 — 說明各欄位的定義、其儲存格式、是否僅為元資料或會在索取時被守護程式使用、哪些輸入會被驗證/拒絕、custom_env 機密資訊的存取控制機制,以及技能綁定行為。不適用於將問題指派給現有代理程式,亦不適用於執行階段的任務提示。
...展開全部建立 Multica 代理程式
這是 Multica 代理程式建立路徑的規範:建立入口點
所接受的內容、伺服器會驗證與拒絕哪些內容、各欄位如何
被持久化,以及守護程式在索賠時實際讀取哪些欄位。 這
並非參數手冊——它陳述的是可追溯至原始碼的事實,且每項聲明皆
有references/creating-agents-source-map.md 檔案中的「檔案:行號」作為依據。
快速入門(唯讀檢視)
這些指令用於讀取狀態,且無任何副作用:
multica agent get --output json # 完整的持久化代理記錄
multica agent skills list --output json # 當前的技能綁定
multica agentenvget --output json # 明文環境變數(僅限擁有者/管理員,代理無權存取)
agent get會回傳包含runtime_id、model、
thinking_level、service_tier、custom_args、has_custom_env、
custom_env_key_count 以及skills 的持久化代理資料。此指令絕不會回傳明文形式的custom_env。
核心模型
代理程式是工作區範圍內的資料列(agent 資料表)。建立代理程式只需單一
POST /api/agents請求(multica agent create)。 在任務申領時,守護程式
會重新讀取代理程式資料列並組裝執行時載荷——因此代理程式實際執行的依據是
儲存的欄位,而非建立時的輸出結果。
兩個常被混淆的獨立文字欄位:
description為目錄摘要。它會儲存並顯示於清單中; 守護程式不會將其注入代理的執行時提示中。請僅將其視為 面向人類的元資料。上限為 255 個 Unicode 碼點。instructions是執行時行為契約。守護程式會在 索取時讀取此欄位,並將其作為代理程式的持久化指令傳送給提供者。 角色、職責、邊界、輸出及升級規則應置於此處, 而非description中。
CLI / API 入口點
最基本的建立呼叫(--name與--runtime-id皆為必填):
multica agent create --name --runtime-id \
--description"" \
--instructions"" \
--output json
runAgentCreate會建立一個 JSON 內容並將其發送至/api/agents。它僅
在提供對應旗標時才會新增鍵值 — 當description/instructions為
描述/說明欄位為非空值時,其餘欄位(runtime-config、custom-args、model、
thinking-level、service-tier、visibility 等)則在參數標記為「Changed」時才加入 — 因此省略的
參數將採用伺服器預設值,而非傳送空字串。
HTTP 請求體(CreateAgentRequest)接受以下參數:name、description、
instructions、avatar_url、runtime_id、runtime_config、custom_env、
custom_args、model、thinking_level、service_tier、visibility、
max_concurrent_tasks、mcp_config。
欄位規範
省略時的預設值:runtime_config→{},custom_env→{},
custom_args→[],avatar_url→ 隨機表情符號:,visibility→
private,max_concurrent_tasks→6
(所有內容均在插入前於伺服器端實體化)。custom_args/runtime_config
的類型為[]string/any,並以原始形式進行序列化 —— JSON 結構不符的
拒絕機制發生在 CLI 中,而非 create 處理程序中。
thinking_level僅在提供者層級進行驗證:固定目錄
提供者會拒絕未識別的字面值,而動態目錄提供者(如
Codex/OpenCode)則會接受語法上安全的標記。 對於
所選模型不支援的值,此處並不會被拒絕 — 守護程式會在執行時檢查其本機模型
目錄,記錄警告,並省略不相容的覆寫。
請透過 CLI 在agent create和agent update 時使用--thinking-level設定此參數,其運作方式與--model 相同:此標誌僅是對頂層
thinking_level欄位的簡易轉遞,而在更新時,若傳入空字串 (--thinking-level "")
則會將其重置為執行時預設值。 命令列介面刻意不列舉
有效的層級 — 這些層級取決於執行時環境與模型(Claude 目前使用
low|medium|high|xhigh|max;Codex 的值則從執行時環境的
模型目錄中取得)。 它會轉發該標記,伺服器會套用提供者的
固定枚舉或安全標記閘門,而守護程式則執行精確的模型/層級
檢查。若某運行時之提供者沒有「思考」概念,則會以 400 狀態碼
拒絕任何非空
值。
service_tier是對應的一等 Codex 速度控制選項。請在建立/更新時使用
--service-tier設定;若要在
更新時清除該設定,請使用--service-tier ""。執行環境的模型目錄同時管理可用性與
顯示副本(目前為優先級,顯示為 Fast)。 伺服器接受安全的
未來 Codex 目錄 ID,而守護程式會在執行前驗證確切的模型/層級組合,
並跳過過時且不相容的覆寫設定。若代理程式未指定
明確的模型,則會因無法識別有效的 config.toml 模型而失敗並關閉。
模型與 custom_args
model是一個一等持久化欄位,守護程式會直接讀取。
custom_args則是原始的提供者 CLI 參數。CLI 說明文件指出,某些提供者
(如 Codex 應用伺服器、Openclaw)會拒絕在custom_args中使用--model—— 但這僅是
文件中記載的 CLI 指引,並非伺服器強制執行的不變條件;在 create
處理程序中,並無任何機制會檢查custom_args是否包含 model 標誌。
環境變數與機密資訊
`custom_env` 屬於機密資料。CLI 提供三種輸入管道;其中兩種可
避免機密資訊出現在 shell 執行紀錄及進程清單中:
multica agent create --name --runtime-id --custom-env-stdin --output json
multica agent create --name --runtime-id --custom-env-file<0600-json> --output json
--custom-env-stdin從標準輸入 (stdin) 讀取 JSON 物件;--custom-env-file
則從檔案中讀取 (建議權限設定為 0600)。 第三種方式,
--custom-env ,會將值放置於命令列上,使 shell 歷史紀錄
和ps 指令能夠讀取到 — 若涉及真正的機密資訊,請避免使用此方式。
讀取端須知(以下為應避免的錯誤假設):
- 代理資源絕不會暴露明文形式的
custom_env。agent list/get/create/update及 WS 事件僅會回傳has_custom_env(布林值) 和custom_env_key_count(整數)。 - 若要讀取明文值,必須透過專用的
GET /api/agents/{id}/env端點(multica agent env get)。此端點僅限工作區擁有者/管理員 成員存取,且無論後端成員的 角色為何,代理程式執行者皆被拒絕存取— 正在運行的代理程式無法讀取其他代理程式的機密資訊。 - 建立後寫入值時,並不會透過
代理程式更新功能進行。通用 更新處理程式會以 400 狀態碼(「請使用 PUT /api/agents/{id}/env」)拒絕任何custom_env欄位。明文環境變數的寫入由PUT /api/agents/{id}/env(Multica 代理環境設定)處理,此操作僅限擁有者/管理員 執行,並會寫入稽核記錄。
mcp_config
mcp_config是代理的 MCP 伺服器配置(一個 JSON 物件,例如
{"mcpServers": {…}})。它同樣屬於機密資料 — MCP 條目通常會嵌入
API 憑證 — 並在代理建立和代理更新時,均提供與custom_env 相同的
三個輸入管道:
multica agent create --name --runtime-id --mcp-config-file<0600-json> --output json
multica agent update --mcp-config-stdin --output json
multica agent update --mcp-config'null' # 清除設定
--mcp-config-stdin/--mcp-config-file可將值排除於 shell 歷史紀錄
及ps 指令之外;而內嵌的--mcp-config則無法做到這點。 此命令列介面要求輸入 JSON
物件或字面值null;若為頂層陣列或基本資料型別,將在
客戶端被拒絕,且空的標準輸入(stdin)或檔案輸入會引發錯誤,而非靜默清除。
mcp_config與custom_env 的兩項差異:
- 它確實可透過
代理程式更新進行設定。與custom_env不同,mcp_config沒有專用的受審計端點 — 通用PUT /api/agents/{id}端點即可 處理此操作。根據原始請求正文的狀態有三種情況:欄位省略 → 不變更;null→ 清除;物件 → 替換。 - 讀取時會進行序列化,但會被遮蔽。
agentget/list僅會將mcp_config回傳給獲准查看代理程式機密資訊的呼叫者;否則該 欄位為null,且mcp_config_redacted為true。代理程式執行者永遠無法 看到它,且工作區可強制對所有人進行遮蔽。
提供者的支援方式並不統一:Qwen Code 接受透過由守護程式擁有的 0600 權限臨時 JSON 檔案傳遞的受管理mcp_config(需透過--mcp-config 參數傳入);該檔案會在執行程序結束時被移除。若將該欄位設為未設定(null),則會繼承 Qwen Code 的原生設定。
技能綁定
建立代理程式並不會綁定任何工作區技能——綁定是代理程式建立後 的獨立呼叫。有兩個不同的動詞:
add為累加式 — 會將指定的 ID 與現有綁定合併 (POST /api/agents/{id}/skills/add)。set為全數替換 — 會將整個綁定清單完全 覆寫為指定的 ID(PUT /api/agents/{id}/skills);--skill-ids ''將清除所有綁定。
multica agent skills add --skill-ids --output json
multica agent skills list --output json
在請求處理時,守護程式會先將代理的技能組裝為「工作區綁定技能」,
然後再附加平台內建技能。LoadAgentSkills會載入每個
綁定技能的內容及其支援檔案;內建技能則在
編譯時嵌入,並從SKILL.md及其同級檔案中載入。兩者皆以
技能內容的形式傳遞給提供者 —— 這就是為何功能應置於綁定技能中,
而非貼入指令中。
需經核准的副作用
唯讀(安全):agent get、agent skills list、agent env get。
會改變狀態(需明確指令 — 請勿預先執行):
multica agent create— 插入新的代理行。multica agent skills add/set— 變更綁定(set屬破壞性操作: 會刪除未包含在新清單中的綁定)。multica agent env set— 覆寫完整的custom_env映射,並寫入一 筆稽核記錄。
常見的錯誤假設
- 「
描述即為提示」。事實並非如此——僅有指令會傳遞至 執行階段。若描述內容豐富但指令欄位為空,將產生一個 無運作合約的命名殼層。 - 「建立會綁定代理的技能。」並非如此;請事後明確進行綁定。
- 「
agent update可以輪替環境。」並非如此 — 它會在custom_env上返回 400 錯誤;請使用 env 端點。 - 「
mcp_config在更新時行為類似custom_env。」並非如此——mcp_config確實可透過agent update(--mcp-config)設定,並可使用--mcp-config null來 清除;僅有custom_env受限於專用的 env 端點之後。 - 「
agent get會顯示環境變數值。」它僅顯示has_custom_env和custom_env_key_count。 - 「建立時會攔截無效的
thinking_level/model組合。」僅會攔截 未知供應商層級的字面值 — 特定模型的缺失會在執行時失敗。 - 「對於技能而言,
set與add可互換使用。」set會替換所有 綁定;若您本意是使用add卻誤用 set,系統會靜默移除相關功能。
參考資料
references/creating-agents-source-map.md將上述每個合約映射至其
在當前樹狀結構中的檔案:行號、執行時效果,以及一個安全的唯讀
驗證指令。
Creating Multica agents
This is the contract for Multica's agent-creation path: what the create entry
points accept, what the server validates and rejects, how each field is
persisted, and which fields the daemon actually reads at claim time. It is
not a parameter manual — it states source-traced facts, and every claim is
backed by file:line in references/creating-agents-source-map.md.
Quick start (read-only inspection)
These commands read state and have no side effects:
multica agent get <agent-id> --output json # full persisted agent record
multica agent skills list <agent-id> --output json # current skill bindings
multica agent env get <agent-id> --output json # plaintext env (owner/admin only, agents denied)
agent get returns the persisted agent including runtime_id, model,
thinking_level, service_tier, custom_args, has_custom_env,
custom_env_key_count, and skills. It never returns plaintext custom_env.
Core model
An agent is a workspace-scoped row (table agent). Creation is a single
POST /api/agents (multica agent create). At task claim time the daemon
re-reads the agent row and assembles the runtime payload — so the persisted
fields, not the create-time output, are what the agent runs on.
Two distinct text fields, often confused:
descriptionis a catalog summary. It is stored and shown in listings; the daemon does NOT inject it into the agent's runtime prompt. Treat it as human-facing metadata only. Capped at 255 Unicode code points.instructionsis the runtime behavior contract. The daemon reads it at claim time and ships it to the provider as the agent's durable instructions. Persona, responsibilities, boundaries, output and escalation rules go here, not indescription.
CLI / API entry points
Minimum create call (--name and --runtime-id are both required):
multica agent create --name <name> --runtime-id <runtime-id> \
--description "<short catalog summary>" \
--instructions "<runtime behavior contract>" \
--output json
runAgentCreate builds a JSON body and posts it to /api/agents. It only
adds a key when its flag was provided — description/instructions on a
non-empty value, the rest (runtime-config, custom-args, model,
thinking-level, service-tier, visibility, …) on the flag being Changed — so omitted
flags fall through to server defaults rather than sending empty strings.
The HTTP body (CreateAgentRequest) accepts: name, description,
instructions, avatar_url, runtime_id, runtime_config, custom_env,
custom_args, model, thinking_level, service_tier, visibility,
max_concurrent_tasks, mcp_config.
Field contracts
Defaults when omitted: runtime_config → {}, custom_env → {},
custom_args → [], avatar_url → a random emoji:<glyph>, visibility →
private, max_concurrent_tasks → 6
(all materialized server-side before the insert). custom_args/runtime_config
are typed []string/any and marshaled as-is — the JSON-shape rejection
happens in the CLI, not the create handler.
thinking_level is validated only at the provider level: fixed-catalog
providers reject an unrecognized literal, while dynamic-catalog providers such
as Codex/OpenCode accept a syntactically safe token. A value unsupported for
the chosen model is NOT rejected here — the daemon checks its local model
catalog at execution time, logs a warning, and omits the incompatible override.
Set it from the CLI with --thinking-level on agent create and agent update, mirroring --model: the flag is a thin pass-through to the top-level
thinking_level field, and on update an empty string (--thinking-level "")
clears it back to the runtime default. The CLI deliberately does not enumerate
the valid levels — they are runtime/model-specific (Claude currently uses
low|medium|high|xhigh|max; Codex values are discovered from the runtime's
model catalog). It forwards the token, the server applies the provider's
fixed-enum or safe-token gate, and the daemon performs the exact model/level
check. A runtime whose provider has no thinking concept rejects any non-empty
value with a 400.
service_tier is the matching first-class Codex speed control. Set it with
--service-tier <catalog-id> on create/update; use --service-tier "" on
update to clear it. The runtime model catalog owns both availability and
display copy (currently priority, shown as Fast). The server accepts safe
future Codex catalog IDs, while the daemon verifies the exact model/tier pair
before execution and omits a stale incompatible override. Agents without an
explicit model fail closed because the effective config.toml model is unknown.
model vs custom_args
model is a first-class persisted column the daemon reads directly.
custom_args are raw provider CLI args. The CLI help notes that some providers
(codex app-server, openclaw) reject --model inside custom_args — but that is
documented CLI guidance, not a server-enforced invariant; nothing in the create
handler inspects custom_args for a model flag.
Env & secrets
custom_env is secret material. The CLI offers three input channels; two keep
secrets out of shell history and the process list:
multica agent create --name <name> --runtime-id <runtime-id> --custom-env-stdin --output json
multica agent create --name <name> --runtime-id <runtime-id> --custom-env-file <0600-json> --output json
--custom-env-stdin reads the JSON object from stdin; --custom-env-file
reads it from a file (suggested mode 0600). The third channel,
--custom-env <json>, puts the value on the command line where shell history
and ps can see it — avoid it for real secrets.
Read-side facts (these are the wrong assumptions to avoid):
- Agent resources never expose plaintext
custom_env.agent list/get/create/updateand WS events return onlyhas_custom_env(bool) andcustom_env_key_count(int). - Reading plaintext values requires the dedicated
GET /api/agents/{id}/envendpoint (multica agent env get). It is gated to workspace owner/admin members, and agent actors are denied regardless of the backing member's role — a running agent cannot read another agent's secrets. - Writing values after creation does NOT go through
agent update. The generic update handler rejects anycustom_envfield with a 400 ("use PUT /api/agents/{id}/env"). Plaintext env writes are handled byPUT /api/agents/{id}/env(multica agent env set), which is owner/admin-only and writes an audit row.
mcp_config
mcp_config is the agent's MCP server configuration (a JSON object such as
{"mcpServers": {…}}). It is also secret material — MCP entries routinely embed
API tokens — and offers the same three input channels as custom_env, on BOTH
agent create and agent update:
multica agent create --name <name> --runtime-id <runtime-id> --mcp-config-file <0600-json> --output json
multica agent update <agent-id> --mcp-config-stdin --output json
multica agent update <agent-id> --mcp-config 'null' # clears the config
--mcp-config-stdin / --mcp-config-file keep the value out of shell history
and ps; the inline --mcp-config <json> does not. The CLI requires a JSON
object or the literal null; a top-level array or primitive is rejected
client-side, and empty stdin/file input errors rather than silently clearing.
Two ways mcp_config differs from custom_env:
- It IS settable through
agent update. Unlikecustom_env,mcp_confighas no dedicated audited endpoint — the genericPUT /api/agents/{id}accepts it. Tri-state per the raw request body: field omitted → no change;null→ clear; object → replace. - It is serialized on read, but redacted.
agent get/listreturnmcp_configonly to callers allowed to view agent secrets; otherwise the field isnullandmcp_config_redactedistrue. Agent actors never see it, and a workspace may force redaction for everyone.
Provider support is not uniform: Qwen Code accepts a managed mcp_config through a daemon-owned 0600 temporary JSON file passed with --mcp-config; it is removed when the run exits. Leave the field unset (null) to inherit Qwen Code native settings.
Skill binding
Creating an agent does NOT bind any workspace skill — binding is a separate call after the agent exists. Two distinct verbs:
addis additive — it merges the given ids with existing bindings (POST /api/agents/{id}/skills/add).setis replace-all — it overwrites the entire binding list with exactly the given ids (PUT /api/agents/{id}/skills);--skill-ids ''clears all.
multica agent skills add <agent-id> --skill-ids <skill-id> --output json
multica agent skills list <agent-id> --output json
At claim time the daemon assembles the agent's skills as workspace-bound skills
FIRST, then appends the platform built-in skills. LoadAgentSkills loads each
bound skill's content plus its supporting files; built-in skills are embedded
at compile time and loaded from SKILL.md + sibling files. Both reach the
provider as skill content — which is why capability belongs in a bound skill,
not pasted into instructions.
Side effects needing approval
Read-only (safe): agent get, agent skills list, agent env get.
State-changing (require an explicit instruction — do not run speculatively):
multica agent create— inserts a new agent row.multica agent skills add/set— mutate bindings (setis destructive: it drops bindings not in the new list).multica agent env set— overwrites the fullcustom_envmap and writes an audit row.
Common wrong assumptions
- "
descriptionis the prompt." It is not — onlyinstructionsreaches the runtime. A rich description with empty instructions yields a named shell with no operating contract. - "Create binds the agent's skills." It does not; bind explicitly afterward.
- "
agent updatecan rotate env." It cannot — it 400s oncustom_env; use the env endpoint. - "
mcp_configbehaves likecustom_envon update." It does not —mcp_configIS settable viaagent update(--mcp-config), with--mcp-config nullto clear; onlycustom_envis gated behind the dedicated env endpoint. - "
agent getshows env values." It shows onlyhas_custom_envandcustom_env_key_count. - "An invalid
thinking_level/modelcombo is caught at create." Only an unknown provider-level literal is — model-specific gaps fail at run time. - "
setandaddare interchangeable for skills."setreplaces all bindings; using it when you meantaddsilently removes capabilities.
References
references/creating-agents-source-map.md maps every contract above to its
file:line on the current tree, the runtime effect, and a safe read-only
verification command.
所有檔案
0 個檔案安裝 multica-creating-agents
請下載並將技能檔案解壓縮至您的 .claude/skills/ 目錄中。
下載 ZIP複製儲存庫並將技能檔案複製到您的專案中。
git clone https://github.com/multica-ai/multica/tree/main/server/internal/service/builtin_skills/multica-creating-agents # Copy the skill folder to .claude/skills/ or .codex/skills/
複製





首頁
