multica-ai/multica · error

copy agent: %w

Error message

copy agent: %w

What it means

Thrown by `multica agent copy` when the final POST /api/agents that creates the copy fails. The wrapped error exposes the server's rejection: 4xx validation errors (invalid model for the runtime, bad body fields), 401/403 auth issues, or 5xx/connection failures. All earlier local validation has passed by this point, so the cause is server-side.

Source

Thrown at server/cmd/multica/cmd_agent_copy.go:280

		body["custom_env"] = ce
	}
	if mc, ok, err := resolveMcpConfig(cmd); err != nil {
		return err
	} else if ok {
		body["mcp_config"] = mc
	}
	if cmd.Flags().Changed("runtime-config") {
		v, _ := cmd.Flags().GetString("runtime-config")
		var rc any
		if err := json.Unmarshal([]byte(v), &rc); err != nil {
			return fmt.Errorf("--runtime-config must be valid JSON: %w", err)
		}
		body["runtime_config"] = rc
	}

	var result map[string]any
	if err := client.PostJSON(ctx, "/api/agents", body, &result); err != nil {
		return fmt.Errorf("copy agent: %w", err)
	}

	output, _ := cmd.Flags().GetString("output")
	if output == "json" {
		return cli.PrintJSON(os.Stdout, result)
	}

	fmt.Printf("Agent copied: %s (%s)\n", strVal(result, "name"), strVal(result, "id"))
	return nil
}

func copiedAgentMaxConcurrentTasks(value any) (int32, bool) {
	number, ok := value.(float64)
	if !ok || number != math.Trunc(number) ||
		number < float64(agentconfig.MinMaxConcurrentTasks) ||
		number > float64(agentconfig.MaxMaxConcurrentTasks) {
		return 0, false
	}

View on GitHub (pinned to 2c0912b6ec)

Solutions

  1. Read the wrapped error body — it names the rejected field (e.g. unknown model)
  2. Verify the model exists on the target runtime and re-run with a valid --model
  3. On auth/connection failures, re-authenticate and confirm the server URL, then retry

Example fix

# before
multica agent copy <id> --runtime-id rt_other --model gpt-4o   # model not on that runtime
# after
multica agent copy <id> --runtime-id rt_other --model <model-listed-for-runtime>
Defensive patterns

Strategy: try-catch

Validate before calling

# pre-validate the model on the target runtime before copying
multica runtime models "$TARGET_RT" --output json | jq -e --arg m "$MODEL" 'map(.id) | index($m)' >/dev/null \
  || { echo "model $MODEL not on runtime $TARGET_RT" >&2; exit 1; }
multica agent copy "$AGENT_ID" --runtime-id "$TARGET_RT" --model "$MODEL"

Try / catch

In Go: var result map[string]any; if err := client.PostJSON(ctx, "/api/agents", body, &result); err != nil { return fmt.Errorf("copy agent: %w", err) } — unwrap the HTTP error and branch on status: 4xx means fix the body (model/name fields), 401 re-auth, 5xx/network retry with backoff.

Prevention

When it happens

Trigger: Cross-runtime copy with a --model that does not exist on the target runtime; workspace limits reached; duplicate name conflicts if the server enforces them; API version mismatch between CLI and server.

Common situations: Model names that differ across runtimes (the exact risk error 272 warns about); expired tokens between the GET and POST; server-side schema changes after a CLI/server version skew.

Related errors


AI-assisted analysis of multica-ai/multica@2c0912b6ec (2026-08-15). Data as JSON: /api/errors/2ddbe556c98ffd93. Report an issue: GitHub.