Select AI Agent for Python

Use the select_ai.agent submodule to create and manage in-database AI agent tools, tasks, agents, and teams from Python.

Select AI Agent for Python builds on the select_ai client library and the DBMS_CLOUD_AI_AGENT package. It supports synchronous and asynchronous agent workflows in Autonomous AI Database.

Supported Platforms

For supported Select AI for Python platforms, see Supported Platforms.

Report product issues in the Select AI for Python GitHub repository.

Install Select AI Agent for Python

Install the Select AI for Python package with pip:

python3 -m pip install select_ai

Select AI Agent classes are included in the select_ai.agent submodule.

Manage Database Privileges

Select AI Agent for Python requires access to the DBMS_CLOUD_AI_AGENT database package. Use the following APIs to grant or revoke database package privileges:

select_ai.grant_privileges(...)
select_ai.revoke_privileges(...)

For information about privilege, HTTP access, and external host network access management, see Manage Database Privileges and Network Access.

What You Can Do

The following table summarizes the primary Select AI Agent for Python capabilities:

Capability Description
Tools Create and manage tools for natural-language-to-SQL, web search, Retrieval-Augmented Generation, PL/SQL, notifications, and custom functions.
Tasks Define task logic and configure the tools that a task uses.
Agents Assign agent roles and AI profiles.
Teams Assemble and run multi-agent teams programmatically.
Team export and import Export or import agent team specifications synchronously or asynchronously.
Synchronous and asynchronous APIs Use synchronous APIs or Python async and await constructs based on application requirements.
Object lifecycle management Retrieve, update, and delete database-backed agent objects.

Supported Classes

The following table summarizes the primary Select AI Agent for Python classes:

Class or class group Purpose
Tool and AsyncTool Create and manage AI agent tools.
Task and AsyncTask Create and manage task logic and tool use.
Agent and AsyncAgent Create and manage agents, their roles, profiles, and tasks.
Team and AsyncTeam Create, run, export, and import multi-agent teams.

Work with Tools

Use tools to provide capabilities that an agent can call when processing a task. You can create SQL, web search, Retrieval-Augmented Generation, PL/SQL, Slack notification, and email notification tools.

Tool creation APIs support the instruction parameter. Use this parameter to define precise tool run behavior.

Web search and notification tools require credentials and network access for the external service. SQL and RAG tools require existing Select AI profiles.

Work with Tasks

Use tasks to define the work that an agent performs and the tools that the agent can use. Configure the instruction and tools attributes to control how the agent processes requests.

You can use the optional input attribute to make a task depend on the output of an earlier task.

Work with Agents

Use agents to associate a role and an AI profile. The profile supplies the model that the agent uses for planning and reasoning, while the role defines the agent’s intended behavior.

Work with Agent Teams

Use teams to assemble and run multiple agents programmatically. A team pairs agents with tasks and supports agentic workflows in which specialized agents coordinate to complete a request.

Set the team process attribute to sequential to run task assignments in order. Reuse an agent in multiple team entries when that agent must perform multiple tasks.

Use Team.run(...) to start a team workflow. The prompt argument is passed to the task and can be referenced in task instructions with {query}.

Export and Import Agent Teams

Select AI for Python 1.4 adds synchronous and asynchronous APIs to export and import AI agent teams. A team specification includes the team composition and the related agent, task, and tool definitions.

Synchronous APIs:

Team.export_team(...)
Team.import_team(...)

Asynchronous APIs:

AsyncTeam.export_team(...)
AsyncTeam.import_team(...)

Team.export_team() returns a JSON specification by default. Team.import_team() accepts that JSON specification or a Python mapping containing the team definition. Specify team_name to import a team under a new name.

To write a specification to object storage or import one from object storage, provide object_storage_credential_name and location. Set force=True to replace conflicting tools, tasks, agents, or teams when importing.

For the complete release details, see python-select-ai v1.4.0.

Retrieve and Update Existing Objects

Select AI Agent for Python provides consistent methods for retrieving and updating database-backed proxy objects:

Method Purpose
fetch() Retrieves an existing database object and returns its corresponding proxy object.
set_attribute() Updates one attribute on a proxy object.
set_attributes() Updates multiple attributes on a proxy object.

These methods provide a consistent way to work with tools, tasks, agents, teams, and other supported proxy objects.

Delete Objects with Class Methods

Use class-level delete methods when an application must delete an object without first creating or fetching a proxy object.

Agent.delete_agent(agent_name)
Task.delete_task(task_name)
Tool.delete_tool(tool_name)
Team.delete_team(team_name)

Use Synchronous and Asynchronous APIs

Select AI Agent for Python provides synchronous and asynchronous APIs for its primary operations.

The following table maps synchronous classes to their asynchronous equivalents:

Synchronous class Asynchronous equivalent
Tool AsyncTool
Task AsyncTask
Agent AsyncAgent
Team AsyncTeam

Use asynchronous APIs in applications that:

  • Process multiple agent workflows concurrently.
  • Use an event loop.
  • Integrate with asynchronous Python frameworks.
  • Must avoid blocking while waiting for database operations.

For the complete asynchronous API reference, see the Select AI for Python API Reference.

Related Resources