选项
首页首页 Skill 其他 multica-creating-agents

multica-creating-agents

multica-ai/multica multica-ai/multica

在通过 `multica agent` CLI 或 `POST /api/agents` 创建、检查或调试 Multica 代理时使用 ——包括各字段的含义、其持久化格式、该字段是仅作为元数据存在还是会在申领时被守护进程消耗、哪些输入会被验证/拒绝、custom_env 密钥的访问控制机制,以及技能绑定的行为方式。不适用于将问题分配给现有代理,也不适用于运行时任务提示。

...展开全部
80
更新时间 2026-08-12

创建 Multica 代理

这是 Multica 代理创建路径的规范:create 入口 点接受哪些参数,服务器会验证并拒绝哪些内容,每个字段如何 被持久化,以及守护进程在索赔时实际读取哪些字段。 本文 并非参数手册——它陈述的是可追溯至源代码的事实,且每项声明均 有references/creating-agents-source-map.md 文件中的“文件:行号”作为依据。

快速入门(只读检查)

这些命令用于读取状态,且无副作用:

multica agent get --output json      # 完整的持久化代理记录
multica agent skills list --output json   # 当前技能绑定
multica agentenvget --output json  # 明文环境变量(仅限所有者/管理员,代理被拒绝访问)

agent get返回包含runtime_idmodelthinking_levelservice_tiercustom_argshas_custom_envcustom_env_key_count 以及技能的持久化代理记录。该命令绝不会返回明文形式的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 主体并将其 POST 到/api/agents。它仅 在提供了相应参数时才会添加键值对——当description/instructions参数 描述/说明参数为非空值时,其余参数(运行时配置自定义参数模型思考级别服务等级可见性等)在该参数被设为“Changed”时才会添加——因此省略的 参数将采用服务器默认值,而非发送空字符串。

HTTP 请求体(CreateAgentRequest)支持以下字段:namedescriptioninstructionsavatar_urlruntime_idruntime_configcustom_envcustom_argsmodelthinking_levelservice_tiervisibilitymax_concurrent_tasksmcp_config

字段规范

省略时的默认值:runtime_config{},custom_env{}, custom_args[],avatar_url→ 随机表情符号:,visibilityprivate,max_concurrent_tasks6 (所有内容均在插入前于服务器端实例化)。custom_args/runtime_config 的类型为[]string/any,并将原样序列化——JSON结构验证 在 CLI 中进行,而非在 create 处理程序中。

thinking_level仅在提供程序层级进行验证:固定目录 提供程序会拒绝未识别的字面量,而动态目录提供程序(如 Codex/OpenCode)则接受语法安全的令牌。 对于所选模型不支持的 值,此处不会被拒绝——守护进程会在运行时检查其本地模型 目录,记录一条警告,并忽略该不兼容的覆盖设置。

可通过 CLI 在agent createagent update 时使用--thinking-level进行设置,其机制与--model 类似:该标志仅作为对顶级 thinking_level字段的简单传递;在更新时,空字符串(--thinking-level "") 会将其重置为运行时默认值。 CLI 故意不列举 有效的级别——它们取决于运行时和模型(Claude 目前使用 low|medium|high|xhigh|max;Codex 的值则从运行时的 模型目录中获取)。 它将令牌转发出去,服务器应用提供商的 固定枚举或安全令牌门控,而守护进程则执行精确的模型/级别 检查。如果提供商不支持“thinking”概念的运行时,会以 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中的模型标志。

环境与密钥

`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从标准输入读取 JSON 对象;--custom-env-file 从文件中读取(建议权限设置为 0600)。 第三种方式, --custom-env ,将值放在命令行上,这样 shell 历史记录 和ps 命令都能看到它——对于真正的机密信息请避免使用此方式。

读取端须知(以下是应避免的错误假设):

  • 代理资源绝不会暴露明文形式的custom_envagent 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}/envMultica 代理环境设置)处理,该操作仅限所有者/管理员 执行,并会生成一条审计记录。

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;顶级数组或基本类型将在客户端被拒绝, 且空的标准输入/文件输入会引发错误,而非静默清空。

mcp_configcustom_env 的两点区别:

  • 它确实可以通过代理更新进行设置。custom_env 不同,mcp_config 没有专用的受审计端点——通用PUT请求/api/agents/{id}即可 处理。根据原始请求正文的三种状态:字段省略 → 不更改;null→ 清空;对象 → 替换。
  • 读取时会进行序列化,但会进行屏蔽处理。 agentget/list仅向 有权查看代理密钥的调用者返回mcp_config;否则该 字段为nullmcp_config_redactedtrue。代理执行体永远无法 看到它,且工作区可强制对所有人进行屏蔽处理。

提供商的支持情况不尽相同: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及其同级文件中加载。这两类技能都会作为技能内容 传递给提供程序——这就是为什么能力应属于绑定技能, 而非粘贴在指令中

需要批准的副作用

只读(安全):获取代理代理技能列表获取代理环境

状态变更(需要显式指令——请勿推测性执行):

  • multica agent create— 插入一条新的代理行。
  • multica agent skills add/set— 修改绑定(set操作具有破坏性: 它会删除未包含在新列表中的绑定)。
  • multica agent env set— 覆盖完整的custom_env映射并写入一条 审计记录。

常见的错误假设

  • 描述即提示”。并非如此——只有指令才会传递到 运行时。如果描述内容丰富但指令为空,则会生成一个 没有操作契约的命名 shell。
  • “Create 会绑定代理的技能。”并非如此;需在之后显式进行绑定。
  • “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_envcustom_env_key_count
  • “创建时会捕获无效的thinking_level/model组合。”仅 未知提供商级字面量会被捕获——特定于模型的缺失项会在运行时失败。
  • “对于技能而言,setadd可以互换使用。”set会替换所有 绑定;若本意是使用add却误用了 set,系统会静默移除相应能力。

参考资料

references/creating-agents-source-map.md将上述每项契约映射到当前树结构中的 文件:行号、运行时效果以及一个安全的只读 验证命令。

在 GitHub 上查看

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:

  • description is 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.
  • instructions is 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 in description.

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>, visibilityprivate, max_concurrent_tasks6 (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/update and WS events return only has_custom_env (bool) and custom_env_key_count (int).
  • Reading plaintext values requires the dedicated GET /api/agents/{id}/env endpoint (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 any custom_env field with a 400 ("use PUT /api/agents/{id}/env"). Plaintext env writes are handled by PUT /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. Unlike custom_env, mcp_config has no dedicated audited endpoint — the generic PUT /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/list return mcp_config only to callers allowed to view agent secrets; otherwise the field is null and mcp_config_redacted is true. 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:

  • add is additive — it merges the given ids with existing bindings (POST /api/agents/{id}/skills/add).
  • set is 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 (set is destructive: it drops bindings not in the new list).
  • multica agent env set — overwrites the full custom_env map and writes an audit row.

Common wrong assumptions

  • "description is the prompt." It is not — only instructions reaches 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 update can rotate env." It cannot — it 400s on custom_env; use the env endpoint.
  • "mcp_config behaves like custom_env on update." It does not — mcp_config IS settable via agent update (--mcp-config), with --mcp-config null to clear; only custom_env is gated behind the dedicated env endpoint.
  • "agent get shows env values." It shows only has_custom_env and custom_env_key_count.
  • "An invalid thinking_level/model combo is caught at create." Only an unknown provider-level literal is — model-specific gaps fail at run time.
  • "set and add are interchangeable for skills." set replaces all bindings; using it when you meant add silently 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/

复制 复制
快速设置: 将技能文件夹复制到 .claude/skills/ 目录下,Claude 会自动检测并使用该技能

相关技能

tilemaps
更新时间 2026-08-04
v4-new-features
更新时间 2026-08-04
agent-github-pr-manager
更新时间 2026-08-03
pixijs-application
更新时间 2026-08-04
OR