Oracle Agent Engine Agent Spec patterns

This page provides the copyable Markdown source for the agent-spec-patterns.md reference used by the Codex skill.

Copyable Markdown source

Copy the following block into references/agent-spec-patterns.md.

# Oracle Agent Engine Agent Spec patterns

Use this reference when translating a user's requirements into a spec. The Oracle Database Agent Engine supports a documented subset of Agent Spec 26.1.0. Confirm the target release before using a different version, and use the component schema and examples in the matching Oracle documentation rather than general Agent Spec assumptions.

## Select Agent or Flow

- Use a top-level `Agent` when the model should iteratively decide whether to call one of its declared tools and then produce a result.
- Use a top-level `Flow` when execution order, branches, data movement, or repeated orchestration should be explicit.
- A Flow can contain an Agent through an `AgentNode`; this is useful when an iterative agent is one step in a larger deterministic process.
- If the choice materially changes the requested result, explain the tradeoff and ask the user before switching from an Agent to a Flow.

## Define the public contract

- Give the caller a small, typed input contract and return only outputs the caller needs.
- Use documented Agent Spec types and matching schema shapes. Check object properties, array item types, nullability, required fields, and defaults against the target release.
- Treat titles and identifiers as exact, case-sensitive contract names where the schema requires them.
- Do not expose private database values in the model prompt or top-level output unless the use case needs them and the data owner permits disclosure. Prefer returning a derived or minimized result from a trusted database procedure.

## Define instructions and tools

- Write instructions that state the agent's role, task, decision boundaries, how to use each tool, what to do when information is missing, and the required response format.
- Declare only tools the agent needs. Each tool is a predefined operation; the model cannot create a new tool or expand database privileges.
- For a `plsql_exec` tool, bind the contract to an existing stored procedure. Verify the schema, package, procedure, parameter names, directions, and supported parameter types. Do not fabricate a procedure definition or silently turn a natural-language capability into executable SQL.
- If the user wants a new procedure, identify that as separate database implementation work. Include necessary demonstration procedures when they fall within an authorized setup or build-and-run request. Identify them as new fixtures and preserve existing application objects.
- Be explicit when a tool can modify data or cause an external effect. The application and database procedure must enforce the required authorization and confirmation behavior; do not imply the spec itself grants a human approval mechanism.

## Configure the model

- Use the documented `DbmsVectorChainLlmConfig` fields for the selected provider: provider, endpoint URL, model, credential name when required, and supported generation parameters.
- Do not guess that a provider/model pair or parameter is supported. Verify compatibility in Oracle and provider documentation when the user specifies a provider, model, or asks for the latest model.
- Keep credentials and secrets out of the spec. The spec may refer to a database credential by name.
- Do not copy a sample's `agentspec_version` blindly. Oracle pages may contain examples from different releases; align the generated spec with the target runtime's documented support.

## Structural checks before presenting

Review the full JSON for:

- Correct top-level executable type and supported Agent Spec version.
- Required component fields and case-sensitive component types.
- Component IDs unique within the documented scope, and exact `$component_ref` resolution using supported scoping rules.
- Inputs and outputs that agree with every referenced tool and component contract.
- Existing PL/SQL parameter names, directions, and types when a database tool is supplied.
- Provider, endpoint, model, and credential-name consistency.
- No secret values, unsupported components, invented database objects, or undeclared tools.

Describe this as a structural review. `DBMS_AI_AGENT` performs database-side validation when the spec is submitted to the target database.

## Oracle documentation

- [Oracle AI Database Agent Engine overview](https://docs.oracle.com/en/database/oracle/oracle-database/26/odbae/oracle-ai-database-agent-engine/overview.html)
- [Agent architecture and components](https://docs.oracle.com/en/database/oracle/oracle-database/26/odbae/oracle-ai-database-agent-engine/agent-architecture-and-components.html)
- [Agent Building Blocks](https://docs.oracle.com/en/database/oracle/oracle-database/26/odbae/agent-building-blocks.html)
- [Define Tools and Built-In Tool Types](https://docs.oracle.com/en/database/oracle/oracle-database/26/odbae/agent-building-blocks/define-tools-and-built-in-tool-types.html)
- [LLM Configuration and Access](https://docs.oracle.com/en/database/oracle/oracle-database/26/odbae/agent-building-blocks/llm-configuration-and-access.html)
- [AgentNode example](https://docs.oracle.com/en/database/oracle/oracle-database/26/odbae/design-and-run-flows/agentnode.html)