Skip to content

Commit ed020b6

Browse files
committed
agents creation templates
1 parent 3af0e57 commit ed020b6

File tree

10 files changed

+5021
-100
lines changed

10 files changed

+5021
-100
lines changed
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
-- Copyright (c) 2025 Oracle and/or its affiliates.
2+
-- Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
3+
--
4+
-- ======================================================================
5+
-- Purpose:
6+
-- Install and configure an OCI Autonomous Database AI Agent using
7+
-- DBMS_CLOUD_AI_AGENT (Select AI / Oracle AI Database).
8+
-- ======================================================================
9+
10+
SET SERVEROUTPUT ON
11+
SET VERIFY OFF
12+
WHENEVER SQLERROR EXIT SQL.SQLCODE
13+
14+
PROMPT ======================================================
15+
PROMPT OCI Autonomous Database AI Agent Installer
16+
PROMPT ======================================================
17+
18+
-- Target schema
19+
ACCEPT SCHEMA_NAME CHAR PROMPT 'Enter target schema name: '
20+
DEFINE INSTALL_SCHEMA = '&SCHEMA_NAME'
21+
22+
-- AI Profile
23+
ACCEPT PROFILE_NAME CHAR PROMPT 'Enter AI Profile name to be used with the Agent: '
24+
DEFINE PROFILE_NAME = '&PROFILE_NAME'
25+
26+
PROMPT ------------------------------------------------------
27+
PROMPT Installing into schema: &&INSTALL_SCHEMA
28+
PROMPT Using AI Profile : &&PROFILE_NAME
29+
PROMPT ------------------------------------------------------
30+
31+
----------------------------------------------------------------
32+
-- 1. Grants (safe to re-run)
33+
----------------------------------------------------------------
34+
BEGIN
35+
DBMS_OUTPUT.PUT_LINE('Granting required privileges to &&INSTALL_SCHEMA ...');
36+
EXECUTE IMMEDIATE 'GRANT EXECUTE ON DBMS_CLOUD_AI_AGENT TO &&INSTALL_SCHEMA';
37+
EXECUTE IMMEDIATE 'GRANT EXECUTE ON DBMS_CLOUD TO &&INSTALL_SCHEMA';
38+
DBMS_OUTPUT.PUT_LINE('Grants completed.');
39+
END;
40+
/
41+
42+
----------------------------------------------------------------
43+
-- 2. Create installer procedure in target schema
44+
----------------------------------------------------------------
45+
PROMPT Creating installer procedure in &&INSTALL_SCHEMA ...
46+
47+
CREATE OR REPLACE PROCEDURE &&INSTALL_SCHEMA..install_oci_autonomous_database_agent (
48+
p_profile_name IN VARCHAR2
49+
)
50+
AUTHID DEFINER
51+
AS
52+
BEGIN
53+
DBMS_OUTPUT.PUT_LINE('--------------------------------------------');
54+
DBMS_OUTPUT.PUT_LINE('Starting OCI Autonomous Database AI installation');
55+
DBMS_OUTPUT.PUT_LINE('Schema : ' || USER);
56+
DBMS_OUTPUT.PUT_LINE('--------------------------------------------');
57+
58+
------------------------------------------------------------
59+
-- DROP & CREATE TASK
60+
------------------------------------------------------------
61+
BEGIN
62+
DBMS_CLOUD_AI_AGENT.DROP_TASK('OCI_AUTONOMOUS_DATABASE_TASKS');
63+
EXCEPTION
64+
WHEN OTHERS THEN NULL;
65+
END;
66+
67+
DBMS_CLOUD_AI_AGENT.CREATE_TASK(
68+
task_name => 'OCI_AUTONOMOUS_DATABASE_TASKS',
69+
description => 'Task for provisioning and managing OCI Autonomous Databases.',
70+
attributes => '{
71+
"instruction": "Identify the intent of the user request and determine the correct Autonomous Database operation. '
72+
|| 'Prompt the user only for necessary missing details. '
73+
|| 'Ask clarifying questions if intent is ambiguous. '
74+
|| 'When presenting any list, object, or JSON structure to the user, format it in a human-readable way. '
75+
|| 'Confirm destructive actions before execution. '
76+
|| 'User request: {query}",
77+
"tools": [
78+
"LIST_SUBSCRIBED_REGIONS_TOOL",
79+
"LIST_COMPARTMENTS_TOOL",
80+
"GET_COMPARTMENT_OCID_BY_NAME_TOOL",
81+
"LIST_AUTONOMOUS_DATABASES_TOOL",
82+
"GET_AUTONOMOUS_DATABASE_DETAILS_TOOL",
83+
"ADBS_PROVISIONING_TOOL",
84+
"ADBS_UNPROVISION_TOOL",
85+
"START_AUTONOMOUS_DATABASE_TOOL",
86+
"STOP_AUTONOMOUS_DATABASE_TOOL",
87+
"DATABASE_RESTART_TOOL",
88+
"MANAGE_AUTONOMOUS_DB_POWER_TOOL",
89+
"UPDATE_AUTONOMOUS_DB_RESOURCES_TOOL",
90+
"GET_MAINTENANCE_RUN_HISTORY_TOOL",
91+
"UPDATE_AUTONOMOUS_DATABASE_TOOL",
92+
"LIST_KEY_STORES_TOOL",
93+
"LIST_DB_HOMES_TOOL",
94+
"SHRINK_AUTONOMOUS_DATABASE_TOOL",
95+
"DELETE_KEY_STORE_TOOL",
96+
"LIST_APPLICATION_VIPS_TOOL",
97+
"LIST_ACDS_TOOL",
98+
"LIST_ADB_BACKUPS_TOOL",
99+
"HUMAN_TOOL"
100+
]
101+
}'
102+
);
103+
DBMS_OUTPUT.PUT_LINE('Created task OCI_AUTONOMOUS_DATABASE_TASKS');
104+
105+
------------------------------------------------------------
106+
-- DROP & CREATE AGENT
107+
------------------------------------------------------------
108+
BEGIN
109+
DBMS_CLOUD_AI_AGENT.DROP_AGENT('OCI_AUTONOMOUS_DATABASE_ADVISOR');
110+
DBMS_OUTPUT.PUT_LINE('Dropped agent OCI_AUTONOMOUS_DATABASE_ADVISOR');
111+
EXCEPTION
112+
WHEN OTHERS THEN
113+
DBMS_OUTPUT.PUT_LINE('Agent OCI_AUTONOMOUS_DATABASE_ADVISOR does not exist, skipping');
114+
END;
115+
116+
DBMS_CLOUD_AI_AGENT.CREATE_AGENT(
117+
agent_name => 'OCI_AUTONOMOUS_DATABASE_ADVISOR',
118+
attributes =>
119+
'{' ||
120+
'"profile_name":"' || p_profile_name || '",' ||
121+
'"role":"You are an OCI Autonomous Database Advisor. You help users provision, list, start/stop/restart, resize, update configuration, and inspect ADB-related resources safely. You confirm destructive actions and present results clearly."' ||
122+
'}',
123+
description => 'AI agent for advising and automating OCI Autonomous Database operations'
124+
);
125+
DBMS_OUTPUT.PUT_LINE('Created agent OCI_AUTONOMOUS_DATABASE_ADVISOR');
126+
127+
------------------------------------------------------------
128+
-- DROP & CREATE TEAM
129+
------------------------------------------------------------
130+
BEGIN
131+
DBMS_CLOUD_AI_AGENT.DROP_TEAM('OCI_AUTONOMOUS_DATABASE_TEAM');
132+
DBMS_OUTPUT.PUT_LINE('Dropped team OCI_AUTONOMOUS_DATABASE_TEAM');
133+
EXCEPTION
134+
WHEN OTHERS THEN
135+
DBMS_OUTPUT.PUT_LINE('Team OCI_AUTONOMOUS_DATABASE_TEAM does not exist, skipping');
136+
END;
137+
138+
DBMS_CLOUD_AI_AGENT.CREATE_TEAM(
139+
team_name => 'OCI_AUTONOMOUS_DATABASE_TEAM',
140+
attributes => '{
141+
"agents":[{"name":"OCI_AUTONOMOUS_DATABASE_ADVISOR","task":"OCI_AUTONOMOUS_DATABASE_TASKS"}],
142+
"process":"sequential"
143+
}'
144+
);
145+
DBMS_OUTPUT.PUT_LINE('Created team OCI_AUTONOMOUS_DATABASE_TEAM');
146+
147+
DBMS_OUTPUT.PUT_LINE('--------------------------------------------');
148+
DBMS_OUTPUT.PUT_LINE('OCI Autonomous Database AI installation COMPLETE');
149+
DBMS_OUTPUT.PUT_LINE('--------------------------------------------');
150+
END install_oci_autonomous_database_agent;
151+
/
152+
153+
----------------------------------------------------------------
154+
-- 3. Execute installer in target schema
155+
----------------------------------------------------------------
156+
PROMPT Executing installer procedure ...
157+
BEGIN
158+
&&INSTALL_SCHEMA..install_oci_autonomous_database_agent('&&PROFILE_NAME');
159+
END;
160+
/
161+
162+
PROMPT ======================================================
163+
PROMPT Installation finished successfully
164+
PROMPT ======================================================

0 commit comments

Comments
 (0)