Python API reference
For a guided introduction, start with the quickstart. This page describes the public function signatures and error behavior.
Function index
| Task | Functions |
|---|---|
| Configure a model | llm_config |
| Define a tool | plsql_tool, agent_tool |
| Create a workflow step | tool_node, llm_node |
| Create an agent | agent |
| Compose a workflow | sequential, parallel, routing, orchestrator, loop |
| Run a workflow | execute |
| Provision a credential | create_api_key_credential |
| Handle an error | Error classes |
Workflow definitions do not call the database or model. Pass an executable to execute() to run it. Examples use support_llm from llm_config(). Execution examples also need an open database connection.
Creating a tool definition does not check whether the referenced database objects exist or whether your user can access them. Missing objects or permissions can cause execution to fail.
User-supplied component and workflow names must contain a non-whitespace character. Valid names are preserved exactly as supplied. PL/SQL procedure names, and optional package/schema names when supplied, must also contain a non-whitespace character. These checks validate reference shapes; identifier syntax and object resolution remain the database's responsibility.
Input and output contracts
Declare field names and JSON types when building each component. At execution, supply values for the inputs of the top-level agent, step, or workflow you pass to execute(). The workflow supplies values to its steps according to the selected composition pattern:
| Use | Example |
|---|---|
| Declare inputs | inputs={"order_id": "string"} |
| Declare outputs | outputs={"order_status": "string"} |
| Supply execution values | execute(..., inputs={"order_id": "ORDER-100"}) |
Supply the inputs declared by the workflow. Each pattern determines how those values and step results are passed to later steps.
For example, in an order lookup followed by an explanation, the caller supplies order_id. The lookup produces order_status, which is passed to the explanation
step. The caller does not supply order_status. See sequential() for the complete example.
Declare field types using string, integer, number, boolean, object, or array.
Field names and types are checked when you connect workflow steps. Validate the actual input values in your application; execute() does not convert types or perform full JSON Schema validation.
LLM configuration
llm_config
llm_config(*, provider, model_id, url, credential_name=None, host=None,
transfer_timeout=None, generation=None) -> LlmConfig
| Parameter | Type | Purpose |
|---|---|---|
provider | str | LLM provider identifier; see the supported providers in UTL_TO_GENERATE_TEXT |
model_id | str | Model identifier |
url | str | Full provider operation URL, such as https://api.openai.com/v1/chat/completions |
credential_name | str or None | Database credential name, not an API key |
host | "local" or None | For an OpenAI-compatible or Ollama endpoint that does not require authentication, set host="local" and leave credential_name unset. The database calls the endpoint specified by url |
transfer_timeout | int or None | Maximum wait for a provider request, in seconds; None leaves it unspecified |
generation | Dictionary of settings, or None | Generation settings, for example {"temperature": 0.2, "max_tokens": 512}. See supported generation settings |
Pass the returned configuration to agent() or llm_node(). The database uses these settings to call the model when the workflow runs. Invalid configuration values raise BuildingBlockError.
For provider and endpoint setup, see configuration.
from oracle_db_agent_sdk import llm_config
support_llm = llm_config(
provider="openai",
model_id="gpt-5.4",
url="https://api.openai.com/v1/chat/completions",
credential_name="OPENAI_CREDENTIAL",
)
Supported generation settings
The database's LLM Configuration and Access documentation lists these generation settings:
| Setting | Purpose |
|---|---|
max_tokens | Limit the generated output length |
temperature | Adjust response variability |
top_p | Adjust nucleus sampling where supported |
reasoning_effort | Choose a reasoning level supported by the model |
Check that documentation for your database release, then check the selected provider's model documentation for allowed values and combinations. These settings are not supported uniformly across models.
Python validation does not confirm that a setting is supported by your database or model. Check the documentation for both before using additional options.
Tools and executable building blocks
plsql_tool
plsql_tool(*, name, procedure, inputs, outputs, description=None,
schema=None, package=None) -> Tool
| Parameter | Type | Purpose |
|---|---|---|
name | str | Tool name exposed in the workflow |
procedure | str | Existing PL/SQL procedure identifier |
inputs | Dictionary | Procedure input names and types, for example {"order_id": "string"} |
outputs | Dictionary | Procedure output names and types, for example {"order_status": "string"} |
description | str or None | Description, useful for agent tool selection |
schema | str or None | Optional schema name |
package | str or None | Optional package name |
Pass the returned tool to tool_node() to call the procedure as a workflow step. Or add it to an agent's tools list so the agent can choose when to call it.
The procedure must already exist in your database. Invalid settings raise BuildingBlockError.
For an existing order lookup procedure:
from oracle_db_agent_sdk import plsql_tool
lookup_order = plsql_tool(
name="lookup_order_status",
procedure="GET_STATUS",
inputs={"order_id": "string"},
outputs={"order_status": "string"},
description="Look up the current status of an order.",
package="ORDER_SERVICE",
)
All plsql_tool() arguments are keyword-only. The signature, parameter table, and examples use the same parameter order for readability; their order in a call does not determine the PL/SQL parameter binding.
The example assumes ORDER_SERVICE contains a procedure with these parameters:
PROCEDURE GET_STATUS(order_id IN VARCHAR2, order_status OUT VARCHAR2);
The keys must match the procedure's parameter names as understood by Oracle; they are not aliases you can rename for the workflow. Declare IN parameters
in inputs, OUT parameters in outputs, and IN OUT parameters in both, with compatible JSON types. Include the parameters needed for the call; the SDK does not infer omitted parameters or adapt mismatched declarations. For this procedure, the keys are order_id and order_status:
| PL/SQL parameter | Tool definition | Meaning |
|---|---|---|
order_id IN VARCHAR2 | inputs={"order_id": "string"} | The workflow supplies the order ID to the procedure |
order_status OUT VARCHAR2 | outputs={"order_status": "string"} | The procedure supplies the order status to the workflow |
For a procedure parameter draft IN OUT CLOB, declare "draft": "string" in both mappings so the call receives the initial text and returns the updated text.
See the database's PL/SQL tool bindings and type compatibility for supported parameter directions and types.
The package must be implemented, and your database user must have permission to execute the procedure. plsql_tool() does not query the database to check its existence, parameters, or your permissions.
agent_tool
agent_tool(*, name, agent, description=None)
agent_tool(*, name, agent_name, schema, inputs, outputs, description=None)
Use the first form to expose a Python-defined agent or workflow to an orchestrator(). It inherits the executable's input/output contracts. You do not need to register the Python-defined agent in the database.
from oracle_db_agent_sdk import agent, agent_tool
specialist = agent(
name="case_specialist",
llm=support_llm,
instruction="Assess case {{case_id}} with status {{status}} using those facts.",
inputs={"case_id": "string", "status": "string"},
outputs={"assessment": "string"},
)
get_case_assessment = agent_tool(
name="get_case_assessment",
agent=specialist,
description="Assess a support case using its current status.",
)
name identifies the capability to the manager; description explains when to use it. Pass the returned capability in orchestrator(tools=[...]). Embedded agent tools cannot be used by agent() or tool_node().
The second form references an existing stored database agent. Supply its owner as schema, its name as agent_name, and matching inputs and outputs
contracts. Check that your database version supports calling stored agents from workflows. The SDK does not retrieve or verify the stored agent's interface or existence. Do not mix the two forms. Invalid settings raise BuildingBlockError.
tool_node
tool_node(*, name, tool) -> Executable
Use tool_node() to call a tool as a workflow step.
| Parameter | Type | Purpose |
|---|---|---|
name | str | Name for the workflow step |
tool | Tool | The tool to call, created with plsql_tool() or agent_tool() |
For example, define an order lookup tool and create a step that calls it:
from oracle_db_agent_sdk import plsql_tool, tool_node
lookup_order = plsql_tool(
name="lookup_order_status",
procedure="GET_STATUS",
inputs={"order_id": "string"},
outputs={"order_status": "string"},
package="ORDER_SERVICE",
)
lookup_step = tool_node(name="lookup_order", tool=lookup_order)
When lookup_step runs, it passes order_id to ORDER_SERVICE.GET_STATUS and receives order_status. Pass lookup_step to execute() to run it, or combine it with other workflow steps. Invalid settings raise BuildingBlockError.
llm_node
llm_node(*, name, llm, prompt, inputs, outputs) -> Executable
Use llm_node() to add a model task to your workflow.
| Parameter | Type | Purpose |
|---|---|---|
name | str | Name you give this step, for example explain_status |
llm | Model configuration | Model settings created with llm_config(), such as support_llm |
prompt | str | Instructions for the model. Supports {{input_name}} syntax, for example {{order_status}} |
inputs | Dictionary | Input names and types used in the prompt, for example {"order_status": "string"} |
outputs | Dictionary | Output names and types the model should produce, for example {"answer": "string"} |
In this example, the step takes order_status as input and asks the model to produce an answer. Invalid step settings raise BuildingBlockError.
from oracle_db_agent_sdk import llm_node
explain_step = llm_node(
name="explain_status",
llm=support_llm,
prompt="Explain this order status clearly: {{order_status}}",
inputs={"order_status": "string"},
outputs={"answer": "string"},
)
agent
agent(*, name, llm, instruction, inputs, outputs, tools=(),
description=None) -> Executable
Use agent() when a model should reason about a task and choose tools as needed to produce an answer. Use orchestrator() to delegate work to sub-agents.
| Parameter | Type | Purpose |
|---|---|---|
name | str | Name you give the agent, for example order_support |
llm | Model configuration | Model settings created with llm_config(), such as support_llm |
instruction | str | System prompt describing the agent's task and behavior. Supports {{input_name}} syntax, for example {{question}} |
inputs | Dictionary | Input names and types the agent accepts, for example {"question": "string", "order_id": "string"} |
outputs | Dictionary | Output names and types the agent should produce, for example {"answer": "string"} |
tools | List of tools | PL/SQL tools the agent can call, for example [lookup_order]. Create them with plsql_tool() |
description | str or None | A short explanation of what the agent does; optional |
Use instruction to set the agent's system prompt: describe its goal, constraints, and when to use its tools. Tool names, descriptions, and parameter definitions are supplied through tools; you do not need to repeat those definitions in the prompt.
The example below receives a question and an order_id, looks up the order's status when needed, and returns an answer.
Define lookup_order using the plsql_tool() example. Passing tools=[lookup_order] makes that tool available to the agent; the model decides when to call it. Invalid agent settings raise BuildingBlockError.
from oracle_db_agent_sdk import agent
support_agent = agent(
name="order_support",
llm=support_llm,
instruction=(
"Answer {{question}} about the status of order {{order_id}}. "
"Use the order lookup tool when needed."
),
inputs={"question": "string", "order_id": "string"},
outputs={"answer": "string"},
tools=[lookup_order],
)
Workflow patterns
Composition patterns connect steps using their declared inputs and outputs, so you do not have to define individual control-flow and data-flow edges. Choose a pattern to run steps in order, handle independent tasks, route requests, or repeat a task:
| Function | What it does | Example |
|---|---|---|
sequential() | Runs steps in order, passing each result to the next step | Look up an order, then explain its status |
parallel() | Runs independent branches and combines their results | Review a ticket's sentiment and urgency separately |
routing() | Runs the branch selected by a routing step | Send a ticket to billing or technical support based on its classification |
orchestrator() | Coordinates tools and can delegate work to sub-agents | Look up a support case and consult a specialist agent before preparing a response |
loop() | Repeats a task using the previous result, up to a configured limit | Review and revise a draft until it is marked complete |
All five patterns execute in the database. Choose a pattern according to how steps should share inputs and results. Patterns validate their configuration when defined; defining a workflow does not execute it.
sequential
sequential(*, name, steps) -> Executable
Run steps one after another, passing each step's output to the next step.
| Parameter | Type | Purpose |
|---|---|---|
name | str | Name for the workflow, for example order_support |
steps | List of steps | Steps to run, in order. Include at least two steps |
This example looks up an order with PL/SQL, then asks the model to explain its status. It uses support_llm from the llm_config() example.
from oracle_db_agent_sdk import llm_node, plsql_tool, sequential, tool_node
order_tool = plsql_tool(
name="lookup_order_status",
procedure="GET_STATUS",
inputs={"order_id": "string"},
outputs={"order_status": "string"},
package="ORDER_SERVICE",
)
lookup_step = tool_node(name="lookup_order", tool=order_tool)
explain_step = llm_node(
name="explain_status",
llm=support_llm,
prompt="Explain this order status clearly: {{order_status}}",
inputs={"order_status": "string"},
outputs={"answer": "string"},
)
order_workflow = sequential(name="order_support", steps=[lookup_step, explain_step])
The workflow takes an order_id and produces an answer:
| Step | Receives | Produces |
|---|---|---|
lookup_step | order_id | order_status from the PL/SQL procedure |
explain_step | order_status | answer from the model |
Each step must produce exactly the fields the next step accepts, with compatible types. Here, both steps use order_status with type string to pass the status
between them. Only output fields are passed forward. If the next step needs an earlier input, the preceding step must return it too.
Invalid workflow settings raise PatternCompilationError. Mismatched field names or types raise IncompatibleSequentialContractError.
parallel
parallel(*, name, steps) -> Executable
Use parallel() to define separate branches that receive workflow inputs and contribute distinct fields to a combined output.
| Parameter | Type | Purpose |
|---|---|---|
name | str | Name for the workflow, for example ticket_review |
steps | List of steps | Independent branches to run. Include at least two steps; list order does not determine execution order |
This example reviews the same support ticket in two ways: one step describes its sentiment, and another assesses its urgency. It uses support_llm from the
llm_config() example.
from oracle_db_agent_sdk import llm_node, parallel
sentiment_review = llm_node(
name="sentiment_review",
llm=support_llm,
prompt="Describe the sentiment of {{ticket_text}}.",
inputs={"ticket_text": "string"},
outputs={"sentiment": "string"},
)
urgency_review = llm_node(
name="urgency_review",
llm=support_llm,
prompt="Assess the urgency of {{ticket_text}}.",
inputs={"ticket_text": "string"},
outputs={"urgency": "string"},
)
review_workflow = parallel(
name="ticket_review",
steps=[sentiment_review, urgency_review],
)
Run review_workflow with a ticket_text input. Each review receives that text, and the workflow collects both results:
| Step | Receives | Produces |
|---|---|---|
sentiment_review | ticket_text | sentiment |
urgency_review | ticket_text | urgency |
Give each result a different name so both can be included in the workflow's output. Here, the names are sentiment and urgency. Steps can share an input
such as ticket_text when they expect compatible types. If steps need different inputs, supply all of those inputs when running the workflow.
Branches do not pass results to each other. This composes separately defined tasks; it does not map one task over the elements of a collection.
The database schedules the branches. Available resources and the work performed by each branch determine whether parallel execution improves performance.
Invalid workflow settings, including fewer than two steps, raise PatternCompilationError when defining the workflow, before execution.
Conflicting input types or duplicate output names raise IncompatibleParallelContractError.
routing
routing(router, *, name, route_key, routes, default) -> Executable
Use routing() to choose one branch based on the result of an earlier step.
| Parameter | Type | Purpose |
|---|---|---|
router | Step or workflow | The step that decides which branch to run, such as a ticket classifier |
name | str | Name identifying the routing workflow and its generated Flow |
route_key | str | Name of the router's string output to use for the choice, for example issue_type |
routes | Dictionary | Matches router results to branches, for example {"billing": billing_reply} |
default | Step or workflow | Branch to run when the result is not listed in routes, for example general_reply |
This example classifies a ticket, then chooses between two reply steps: billing support or general support. It uses support_llm from the llm_config() example.
from oracle_db_agent_sdk import llm_node, routing
classify_ticket = llm_node(
name="classify_ticket",
llm=support_llm,
prompt="Classify {{ticket_text}}. Return issue_type as billing or general.",
inputs={"ticket_text": "string"},
outputs={"issue_type": "string"},
)
billing_reply = llm_node(
name="billing_reply",
llm=support_llm,
prompt="Draft a billing support response to: {{ticket_text}}",
inputs={"ticket_text": "string"},
outputs={"resolution": "string"},
)
general_reply = llm_node(
name="general_reply",
llm=support_llm,
prompt="Draft a general support response to: {{ticket_text}}",
inputs={"ticket_text": "string"},
outputs={"resolution": "string"},
)
support_workflow = routing(
classify_ticket,
name="ticket_routing",
route_key="issue_type",
routes={"billing": billing_reply},
default=general_reply,
)
Run support_workflow with a ticket_text input. The classifier produces issue_type, which selects the reply step:
Value of issue_type | Step that runs |
|---|---|
"billing" | billing_reply |
"general" or any other value | general_reply |
Only one reply step runs. It receives the original ticket_text and produces resolution.
Branches use the original workflow inputs and must return the same output fields with compatible types.
Raises PatternCompilationError for invalid settings or IncompatibleRoutingContractError for incompatible inputs or outputs.
See the full ticket-routing example
orchestrator
orchestrator(*, name, llm, instruction, inputs, outputs, tools,
description=None) -> Executable
Use orchestrator() to coordinate tools and sub-agents using their previous results.
| Parameter | Type | Purpose |
|---|---|---|
name | str | Name for the coordinator, for example case_coordinator |
llm | Model configuration | Model settings created with llm_config(), such as support_llm |
instruction | str | Instructions describing the task and when to use each capability. Supports {{input_name}} syntax |
inputs | Dictionary | Nonempty input contract, for example {"case_id": "string"} |
outputs | Dictionary | Nonempty output contract, for example {"resolution": "string"} |
tools | List of tools | At least one capability created with plsql_tool() or agent_tool(). Names must be unique; finish is reserved for completion |
description | str or None | A short explanation of what the coordinator does; optional |
Use instruction for the task, when to consult each capability, any required ordering, and how to combine results. Reference workflow inputs as {{input_name}}. Model decisions remain probabilistic. Use sequential() for a required fixed sequence or routing() for one selected destination without feedback.
This example asks the coordinator to look up a case's status, consult a specialist, and combine the findings into a resolution. It uses support_llm from the llm_config() example.
from oracle_db_agent_sdk import agent, agent_tool, orchestrator, plsql_tool
lookup_case = plsql_tool(
name="lookup_case",
schema="APP_USER",
package="CASE_SERVICE",
procedure="GET_STATUS",
inputs={"case_id": "string"},
outputs={"status": "string"},
description="Look up the current case status.",
)
specialist = agent(
name="case_specialist",
llm=support_llm,
instruction="Assess case {{case_id}} with status {{status}} using those facts.",
inputs={"case_id": "string", "status": "string"},
outputs={"assessment": "string"},
)
case_coordinator = orchestrator(
name="case_coordinator",
llm=support_llm,
instruction=(
"Resolve case {{case_id}}. Look up its status, then pass that actual "
"status and case_id to get_case_assessment. Combine the findings."
),
inputs={"case_id": "string"},
outputs={"resolution": "string"},
tools=[
lookup_case,
agent_tool(
name="get_case_assessment",
agent=specialist,
description="Assess a case using its current status.",
),
],
)
Only APP_USER.CASE_SERVICE.GET_STATUS and the model credential must already exist for this example. The specialist is defined in Python.
Run case_coordinator with a case_id input. The coordinator chooses a capability, receives its results, and decides whether to call another capability or finish.
It can use earlier results as inputs to a later call. On completion, it combines the findings into the declared outputs. Only selected capabilities run, and a
capability may be selected more than once.
The manager can repeat capabilities until it chooses to finish. Choosing an unknown capability raises OrchestrationExecutionError before another capability runs. Failures propagate through enclosing patterns and skip subsequent dependent steps; independent parallel branches may already have performed work.
Coordination can require multiple model requests in addition to the work each capability performs. Keep tasks focused to control resource use and cost.
Invalid authoring settings raise PatternCompilationError.
See the complete case-support example
loop
loop(*, name, body, state_key, continue_value, max_iterations) -> Executable
Use loop() to repeat a step, passing its latest results back as the next input.
| Parameter | Type | Purpose |
|---|---|---|
name | str | Name you give the loop, for example review_until_done |
body | Step or workflow | Work to repeat. Its input and output field names and types must match |
state_key | str | Name of the string field that controls repetition, for example "done" |
continue_value | str | Nonempty value that means "run again," for example "N" |
max_iterations | int | Maximum number of runs, for example 5. Allowed range: 1 to 256 |
Review a draft at most five times:
import oracle_db_agent_sdk
from oracle_db_agent_sdk import execute, llm_node, loop
state_fields = {"task": "string", "draft": "string", "done": "string"}
review_step = llm_node(
name="review_step",
llm=support_llm,
prompt=(
"Review {{draft}} for task {{task}}. Previous completion flag: {{done}}. "
"Improve the draft, preserve task, and return done='Y' if complete, else done='N'."
),
inputs=state_fields,
outputs=state_fields,
)
review_loop = loop(
name="review_until_done",
body=review_step,
state_key="done",
continue_value="N",
max_iterations=5,
)
result: oracle_db_agent_sdk.JSONValue = execute(
connection=connection,
workflow=review_loop,
inputs={
"task": "Make the draft clearer.",
"draft": "Please call support.",
"done": "N",
},
)
print("Loop result:", result)
if isinstance(result, dict):
print("Final draft:", result["draft"])
Supply the starting values directly as named inputs: task, draft, and done. Each review returns the same fields with compatible declared types.
- While
doneis"N", another review runs using the updated draft. - A value that does not match
"N"takes the default exit. Starting with“Y”skips the review entirely. - Finishing on the fifth review succeeds. If it still returns
"N", execution stops andexecute()raisesLoopExecutionError. A sixth review cannot run.
The result contains the final fields directly. Python does not inspect intermediate state or coordinate iterations. Runtime values, including nulls
and type conversions, follow database validation and branching rules.
Exhaustion skips later steps in an enclosing sequential workflow and propagates out of nested loops and routing. Independent parallel branches may still run;
after they finish, any exhausted branch causes the workflow to raise LoopExecutionError. Body execution errors remain database errors. An absent database response raises InvalidDatabaseResponseError.
Choose the smallest iteration limit that fits the task. Larger limits and nested loops can increase resource use. The accepted range of 1 to 256 is a configuration limit, not a performance guarantee.
Invalid settings raise PatternCompilationError. Mismatched body input/output fields or types raise IncompatibleLoopContractError.
Execution
execute
execute(*, connection, workflow, inputs) -> JSONValue
Use execute() to run an agent, step, or workflow with your input values. The result is an oracle_db_agent_sdk.JSONValue, the SDK's type alias for JSON-compatible Python values.
| Parameter | Type | Purpose |
|---|---|---|
connection | oracledb.Connection | Open database connection created with oracledb.connect() |
workflow | Agent, step, or workflow | What to run, for example support_agent |
inputs | Dictionary | Values for the workflow's named inputs, such as question and order_id |
Run support_agent from the agent() example using an open connection:
import oracle_db_agent_sdk
from oracle_db_agent_sdk import execute
result: oracle_db_agent_sdk.JSONValue = execute(
connection=connection,
workflow=support_agent,
inputs={"question": "What is my order's status?", "order_id": "ORDER-100"},
)
print("Database response:", result)
if isinstance(result, dict) and "answer" in result:
print("Answer:", result["answer"])
JSONValue
oracle_db_agent_sdk.JSONValue is a public type alias provided by this SDK, rather than a built-in Python type. It describes ordinary JSON-compatible Python
values: None, booleans, numbers, strings, lists, and dictionaries with string keys. Lists and dictionaries can contain these same value types. The annotation does not create a special response object.
For an agent, step, or workflow, the result is the database's JSON response converted to a Python value. Its structure is unchanged, so inspect the printed result before accessing individual fields.
Use result["answer"] for a dictionary containing an answer key, or result[0] for the first element of a nonempty list, after checking the value's type and
contents. Declaring output fields does not make the SDK extract them or add a response wrapper.
For a loop(), the result contains the final named state fields directly, for example result["done"] and result["draft"].
Supply JSON-compatible input values and validate external inputs in your application.
Credentials
create_api_key_credential
create_api_key_credential(*, connection, name, api_key) -> None
Use create_api_key_credential() to store your model provider's API key in a database credential. Then use the credential's name in llm_config().
| Parameter | Type | Purpose |
|---|---|---|
connection | oracledb.Connection | Open database connection with permission to create credentials |
name | str | Name for the new credential, for example "OPENAI_CREDENTIAL" |
api_key | str | Your model provider's API key |
This example reuses an existing credential by default. Set provision_credential to True only for one-time setup when you know a new credential is needed. That branch needs an open connection with creation privileges and a provider_api_key value from your application's secure configuration:
from oracle_db_agent_sdk import (
CredentialCreationError,
create_api_key_credential,
llm_config,
)
credential_name = "OPENAI_CREDENTIAL"
provision_credential = False # Reuse the existing credential.
if provision_credential:
try:
create_api_key_credential(
connection=connection,
name=credential_name,
api_key=provider_api_key,
)
except CredentialCreationError as error:
print("Credential creation failed:", error)
raise # Verify the cause before deciding whether to reuse or retry.
support_llm = llm_config(
provider="openai",
model_id="gpt-5.4",
url="https://api.openai.com/v1/chat/completions",
credential_name=credential_name,
)
With provision_credential=False, no credential-creation call is made and no API key is needed by this snippet. This flag is a decision made by your deployment or application configuration; it is not an existence check. Create a credential once during provisioning, then use its name during ordinary workflow execution.
The helper is create-only, not idempotent: calling it again attempts creation again. It does not check an existing credential, replace its secret, or rotate
keys. A matching name alone does not verify that an existing credential has the intended authentication material.
DatabaseCleanupError can occur after creation succeeds. Verify the database state before retrying. See error handling for recovery guidance.
Connection and tool ownership
Database access and model access use different settings:
| Setting | Purpose |
|---|---|
connection | Connects your Python application to Oracle Database |
credential_name | Names the credential the database uses to authenticate with the model provider |
Manage the connection in your application, including commits, rollbacks, and
closing it when finished.
Tools can change data. Check whether a failed operation made changes before retrying it. Prompts, inputs, and tool results may be sent to the model provider, so keep secrets out of them.
Untrusted input and privileges
Untrusted prompts, documents, or tool results can contain instructions that trick an agent into misusing its tools. Tool calls run without filtering these
instructions or requesting approval.
Keep workflow and tool definitions under your application's control. When schema, package, or procedure values for plsql_tool() come from external sources, your application must validate that they identify a procedure the requesting user is authorized to invoke.
Validate procedure input values as well, and give agents only the tools and database privileges needed for their tasks. These limits reduce the risk of invoking unintended procedures, unauthorized actions, or privilege escalation.
Errors
Import error classes from oracle_db_agent_sdk. Catch a specific class for a targeted response, or OracleDBAgentsError to handle SDK failures together.
Database connection setup can also raise python-oracledb errors outside the SDK.
JSON nesting that exceeds Python's supported depth raises InputSerializationError for execution inputs or InvalidDatabaseResponseError for database responses.
Input serialization fails before the database call; response decoding happens after execution has completed.
DatabaseExecutionError, CredentialCreationError, and DatabaseCleanupError include the original database or driver diagnostic text after the SDK's operation
context, preserving error codes and multiline error stacks.
| Error | Meaning | Next step |
|---|---|---|
BuildingBlockError | Settings for a model, tool, agent, or step are invalid | Check the relevant function's arguments, model settings, and contracts |
PatternCompilationError | A workflow could not be built | Check the selected pattern's requirements |
IncompatibleSequentialContractError | Adjacent steps have incompatible contracts | Match the preceding outputs to the next inputs as described in sequential workflows |
IncompatibleParallelContractError | Branch inputs conflict or output names overlap | Use compatible shared inputs and distinct outputs; see parallel workflows |
IncompatibleRoutingContractError | Router or destination contracts are incompatible | Check the route field and branch contracts in routing |
IncompatibleLoopContractError | The loop body's input/output contracts are incompatible, or state_key does not name a string state field | Match the body's input/output fields and types, and check state_key; see loops |
AgentSpecSerializationError | A workflow could not be prepared for execution | Check the execution requirements, workflow definitions, and installed dependency versions |
InputSerializationError | Input values cannot be converted to supported JSON | Supply string input names and JSON-compatible values with finite numbers; see inputs and JSONValue |
OrchestrationExecutionError | The manager selected an unknown capability | Inspect tool effects, capability names, and instructions |
LoopExecutionError | A loop still requests continuation after its last permitted execution | Check the continuation field and iteration limit; inspect tool side effects before retrying |
LoopRuntimeSetupError | Retained for import compatibility | This exception is not raised by loop() |
DatabaseExecutionError | A database call failed, or its response could not be read | Check agent support, object privileges, provider credentials, and network prerequisites; inspect side effects before retrying |
DatabaseCleanupError | Execution or credential creation completed, but cursor cleanup failed | Check database state and connection health before repeating an operation; see connection ownership |
InvalidDatabaseResponseError | The database response is absent, blank, non-text, invalid JSON, contains non-finite numbers or numbers that overflow Python's floating-point range, or lacks a valid loop/orchestrator completion status | Check the workflow's declared outputs and the database/model response; see execution |
CredentialConfigurationError | The credential name or API key is missing or invalid | Supply a credential name and API key through secure application configuration; see credentials |
CredentialCreationError | The database credential-creation call failed | Verify the name, existing credential state, and creation privileges; see provisioning and reuse |