Choosing the Right AI Tool Type in APEX: Retrieve Data, Server-side or Client-side
Tutorial

Choosing the Right AI Tool Type in APEX: Retrieve Data, Server-side or Client-side

ASKLYZE Team
ASKLYZE TeamAuthor
5 Mins Read
Oct 21, 2026

Most agent problems we see in APEX projects are not model problems. They are tool problems. The agent calls the wrong thing, gets too much data back, or does something in the browser that should have happened on the server. So it's worth slowing down on the three tool types and when each one makes sense.

Retrieve Data: give the model facts

A Retrieve Data tool returns information to the model. You can back it with a SQL Query, a Function Body that returns a CLOB, or Static text.

Use it when the agent needs to know something before it can answer: a customer's open invoices, a product's specs, the policy text for refunds.

A few habits help a lot:

  • Select only what the model needs. Every column you return costs tokens and gives the model one more thing to misread. Ten well-named columns beat forty cryptic ones.
  • Set Maximum Tokens. It protects you from the one customer with an enormous history.
  • Write the Data Description as if for a new colleague. The model reads it to decide whether the tool is relevant.
  • Static is underrated. Opening hours, escalation rules, glossary terms. If it rarely changes, static text is fast and free of database calls.

Execute Server-side Code: let the agent act

This runs PL/SQL. It's how an agent creates a record, sends an email through APEX_MAIL, starts a workflow or calls a REST API.

This is also the type that deserves the most caution:

  • Turn on Requires Confirmation for anything that writes or sends. The user sees what will happen and approves it.
  • Validate parameters inside your PL/SQL. The model might pass a malformed date or an ID that belongs to someone else. Treat its input like any other user input.
  • Return a short, clear result such as "Ticket 4412 created", not a dump of the new row.

Execute Client-side Code: change what the user sees

This runs JavaScript in the browser. It's great for UI reactions: refresh a report after the agent changed data, set a filter, navigate to a tab, open a modal.

It is not the place for business logic or data access. Anything in the browser can be inspected and changed by the user. If it matters, it belongs on the server.

Augment System Prompt or On Demand?

Every tool also has an execution point.

Augment System Prompt tools run before every message and add their output to the context. Use them for small, always-relevant facts: the user's name and role, today's date, the record currently open on the page. Keep them tiny, because you pay for them on every turn.

On Demand tools run only when the model asks. Most of your tools should be this type. The model sees the list and description, and calls what it needs.

You can also put a server-side condition on a tool using the bind variables APEX$AI_LAST_USER_PROMPT and APEX$AI_ALL_USER_PROMPTS. For example, only include a heavy pricing tool if the user's message mentions price or discount.

A simple rule of thumb

Ask three questions for every capability you want to give an agent:

  1. Does the model need to know something? Retrieve Data.
  2. Does something need to happen in the data or outside systems? Server-side code, with confirmation.
  3. Does the screen need to change? Client-side code.

If one capability seems to need two types, split it into two tools. Agents handle small, sharp tools much better than big multipurpose ones.

Sources: Managing AI Agents and AI Tools, APEX 26.1 documentation, What's New in Oracle APEX 26.1