


























@@ -128,6 +128,7 @@ export const ACP_SPAWN_ERROR_CODES = [
128128"subagent_policy",
129129"thread_required",
130130"target_agent_required",
131+"runtime_agent_mismatch",
131132"agent_forbidden",
132133"cwd_resolution_failed",
133134"thread_binding_invalid",
@@ -395,6 +396,24 @@ function resolveTargetAcpAgentId(params: {
395396}): { ok: true; agentId: string } | { ok: false; error: string } {
396397const requested = normalizeOptionalAgentId(params.requestedAgentId);
397398if (requested) {
399+const configuredAgent = params.cfg.agents?.list?.find(
400+(agent) => normalizeOptionalAgentId(agent.id) === requested,
401+);
402+if (configuredAgent?.runtime?.type === "acp") {
403+return {
404+ok: true,
405+agentId: normalizeOptionalAgentId(configuredAgent.runtime.acp?.agent) ?? requested,
406+};
407+}
408+if (configuredAgent && !isExplicitlyAllowedAcpAgent(params.cfg, requested)) {
409+return {
410+ok: false,
411+error:
412+`agentId "${requested}" is an OpenClaw config agent, not an ACP harness. ` +
413+'Use runtime="subagent" or omit runtime for OpenClaw config agents. ' +
414+'Use runtime="acp" only with external ACP harness ids such as codex, claude, gemini, or opencode, or configure agents.list[].runtime.type="acp" with runtime.acp.agent.',
415+};
416+}
398417return { ok: true, agentId: requested };
399418}
400419@@ -410,6 +429,13 @@ function resolveTargetAcpAgentId(params: {
410429};
411430}
412431432+function isExplicitlyAllowedAcpAgent(cfg: OpenClawConfig, agentId: string): boolean {
433+return (cfg.acp?.allowedAgents ?? []).some((entry) => {
434+const normalized = normalizeOptionalAgentId(entry);
435+return normalized === "*" || normalized === agentId;
436+});
437+}
438+413439function normalizeOptionalAgentId(value: string | undefined | null): string | undefined {
414440const trimmed = normalizeOptionalString(value) ?? "";
415441if (!trimmed) {
@@ -1091,7 +1117,10 @@ export async function spawnAcpDirect(
10911117if (!targetAgentResult.ok) {
10921118return createAcpSpawnFailure({
10931119status: "error",
1094-errorCode: "target_agent_required",
1120+errorCode:
1121+params.agentId && normalizeOptionalAgentId(params.agentId)
1122+ ? "runtime_agent_mismatch"
1123+ : "target_agent_required",
10951124error: targetAgentResult.error,
10961125});
10971126}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。