Skip to content

Commit 02f565e

Browse files
authored
Merge pull request #59 from sandeepkhot/Select_AI_Agents_v1
NL2SQL Data Retrieval Agent
2 parents 906bdd7 + a8253fc commit 02f565e

16 files changed

Lines changed: 3022 additions & 384 deletions

autonomous-ai-agents/README.md

Lines changed: 95 additions & 219 deletions
Original file line numberDiff line numberDiff line change
@@ -1,300 +1,176 @@
1-
# Autonomous AI Agents for OCI (Oracle Autonomous Database)
21

3-
## Overview
4-
5-
This repository provides a **modular, extensible framework** for building **OCI AI Agents** using **Oracle Autonomous Database** and **`DBMS_CLOUD_AI_AGENT` (Select AI)**.
6-
7-
Each OCI service (Vault, Object Storage, Autonomous Database, Network Load Balancer, etc.) is implemented using a **two-layer model**:
8-
9-
- **Tools Layer**
10-
- Installs reusable PL/SQL functions
11-
- Registers them as AI tools
12-
- **Agent Layer**
13-
- Creates sample tasks, agents, and teams
14-
- Consumes the tools created in the Tools layer
15-
16-
### Benefits of This Design
17-
18-
- Reuse tools across multiple agents
19-
- Allow end users to create custom agents and tasks
20-
- Clear separation of:
21-
- Infrastructure logic
22-
- AI orchestration logic
23-
24-
---
25-
26-
## Design Principles
27-
28-
### 1. Two-Layer Architecture
29-
30-
Each OCI service is implemented using **two SQL scripts**:
31-
32-
| Layer | Script Pattern | Purpose |
33-
|------|---------------|---------|
34-
| Tools Layer | `*_tools.sql` | Installs core PL/SQL logic and registers AI tools |
35-
| Agent Layer | `*_agent.sql` | Creates a sample Task, Agent, and Team using those tools |
36-
37-
This design ensures:
38-
- Tools are reusable across multiple agents
39-
- Agent behavior remains customizable
40-
41-
---
42-
43-
## Tools Scripts (`*_tools.sql`)
44-
45-
### Purpose
46-
47-
Tools scripts are responsible for **infrastructure and capability enablement**.
2+
# Select AI Agents on Oracle Autonomous AI Database
483

49-
**Example:**
50-
- `oci_vault_tools.sql`
51-
52-
---
53-
54-
### What a Tools Script Does
4+
## Overview
555

56-
A tools script typically performs the following steps:
6+
This repository provides a **generic, extensible framework for building Select AI Agents on Oracle Autonomous AI Database** using the **Select AI Agent framework**.
577

58-
#### 1. Grant Required Privileges
8+
Select AI Agents enable natural language interactions with enterprise data by combining large language models (LLMs), database-resident tools, and orchestration logic directly inside Oracle Database. Agents can reason over user input, invoke tools, and return structured, explainable results — all while keeping data governance, security, and execution within the database.
599

60-
- Grants access to:
61-
- `DBMS_CLOUD`
62-
- `DBMS_CLOUD_AI`
63-
- `DBMS_CLOUD_AI_AGENT`
64-
- Relevant OCI typed API packages
65-
- Privileges are scoped to the **target schema**
10+
The agents in this repository are **generic Select AI agents**. While some examples may interact with Oracle services, the framework itself is not limited to any specific domain or platform and can support many different types of agents and workflows.
6611

6712
---
6813

69-
#### 2. Create Configuration Table
14+
## What is a Select AI Agent?
7015

71-
Creates a generic configuration table:
16+
Select AI Agents are part of the Oracle Autonomous AI Database Select AI framework. A Select AI Agent:
7217

73-
```sql
74-
OCI_AGENT_CONFIG
75-
```
76-
77-
**Stores configuration such as:**
78-
- Credential name
79-
- Compartment name / OCID
80-
- Resource principal enablement
81-
82-
> Configuration is **agent-specific** and persisted for runtime use.
18+
- Accepts natural language input from users
19+
- Uses an LLM to reason about the request
20+
- Invokes database-resident tools (PL/SQL functions)
21+
- Executes logic securely inside the database
22+
- Returns structured responses
8323

84-
---
24+
Key characteristics of the Select AI Agent framework include:
8525

86-
#### 3. Initialize Configuration
26+
- Native integration with Oracle Autonomous AI Database
27+
- Tool execution through PL/SQL
28+
- Support for tasks, agents, and teams
29+
- Centralized governance and monitoring
30+
- Flexibility to build domain-specific or generic agents
8731

88-
- Parses optional JSON configuration input
89-
- Enables resource principal authentication if requested
90-
- Persists configuration values
32+
For full details, refer to the official documentation:
33+
https://docs.oracle.com/en-us/iaas/autonomous-database-serverless/doc/select-ai-agent.html
9134

9235
---
9336

94-
#### 4. Create PL/SQL Package
95-
96-
**Example package:**
97-
98-
```sql
99-
oci_vault_agents
100-
```
101-
102-
**Package responsibilities:**
103-
- Implements core OCI API logic
104-
- Calls OCI APIs using `DBMS_CLOUD_OCI_*`
105-
- Each function:
106-
- Returns **CLOB JSON**
107-
- Includes:
108-
- Status codes
109-
- Headers
110-
- Response payloads
37+
## Design Principles
11138

112-
---
39+
### 1. Two-Layer Architecture
11340

114-
#### 5. Register AI Tools
41+
Each agent implementation follows a two-layer model using separate SQL scripts.
11542

116-
- Uses `DBMS_CLOUD_AI_AGENT.CREATE_TOOL`
117-
- Maps each PL/SQL function to an AI tool
118-
- Adds rich instructions describing:
119-
- When to use the tool
120-
- Safety rules (e.g. no secret exposure)
121-
- Expected behavior
43+
| Layer | Script Pattern | Purpose |
44+
|--------------|-----------------|---------|
45+
| Tools Layer | `*_tools.sql` | Installs core PL/SQL logic and registers Select AI tools |
46+
| Agent Layer | `*_agent.sql` | Creates a sample Task, Agent, and Team using those tools |
12247

123-
---
48+
This design provides:
12449

125-
### Key Characteristics of Tools
50+
- **Tools** that are reusable across multiple agents
51+
- **Agents** as examples for customizable behavior
12652

127-
- Service-specific but **agent-agnostic**
128-
- Reusable by any task or agent
129-
- Safe to re-run (drop & recreate logic)
130-
- Designed for **human-readable AI responses**
53+
The clear separation between tools and agents allows infrastructure logic to remain stable while agent behavior can be easily adapted or extended.
13154

13255
---
13356

134-
## Agent Scripts (`*_agent.sql`)
57+
## Repository Structure
13558

136-
### Purpose
59+
The repository is organized to align with the Select AI Agent framework:
13760

138-
Agent scripts create **example AI agents** demonstrating how to use the tools.
139-
140-
**Example:**
141-
- `oci_vault_agent.sql`
61+
- Tools scripts define and register reusable PL/SQL functions
62+
- Agent scripts demonstrate how those tools are composed into tasks, agents, and teams
63+
- Additional agents can be created without modifying existing tools
14264

14365
---
14466

145-
### What an Agent Script Does
67+
## Agent Configuration (`SELECTAI_AGENT_CONFIG`)
14668

147-
#### 1. Interactive Execution
69+
### Overview
14870

149-
Prompts for:
150-
- Target schema name
151-
- AI Profile name
71+
Select AI agents use a shared configuration table named `SELECTAI_AGENT_CONFIG` to store **agent-specific configuration parameters**.
15272

153-
This makes scripts **portable across environments**.
73+
The table is generic and can be used by any Select AI agent (for example, NL2SQL data retrieval agents or other domain-specific agents). Each agent persists only the configuration keys it requires, while default behavior applies when values are not provided.
15474

15575
---
15676

157-
#### 2. Grant Required Privileges
77+
### Column Description
15878

159-
Grants:
160-
- `DBMS_CLOUD_AI_AGENT`
161-
- `DBMS_CLOUD`
79+
| Column | Description |
80+
|------|------------|
81+
| `ID` | System-generated unique identifier |
82+
| `KEY` | Configuration parameter name |
83+
| `VALUE` | Configuration value (stored as CLOB) |
84+
| `AGENT` | Logical name of the Select AI agent(Available in tools) |
16285

163-
To the target schema.
86+
Configuration entries are uniquely identified by the combination of `KEY` and `AGENT`.
16487

16588
---
16689

167-
#### 3. Create Installer Procedure
90+
### Writing Configuration Entries
16891

169-
- Creates an installer procedure in the target schema
170-
- Keeps all agent logic **schema-local**
92+
Configuration values are written during agent installation or setup.
93+
Only explicitly provided values are persisted; agents apply internal defaults when values are absent.
17194

17295
---
17396

174-
#### 4. Create AI Task
175-
176-
Defines:
177-
- User intent detection
178-
- Allowed tools
179-
- Safety rules
180-
- Formatting expectations
97+
### Example Configuration Entries
18198

182-
Enforces:
183-
- Confirmation for destructive actions
184-
- Human-readable output
99+
#### NL2SQL Data Retrieval Agent
185100

186-
---
101+
```sql
102+
INSERT INTO SELECTAI_AGENT_CONFIG ("KEY", "VALUE", "AGENT")
103+
VALUES ('ENABLE_RESOURCE_PRINCIPAL', 'YES', 'NL2SQL_DATA_RETRIEVAL_AGENT');
187104

188-
#### 5. Create AI Agent
105+
INSERT INTO SELECTAI_AGENT_CONFIG ("KEY", "VALUE", "AGENT")
106+
VALUES ('CREDENTIAL_NAME', 'MY_DB_CREDENTIAL', 'NL2SQL_DATA_RETRIEVAL_AGENT');
107+
```
189108

190-
- Binds the agent to the specified AI Profile
191-
- Defines the agent’s role and behavior
109+
### JSON-Based Configuration Input
192110

193-
---
111+
Agent installers may accept configuration as JSON input.
194112

195-
#### 6. Create AI Team
113+
Example:
196114

197-
- Links the agent and task
198-
- Uses **sequential execution**
115+
```{
116+
"use_resource_principal": true,
117+
"credential_name": "MY_DB_CREDENTIAL"
118+
}
119+
```
199120

200-
---
121+
The installer parses the JSON and stores the relevant values in SELECTAI_AGENT_CONFIG.
201122

202-
#### 7. Execute Installer
123+
### Reading Configuration at Runtime
203124

204-
- Runs the installer procedure
205-
- Completes agent setup
125+
At runtime, agents read their configuration from SELECTAI_AGENT_CONFIG and consume it as structured JSON. This allows configuration changes without modifying agent code.
206126

207-
---
208127

209-
### Key Characteristics of Agents
128+
## Supported Use Cases
210129

211-
- Agents are **examples**, not hard dependencies
212-
- End users can:
213-
- Modify tasks
214-
- Create new agents
215-
- Create multiple teams
216-
- Tools remain unchanged and reusable
130+
This framework can be used to build Select AI agents for:
217131

218-
---
132+
- Natural language to SQL (NL2SQL)
133+
- Data retrieval and analytics
134+
- Database administration and monitoring
135+
- Operational workflows
136+
- Custom enterprise automation
219137

220-
## Example: OCI Vault
221-
222-
### Files
223-
224-
| File | Description |
225-
|-----|------------|
226-
| `oci_vault_tools.sql` | Installs Vault PL/SQL package, config table, and AI tools |
227-
| `oci_vault_agent.sql` | Creates a sample Vault task, agent, and team |
138+
Agents can target database-only workflows, service integrations, or mixed enterprise use cases.
228139

229140
---
230141

231-
### Supported Capabilities
142+
## Compatibility and Release Support
232143

233-
The Vault tools support:
144+
Select AI capabilities vary by database release. For details on supported features across Autonomous Database and compatible non-Autonomous Database releases, refer to the official Select AI Capability Matrix:
234145

235-
- List secrets
236-
- Get secret metadata
237-
- Create secrets
238-
- Update secrets / rotate versions
239-
- List secret versions
240-
- Get specific secret versions
241-
- Schedule and cancel deletions
242-
- Change secret compartment
243-
244-
**All operations:**
245-
- Use persisted configuration
246-
- Require confirmation for destructive actions
247-
- Never expose secret payloads unintentionally
146+
https://docs.oracle.com/en/database/oracle/oracle-database/26/saicm/select-ai-capability-matrix.pdf
248147

249148
---
250149

251-
## Installation Order (Recommended)
252-
253-
For each OCI service:
150+
## Getting Started
254151

255-
1. Run `*_tools.sql`
256-
2. Run `*_agent.sql` (optional, for sample agent)
257-
258-
### Example (OCI Vault)
259-
260-
```sql
261-
-- Step 1: Install tools
262-
sqlplus admin@db @oci_vault_tools.sql <INSTALL_SCHEMA>
263-
264-
-- Step 2: Install sample agent
265-
sqlplus admin@db @oci_vault_agent.sql
266-
```
152+
1. Run the Tools layer scripts to install and register Select AI tools.
153+
2. Run the Agent layer scripts to create sample tasks, agents, and teams.
154+
3. Customize existing agents or create new ones by composing available tools.
155+
4. Extend the framework by adding new tools and agent definitions.
267156

268157
---
269158

270-
## Customization & Extension
159+
## Intended Audience
271160

272-
- Create your own tasks, agents, and teams
273-
- Tools remain stable and reusable
274-
- Multiple agents can share the same tools
275-
- Configuration can be updated in:
161+
This repository is intended for:
276162

277-
```sql
278-
OCI_AGENT_CONFIG
279-
```
163+
- Database developers
164+
- Data engineers
165+
- Architects
166+
- Platform teams
167+
- AI practitioners working with Oracle Autonomous AI Database
280168

281-
---
282-
283-
## Error Handling & Safety
284-
285-
- Scripts exit immediately on SQL errors
286-
- All destructive OCI operations require confirmation
287-
- Tools return structured JSON containing:
288-
- Status
289-
- Headers
290-
- Payload
291-
- Fully re-runnable with safe drop-and-create logic
169+
Anyone looking to build secure, database-native AI agents using Select AI can use this repository as a starting point.
292170

293171
---
294172

295173
## License
296174

297175
This project is licensed under the **Universal Permissive License (UPL), Version 1.0**.
298-
299-
See:
300-
https://oss.oracle.com/licenses/upl/
176+
See: https://oss.oracle.com/licenses/upl/

0 commit comments

Comments
 (0)