<!-- Documentation header -->
---
guid: aec0cd3b-dcd4-4077-b0c0-04e987bdb690
locale: en-us
summary: Create AI agents in OutSystems Developer Cloud (ODC) using function calling to fulfill complex user requests with dynamic action orchestration.
figma: https://www.figma.com/design/6G4tyYswfWPn5uJPDlBpvp/Building-apps?node-id=8940-10&p=f&t=3HWJrxoEM8IMLFsU-0
coverage-type:
  - understand
  - apply
topic:
  - action-calling-overview
  - configure-action-calling
  - set-call-condition
app_type: reactive web apps,mobile apps
platform-version: odc
audience:
  - Developer
tags:
  - Agentic
  - AI
  - Logic
outsystems-tools:
  - odc studio
helpids:
isautopublish: true
---
# AI agent actions

Function calling is the ability of an [AI model](https://extranetprdintegrations.outsystems.net/Documentation_API/rest/getContentMarkdown/doc?Guid=387270e4-2dc7-4c82-a8fc-3f0a0139eb98) to go beyond generating text and intelligently use tools to perform actions or get data. With function calling, [you can build AI agents](https://extranetprdintegrations.outsystems.net/Documentation_API/rest/getContentMarkdown/doc?Guid=76197f5e-bca6-4603-8e93-45fa96ca76b2)  that interact with your apps and data sources to fulfill complex user requests.

## Action calling

In ODC, the **Call Agent** element within an **Agent Flow** orchestrates this process. When you trigger an agent, it dynamically decides the best course of action using an AI model's reasoning. This can involve calling a single server action, a sequence of different actions, or the same action multiple times.

The AI model decides based on the context you provide, which includes:

* The end-user's prompt at runtime.  
* The [System Prompt](https://extranetprdintegrations.outsystems.net/Documentation_API/rest/getContentMarkdown/doc?Guid=24d5a0ea-68c8-4851-b7de-e0908c122862) you define to instruct the agent on its behavior and goals.  
* The metadata of the available actions (their names, descriptions, and input parameters).

The core of this functionality lies in how you define actions for your agent.

![Flowchart showing the AI agent action calling process, from user prompt through Call Agent orchestration to final response, including the reasoning loop and decision points for action execution.](images/ai-agent-action-calling-flow-diag.png "AI Agent Action Calling Flow")

* **Actions are server actions**: In the context of an AI agent, an action is a standard Server Action. You grant the agent the ability to use these actions to perform its tasks.  
* **Agent autonomy**: You provide the agent with a set of available actions. The AI model autonomously decides which action (or sequence of actions) is appropriate by analyzing the prompts and the purpose of each action you've exposed.

To ingest content from files such as Word documents, PDFs, spreadsheets, presentations, HTML, or plain text in Agent Workbench, add the `OmniDoc2MD` Forge component to your app and expose its conversion server action as an action. It converts file binaries to Markdown while preserving structure and extracting images.
For more information, refer to [Convert files to Markdown](https://extranetprdintegrations.outsystems.net/Documentation_API/rest/getContentMarkdown/doc?Guid=f5b8c0a7-2d0c-4b95-8e1a-7d8d3b5a2c4f).

Providing actions is optional. If you don't provide any server actions, the agent relies exclusively on the AI model's internal knowledge to generate responses.

<div class="info" markdown="1">

Action calling and structured output can't be used on the same Agent call. If you want to use action calling and structure output, you must do action calling on an Agent call and then do the Structure output on another agent call.

</div>

### Implementation considerations

To build reliable and effective agents, keep the following in mind.

#### Indicate AI-generated content

The **Generated by AI** setting for a parameter instructs the AI model to use its reasoning to dynamically determine and provide the value for that specific input at runtime.

Instead of manually assigning a variable or a hardcoded value to an input, you can delegate the task of filling in the parameter to the AI. The model analyzes the complete context of the conversation to infer the correct value.

#### Write detailed and accurate descriptions

The AI model's ability to choose the correct action depends entirely on the text descriptions you provide for the Server Action and its parameters. The model has no other way of understanding what an action does.

* **Action description**: Clearly describe the action’s purpose, what it accomplishes, and when to use it.  
* **Parameter descriptions**: Explain what each input and output represents and provide context on expected values or formats.

The more detailed and clear your descriptions are, the better the model’s reasoning is, leading to more accurate action calls.

For an MCP tool's output, ODC delivers each field as a typed value when it can. Fields it can't type arrive as text containing a JSON-formatted string. Deserialize those fields to access nested values, and account for this in your output descriptions. Refer to [Unsupported structures](https://extranetprdintegrations.outsystems.net/Documentation_API/rest/getContentMarkdown/doc?Guid=debf6461-bb1c-45cb-9335-c2d8111dc937).

#### Guide the call condition

The **Call condition** setting is a safeguard within the **Action calling settings**. Its purpose is to prevent an AI agent from getting stuck in a loop or consuming excessive resources during runtime. You can define specific limits that, once reached, stop the agent from calling any more actions for the current task.

The agent concludes its reasoning loop when it meets a call condition. The agent then stops execution and raises an error to prevent infinite loops or excessive resource consumption.

You define an expression that evaluates after each action call. If the expression evaluates to `True`, the agent stops calling any more actions for the current task.

![Flowchart illustrating the decision process for call conditions in action calling, showing the steps from calling an action, updating variables, evaluating call condition expression, and either continuing or stopping execution.](images/call-condition-flow-diag.png "Call Condition Decision Flow Diagram")

#### Loops and internal variables

In Action calling, a **loop** is a single cycle where the AI model calls an action and then uses that action's output to reason about the next step. An agent can loop multiple times to gather enough information before generating a final answer.

Your call condition expression can use any of the variables that are in scope when **call agent** runs. As in any server action, these are the variables set by actions earlier in the logic flow of **AgentFlow**. Additionally, it can also use the following internal variables that track the agent’s progress in real-time:

* `TokenUsage`: Represents the total number of tokens the agent may consume in one execution of **call agent**. For example, the expression `TokenUsage = 3000` limits token use to a maximum of 3000 tokens.  
* `LoopCount`: Represents the number of reasoning loops the agent has executed in the current task.  
* `TotalCallsCount`: Represents the total number of individual actions the agent has called across all loops. For example, if the agent calls **action 1** 15 times and **action 2** 15, the `TotalCallsCount` is 30.

The agent may continue to execute actions as long as your expression evaluates to `False`.

<div class="info" markdown="1">

Use the **call condition** for process control and the **Max Tokens** setting for output control. The call condition stops the agent's execution and throws an error if it meets its expression, which prevents infinite loops. In contrast, the **Max Tokens** setting limits the final response length by returning a successful but potentially truncated output without an error, which manages the answer's cost and verbosity.

</div>

##### Examples

Here are some example expressions for the call condition:

* To stop the process before it consumes 3000 tokens: `TokenUsage >= 3000`  
* To limit the agent to a maximum of 50 reasoning loops: `LoopCount >= 50`  
* To stop the agent after it has made a total of 30 action calls (regardless of the number of loops): `TotalCallsCount >= 30`  
* To apply multiple conditions simultaneously: `TokenUsage >= 3000 or TotalCallsCount >= 30`


