Interface SelectAIAgent
- All Superinterfaces:
AutoCloseable
This interface provides access to the agent framework resources managed by
DBMS_CLOUD_AI_AGENT: agents, tasks, tools, and teams. It also
provides collection-level operations for listing agents, tasks, tools, and
teams, executing teams, inspecting and updating team state, accessing
runtime variables, retrieving object definitions, and importing team
definitions.
Use SelectAIAgent separately from SelectAI so agent
orchestration and application-facing Select AI profile operations remain
explicit. Agent resources may use Select AI profiles, but creating or
managing an agent resource does not create or modify a profile.
SelectAIAgent extends AutoCloseable. Creating a client with
create(DbConnectionConfig) opens one SDK-owned JDBC connection
immediately. Call close() when the client is no longer needed to
release that connection and its database session.
Creating a client with create(DataSource) does not obtain a
connection immediately. The application owns the DataSource; the
SDK borrows a connection for each database operation and closes that
connection after use, returning pooled connections to their pool. Calling
close() does not close the caller-owned DataSource. Each
operation may therefore use a different pooled connection; applications
should not depend on uncommitted transaction or other session state being
available to a later operation.
The name-only agent(String), task(String),
tool(String), and team(String) factories verify that the
current user owns the resources and load their metadata and attributes before returning.
Granted cross-schema teams can be run through runTeam(String, RunTeamRequest)
without loading owner-only metadata.
The owner-scoped list methods also load metadata and attributes for each
returned handle. listAvailableTeams() provides a separate read-only
discovery view backed by DBMS_CLOUD_AI_AGENT.LIST_TEAMS; its results
may include shared teams that cannot be opened with team(String).
The overloads that accept attributes retain their configuration without a
database query; a resource is not persisted until its create()
method succeeds. For agents, required attribute values such as profile name
and role are validated by the database during Agent.create(), not
by the AgentAttributes builder.
For a complete runnable example, see CreateAgentSample source. For an end-to-end example that creates a tool, task, agent, and team, runs the team, and continues the same conversation, see AgentWorkflowSample source.
- Since:
- 1.1.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionLoads an existing agent, including its metadata and attributes.agent(String agentName, AgentAttributes attributes, String description, AgentStatus status) Initializes an agent object for explicit creation.voidclose()Releases resources owned by this client.static SelectAIAgentcreate(DbConnectionConfig dbConnectionConfig) Creates a SelectAIAgent client from database connection configuration.static SelectAIAgentcreate(DbConnectionConfig dbConnectionConfig, SelectAIOptions options) Creates a SelectAIAgent client from database connection configuration and SDK execution options.static SelectAIAgentcreate(DataSource dataSource) Creates a DataSource-backed SelectAIAgent client.static SelectAIAgentcreate(DataSource dataSource, SelectAIOptions options) Creates a DataSource-backed SelectAIAgent client with SDK execution options.getDefinition(AgentObjectType objectType, String objectName, boolean includeDependentObjects) Returns the definition produced byDBMS_CLOUD_AI_AGENT.GET_DEFINITIONfor an agent framework object.getTeamStateByConversationId(String teamName, String conversationId) Returns the latest state for a team run identified by a database conversation identifier.default StringgetVariable(String namespace, String name) Reads an ephemeral runtime variable from the current database session.getVariable(String namespace, String name, String scope) Reads a runtime variable from the current database session and scope.booleangrantTeamAccess(String teamName, String userOrRoleName) Grants a database user or role permission to run an owner-managed team.booleanimportTeam(ImportTeamRequest request) Imports an agent team definition into the database.Lists agents owned by the current database user.listAgents(String agentNamePattern) Lists owned agents whose names match a database regular-expression pattern.Lists teams available to the calling database user for discovery.Lists tasks owned by the current database user.Lists owned tasks whose names match a database regular-expression pattern.Lists agent teams owned by the current database user.Lists owned teams whose names match a database regular-expression pattern.Lists tools owned by the current database user.Lists owned tools whose names match a database regular-expression pattern.booleanrevokeTeamAccess(String teamName, String userOrRoleName) Revokes a database user or role permission to run an owner-managed team.runTeam(String teamName, RunTeamRequest request) Runs an existing team by name without loading owner-only team metadata.booleansetTeamExecutionState(String teamName, ExecutionStateRequest request) Updates the execution state of a team run.default booleansetVariable(String namespace, String name, String value) Sets or clears an ephemeral runtime variable in the current database session.booleansetVariable(String namespace, String name, String value, String scope) Sets or clears a runtime variable in the current database session and scope.Loads an existing task, including its metadata and attributes.task(String taskName, TaskAttributes attributes, String description, TaskStatus status) Initializes a task object for explicit creation.Loads a team owned by the current database user, including its metadata and attributes.team(String teamName, TeamAttributes attributes, String description, TeamStatus status) Initializes a team object for explicit creation.Loads an existing tool, including its metadata and attributes.tool(String toolName, ToolAttributes attributes, String description, ToolStatus status) Initializes a tool object for explicit creation.
-
Method Details
-
create
Creates a SelectAIAgent client from database connection configuration.For a runnable example, see RunTeamSample source.
- Parameters:
dbConnectionConfig- database connection configuration- Returns:
- SelectAIAgent client
- Throws:
IllegalArgumentException- whendbConnectionConfigis nullSelectAIException- when the database connection cannot be initialized
-
create
static SelectAIAgent create(DbConnectionConfig dbConnectionConfig, SelectAIOptions options) throws SelectAIException Creates a SelectAIAgent client from database connection configuration and SDK execution options.For a runnable example, see CreateSelectAIAgentWithOptionsSample source.
- Parameters:
dbConnectionConfig- database connection configurationoptions- SDK execution options;nulluses defaults- Returns:
- SelectAIAgent client
- Throws:
IllegalArgumentException- whendbConnectionConfigis nullSelectAIException- when the database connection cannot be initialized
-
create
Creates a DataSource-backed SelectAIAgent client.For a runnable example, see CreateSelectAIAgentDataSourceSample source.
- Parameters:
dataSource- DataSource used to obtain JDBC connections- Returns:
- SelectAIAgent client
- Throws:
IllegalArgumentException- whendataSourceis null
-
create
Creates a DataSource-backed SelectAIAgent client with SDK execution options.For a runnable example, see CreateSelectAIAgentDataSourceWithOptionsSample source.
- Parameters:
dataSource- DataSource used to obtain JDBC connectionsoptions- SDK execution options;nulluses defaults- Returns:
- SelectAIAgent client
- Throws:
IllegalArgumentException- whendataSourceis null
-
agent
Loads an existing agent, including its metadata and attributes.For a runnable example, see LoadAgentSample source.
- Parameters:
agentName- agent name- Returns:
- database-backed agent object
- Throws:
IllegalArgumentException- whenagentNameis null or blankSelectAIException- when the agent does not exist or its metadata or attributes cannot be loaded
-
agent
Initializes an agent object for explicit creation.For a runnable example, see CreateAgentSample source.
- Parameters:
agentName- agent nameattributes- agent creation attributesdescription- optional agent descriptionstatus- optional initial status;nulluses the database default- Returns:
- agent object configured for creation
- Throws:
IllegalArgumentException- whenagentNameis null or blank, orattributesis null
-
task
Loads an existing task, including its metadata and attributes.For a runnable example, see LoadTaskSample source.
- Parameters:
taskName- task name- Returns:
- database-backed task object
- Throws:
IllegalArgumentException- whentaskNameis null or blankSelectAIException- when the task does not exist or its metadata or attributes cannot be loaded
-
task
Initializes a task object for explicit creation.For a runnable example, see CreateTaskSample source.
- Parameters:
taskName- task nameattributes- task creation attributesdescription- optional task descriptionstatus- optional initial status;nulluses the database default- Returns:
- task object configured for creation
- Throws:
IllegalArgumentException- whentaskNameis null or blank, orattributesis null
-
tool
Loads an existing tool, including its metadata and attributes.For a runnable example, see LoadToolSample source.
- Parameters:
toolName- tool name- Returns:
- database-backed tool object
- Throws:
IllegalArgumentException- whentoolNameis null or blankSelectAIException- when the tool does not exist or its metadata or attributes cannot be loaded
-
tool
Initializes a tool object for explicit creation.For runnable examples, see CreateToolSample source, CreateSqlToolSample source, and ToolParamsSample source.
- Parameters:
toolName- tool nameattributes- tool creation attributesdescription- optional tool descriptionstatus- optional initial status;nulluses the database default- Returns:
- tool object configured for creation
- Throws:
IllegalArgumentException- whentoolNameis null or blank, orattributesis null
-
team
Loads a team owned by the current database user, including its metadata and attributes. To run a granted team owned by another user, userunTeam(String, RunTeamRequest)with an owner-qualified name.For a runnable example, see LoadTeamSample source.
- Parameters:
teamName- team name- Returns:
- database-backed team object
- Throws:
IllegalArgumentException- whenteamNameis null or blankSelectAIException- when the team does not exist or its metadata or attributes cannot be loaded
-
team
Initializes a team object for explicit creation.For a runnable example, see CreateTeamSample source.
- Parameters:
teamName- team nameattributes- team creation attributesdescription- optional team descriptionstatus- optional initial status;nulluses the database default- Returns:
- team object configured for creation
- Throws:
IllegalArgumentException- whenteamNameis null or blank, orattributesis null
-
runTeam
Runs an existing team by name without loading owner-only team metadata. A consumer can run a team granted by another database user with a name such asTEAM_OWNER.SHARED_SUPPORT_TEAM. The database checks team existence and the caller's access; this method does not grant access to manage the team's definition. Without established session context, the request must contain a database-created conversation identifier. The operation is synchronous. InDataSourcemode, the borrowed JDBC connection can remain occupied for the duration of the workflow. The SDK does not provide a cancellation API, and a JDBC timeout or interrupted call may not stop server-side or provider work. Retry only when the workflow is known to be safe to repeat.For a runnable example, see RunSharedTeamSample source.
For a human-input workflow resumed in a new process through a pooled
DataSource, see PooledTeamResumeSample source.- Parameters:
teamName- team name, optionally owner-qualifiedrequest- prompt and optional runtime parameters- Returns:
- typed team-run result retaining the database response
- Throws:
IllegalArgumentException- whenteamNameis null or blank, orrequestis nullSelectAIException- when the database rejects or cannot complete the run
-
getTeamStateByConversationId
TeamExecutionState getTeamStateByConversationId(String teamName, String conversationId) throws SelectAIException Returns the latest state for a team run identified by a database conversation identifier.This operation does not load a
Teamhandle and supports an owner-qualified team name for a shared team.For a runnable example, see GetTeamStateSample source. For a runnable example that verifies
WAITING_FOR_HUMANbefore resuming through a pooledDataSource, see PooledTeamResumeSample source.- Parameters:
teamName- team name, optionally owner-qualifiedconversationId- existing database conversation identifier- Returns:
- typed team execution state retaining the original database value
- Throws:
IllegalArgumentException- when either argument is null or blankSelectAIException- when the database operation fails- Since:
- 1.1.0
-
setTeamExecutionState
boolean setTeamExecutionState(String teamName, ExecutionStateRequest request) throws SelectAIException Updates the execution state of a team run.This operation does not load a
Teamhandle and therefore also supports an owner-qualified team name for a team granted to the current database user. Set the request's conversation identifier to address a run across pooled database connections.For a runnable example, see SetTeamExecutionStateSample source.
- Parameters:
teamName- team name, optionally owner-qualifiedrequest- execution state and a typed conversation identifier- Returns:
truewhen the database operation succeeds- Throws:
IllegalArgumentException- whenteamNameis null or blank, orrequestis null or does not identify a conversationSelectAIException- when the database operation fails
-
grantTeamAccess
Grants a database user or role permission to run an owner-managed team. The connected database user must own the team, andteamNamemust be the owner's unqualified team name. This method does not load aTeamhandle and is useful when the owner wants a client-level sharing operation.For a runnable example, see GrantTeamAccessSample source.
- Parameters:
teamName- owner's unqualified team nameuserOrRoleName- database user or role receiving execution access- Returns:
truewhen the database accepts the grant- Throws:
IllegalArgumentException- when either name is null, blank, invalid, or the grantee isPUBLICSelectAIException- when the database rejects or cannot complete the grant- Since:
- 1.1.0
-
revokeTeamAccess
Revokes a database user or role permission to run an owner-managed team. The connected database user must own the team, andteamNamemust be the owner's unqualified team name.For a runnable example, see RevokeTeamAccessSample source.
- Parameters:
teamName- owner's unqualified team nameuserOrRoleName- database user or role losing execution access- Returns:
truewhen the database accepts the revoke- Throws:
IllegalArgumentException- when either name is null, blank, invalid, or the grantee isPUBLICSelectAIException- when the database rejects or cannot complete the revoke- Since:
- 1.1.0
-
getVariable
Reads an ephemeral runtime variable from the current database session.Runtime variables are session-scoped. In
DataSourcemode, separate calls may use different pooled connections, so applications that require the value to remain available across calls should use a connection mode that retains one database session or manage the session explicitly.For a runnable example, see GetVariableSample source.
- Parameters:
namespace- runtime-variable namespace, such asstate_variablesname- runtime-variable key- Returns:
- the variable value, or
nullwhen the key is not set - Throws:
IllegalArgumentException- whennamespaceornameis null or blankSelectAIException- when the database operation fails- Since:
- 1.1.0
-
getVariable
Reads a runtime variable from the current database session and scope.For a runnable example, see GetVariableSample source.
- Parameters:
namespace- runtime-variable namespace, such asstate_variablesname- runtime-variable keyscope- runtime-variable scope; the database currently supportsephemeral- Returns:
- the variable value, or
nullwhen the key is not set - Throws:
IllegalArgumentException- when an argument is null or blankSelectAIException- when the database operation fails- Since:
- 1.1.0
-
setVariable
Sets or clears an ephemeral runtime variable in the current database session. Anullvalue clears the variable.For a runnable example, see SetVariableSample source.
- Parameters:
namespace- runtime-variable namespace, such asstate_variablesname- runtime-variable keyvalue- value to store, ornullto clear the key- Returns:
truewhen the database accepts the operation- Throws:
IllegalArgumentException- whennamespaceornameis null or blankSelectAIException- when the database operation fails- Since:
- 1.1.0
-
setVariable
boolean setVariable(String namespace, String name, String value, String scope) throws SelectAIException Sets or clears a runtime variable in the current database session and scope. Anullvalue clears the variable.For a runnable example, see SetVariableSample source.
- Parameters:
namespace- runtime-variable namespace, such asstate_variablesname- runtime-variable keyvalue- value to store, ornullto clear the keyscope- runtime-variable scope; the database currently supportsephemeral- Returns:
truewhen the database accepts the operation- Throws:
IllegalArgumentException- when an argument is null or blank, exceptvalueSelectAIException- when the database operation fails- Since:
- 1.1.0
-
listAgents
Lists agents owned by the current database user.For a runnable example, see ListAgentsSample source.
- Returns:
- agent handles initialized from
USER_AI_AGENTSmetadata and their current database attributes - Throws:
SelectAIException- when agent metadata or attributes cannot be loaded
-
listAgents
Lists owned agents whose names match a database regular-expression pattern. Matching is case-insensitive. Each returned handle includes metadata and attributes loaded from the database.For a runnable example, see ListAgentsSample source.
- Parameters:
agentNamePattern- regular-expression pattern matched against agent names- Returns:
- matching agent handles
- Throws:
IllegalArgumentException- whenagentNamePatternis null or blankSelectAIException- when listing agents fails
-
listTasks
Lists tasks owned by the current database user.For a runnable example, see ListTasksSample source.
- Returns:
- task handles initialized from
USER_AI_AGENT_TASKSmetadata and their current database attributes - Throws:
SelectAIException- when task metadata or attributes cannot be loaded
-
listTasks
Lists owned tasks whose names match a database regular-expression pattern. Matching is case-insensitive. Each returned handle includes metadata and attributes loaded from the database.For a runnable example, see ListTasksSample source.
- Parameters:
taskNamePattern- regular-expression pattern matched against task names- Returns:
- matching task handles
- Throws:
IllegalArgumentException- whentaskNamePatternis null or blankSelectAIException- when listing tasks fails
-
listTools
Lists tools owned by the current database user.For a runnable example, see ListToolsSample source.
- Returns:
- tool handles initialized from
USER_AI_AGENT_TOOLSmetadata and their current database attributes - Throws:
SelectAIException- when tool metadata or attributes cannot be loaded
-
listTools
Lists owned tools whose names match a database regular-expression pattern. Matching is case-insensitive. Each returned handle includes metadata and attributes loaded from the database.For a runnable example, see ListToolsSample source.
- Parameters:
toolNamePattern- regular-expression pattern matched against tool names- Returns:
- matching tool handles
- Throws:
IllegalArgumentException- whentoolNamePatternis null or blankSelectAIException- when listing tools fails
-
listTeams
Lists agent teams owned by the current database user.For a runnable example, see ListAgentTeamsSample source.
- Returns:
- team handles initialized from
USER_AI_AGENT_TEAMSmetadata and their current database attributes - Throws:
SelectAIException- when team metadata or attributes cannot be loaded
-
listTeams
Lists owned teams whose names match a database regular-expression pattern. Matching is case-insensitive. Each returned handle includes metadata and attributes loaded from the database. Granted cross-schema teams are not returned; userunTeam(String, RunTeamRequest)to run those teams.For a runnable example, see ListAgentTeamsSample source.
- Parameters:
teamNamePattern- regular-expression pattern matched against team names- Returns:
- matching team handles
- Throws:
IllegalArgumentException- whenteamNamePatternis null or blankSelectAIException- when listing teams fails
-
listAvailableTeams
Lists teams available to the calling database user for discovery.The returned objects are read-only discovery snapshots, not mutable
Teamlifecycle handles.For a runnable example, see ListAvailableTeamsSample source.
- Returns:
- available team discovery snapshots
- Throws:
SelectAIException- when the database discovery operation or its JSON response cannot be processed
-
getDefinition
String getDefinition(AgentObjectType objectType, String objectName, boolean includeDependentObjects) throws SelectAIException Returns the definition produced byDBMS_CLOUD_AI_AGENT.GET_DEFINITIONfor an agent framework object.For a runnable example, see GetDefinitionSample source.
- Parameters:
objectType- object type to describeobjectName- agent, task, tool, or team nameincludeDependentObjects- whether dependent objects should be included- Returns:
- definition returned by the database package
- Throws:
IllegalArgumentException- whenobjectTypeis null orobjectNameis null or blankSelectAIException- when the database operation fails
-
importTeam
Imports an agent team definition into the database.For a runnable example, see ImportTeamSample source.
- Parameters:
request- import request- Returns:
truewhen import succeeds- Throws:
IllegalArgumentException- whenrequestis nullSelectAIException- when import fails
-
close
Releases resources owned by this client.For a runnable example, see CreateSelectAIAgentWithOptionsSample source.
- Specified by:
closein interfaceAutoCloseable- Throws:
SelectAIException- when an owned JDBC connection cannot be closed
-