Skip to content

Commit 03f5615

Browse files
committed
Updated the agent code
1 parent 519a8da commit 03f5615

File tree

2 files changed

+57
-2
lines changed

2 files changed

+57
-2
lines changed

autonomous-ai-agents/oci_object_storage/oci_object_storage_agent.sql

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,11 @@ BEGIN
182182
|| '- Bullet points for simple lists. '
183183
|| '- Indented JSON for structured responses. '
184184
|| 'Use LIST_COMPARTMENTS_TOOL to list compartments. '
185-
|| 'Use LIST_SUBSCRIBED_REGIONS_TOOL to list regions and confirm with user. '
186185
|| 'Automatically derive namespace using GET_NAMESPACE_TOOL. '
187186
|| 'Confirm destructive actions before execution. '
188187
|| 'User request: {query}",
189188
"tools": [
190189
"LIST_COMPARTMENTS_TOOL",
191-
"LIST_SUBSCRIBED_REGIONS_TOOL",
192190
"GET_NAMESPACE_TOOL",
193191
"CREATE_BUCKET_TOOL",
194192
"DELETE_BUCKET_TOOL",

autonomous-ai-agents/oci_object_storage/oci_object_storage_tools.sql

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,10 @@ AS
801801
region IN VARCHAR2
802802
) RETURN CLOB;
803803

804+
-- Helper: gets the list of compartments using configured credentials
805+
FUNCTION list_compartments
806+
RETURN CLOB;
807+
804808

805809
END oci_object_storage_agents;
806810
/
@@ -930,6 +934,45 @@ AS
930934
RETURN l_result_json.to_clob();
931935
END list_compartments;
932936

937+
-- Helper: gets the list of compartments using configured credentials
938+
FUNCTION list_compartments
939+
RETURN CLOB
940+
IS
941+
l_result_json JSON_OBJECT_T := JSON_OBJECT_T();
942+
l_current_user VARCHAR2(128) := SYS_CONTEXT('USERENV', 'CURRENT_USER');
943+
l_cfg_json CLOB;
944+
l_cfg JSON_OBJECT_T;
945+
l_params JSON_OBJECT_T;
946+
l_credential_name VARCHAR2(256);
947+
BEGIN
948+
l_cfg_json := get_agent_config(
949+
l_current_user,
950+
'SELECTAI_AGENT_CONFIG',
951+
'OCI_OBJECT_STORAGE'
952+
);
953+
l_cfg := JSON_OBJECT_T.parse(l_cfg_json);
954+
955+
IF l_cfg.get_string('status') = 'success' THEN
956+
l_params := l_cfg.get_object('config_params');
957+
l_credential_name := l_params.get_string('CREDENTIAL_NAME');
958+
END IF;
959+
960+
IF l_credential_name IS NULL OR TRIM(l_credential_name) IS NULL THEN
961+
l_result_json.put('status', 'error');
962+
l_result_json.put('message', 'Credential name is not configured. Set CREDENTIAL_NAME in SELECTAI_AGENT_CONFIG before calling this tool.');
963+
RETURN l_result_json.to_clob();
964+
END IF;
965+
966+
RETURN list_compartments(credential_name => l_credential_name);
967+
968+
EXCEPTION
969+
WHEN OTHERS THEN
970+
l_result_json := JSON_OBJECT_T();
971+
l_result_json.put('status', 'error');
972+
l_result_json.put('message', 'Error: ' || SQLERRM);
973+
RETURN l_result_json.to_clob();
974+
END list_compartments;
975+
933976
-- Helper: gets the compartment ocid with the given compatment name
934977
FUNCTION get_compartment_ocid_by_name(
935978
compartment_name IN VARCHAR2
@@ -4180,6 +4223,20 @@ IS
41804223
END IF;
41814224
END drop_tool_if_exists;
41824225
BEGIN
4226+
------------------------------------------------------------------------
4227+
-- AI TOOL: LIST_COMPARTMENTS_TOOL
4228+
-- maps to oci_object_storage_agents.list_compartments
4229+
------------------------------------------------------------------------
4230+
drop_tool_if_exists(tool_name => 'LIST_COMPARTMENTS_TOOL');
4231+
DBMS_CLOUD_AI_AGENT.CREATE_TOOL(
4232+
tool_name => 'LIST_COMPARTMENTS_TOOL',
4233+
attributes => '{
4234+
"instruction": "List compartments visible to the configured tenancy and credentials, including OCID and lifecycle metadata.",
4235+
"function": "oci_object_storage_agents.list_compartments"
4236+
}',
4237+
description => 'Tool for listing OCI compartments'
4238+
);
4239+
41834240
------------------------------------------------------------------------
41844241
-- AI TOOL: LIST_OBJECTS_TOOL
41854242
-- maps to oci_object_storage_agents.list_objects

0 commit comments

Comments
 (0)