NL2SQL Agent
The NL2SQL agent enables natural language queries against structured data in Oracle Database.
- NL2SQL uses an Agent that autonomously selects from its fixed SQLcl connection, schema, query, and request-status tools using the ReAct pattern, rather than following a fixed pipeline.
build_nl2sql_agentspeccreates a portable AgentSpec Agent with anMCPToolBoxrestricted tosqlcl_connect,sqlcl_schema_information,sqlcl_sql_run, andsqlcl_request_status.- The session augments the agent's system prompt with the configured database connection name, model, and thread ID so the LLM passes them to the SQL execution tool calls.
- The system prompt is fetched from the MCP server (
optimizer_nl2sql-tools-default). If unavailable, a default instruction is used. - Requires a configured structured database connection and SQLcl MCP Server.
- SQLcl uses restrict level
4by default. Database access is determined by the configured connection account; use an account with only the required permissions.