30
Views
4
Comments
Failed to deserialize the response of AI model into the predefined structured output
Application Type
Service

Hi everyone,

I am currently building an agentic application in OutSystems 11. To ensure a stable and valid response, I am using the Structured Output feature in the AI Agent. However, I consistently encounter the following error after receiving the response from the model:

OS-BERT-00000 - Error executing action Failed to deserialize the response content '{"ConstructionVa...' from the AI model response to the structured output. 

What I have investigated so far:

  • Max Tokens: I have increased the Max Tokens to 2000, but the error persists.

Questions:

  1. Is there a known limitation on the size of the Structured Output?

  2. How can I capture the entire raw response string before the deserialization fails to debug the exact JSON structure?

  3. Could this be related to specific data types (Integer/Decimal) in my OutSystems Structure?

2025-12-22 13-50-43
Sherif El-Habibi
Champion

Hello @Tâm Phan,

Max Tokens only control the length of the response generated by the AI model. This happens after the structured output has been successfully mapped, so the Max Tokens step has not been reached yet. The error is likely triggered before that.

To explain the flow:

First, the agent receives the grounding data, which is usually in JSON format. Then, based on the system message configured in the Build Messages actions, the agent is assigned a persona (such as an assistant, doctor, etc.). Finally, the messages are passed to the agent to process, which can be done either through structured output (as in your case) or action calling.

In both cases, there is a mandatory and very important step that helps the agent map fields correctly or choose the right action, which is the description.

For example, if you create a structure with a field called "discount", it may be obvious to us that it represents a value deducted from the original price. However, if the description of this field is not provided, the agent may not understand how to handle it properly.

If I were you, I would start by reviewing and improving the descriptions, as this could be directly related to the issue. If that does not resolve it, I would then check the logs in the ODC portal to identify the exact error in detail.

2024-11-14 08-23-36
Melvin September

Hi @Tâm Phan,

I encountered this problem aswell when doing a Agentic AI POC.
In my case I had the structured output also in my prompts to help the agent understand my Output structure. For each key-value pair i had a brief description about how and what he needs to map.

When the agent is mapping the values found to the Output Structure it strictly uses Case Sensitive approach. I had a prompt column 'INSZ' and output column called 'insz'. I solved the problem by changing my output column to uppercase.

Hope this information can resolve your issue and to extend Sherif's remark double check your datatypes.

Kind Regards,
Melvin 

2018-12-10 12-16-21
Goncalo Duarte Almeida

Try this steps to find the issue:

  • Reduce your Structure to just two Text attributes. If that works, add your Integer/Decimal fields back one by one to find the "poison" attribute.
  • Explicitly instruct the model in the System Prompt:  "Return valid JSON only. Do not include markdown formatting or backticks. Ensure all numeric values are formatted as Decimals."
  • Go to Service Center > Monitoring > Errors. Search for the OS-BERT-00000 entry. Sometimes the "Detail" view provides a snippet of the JSON where the parser gave up.

I face this issue and the problem was with the json and the first optin resolved my problem.

UserImage.jpg
Saicharan

Hi 

There isn’t a published hard size limit for Structured Output in OS11, but deserialization typically fails when the model’s JSON doesn’t exactly match your Structure (arrays vs. objects, nullability, unexpected/extra fields), or when numeric/decimal values arrive as strings or with locale commas. Keep the payload compact (tens of KB), use ISO formats (ISO‑8601 dates, “.” for decimals), mark nullable fields as Nullable, lists as List, ensure booleans are true/false (not "true"), and consider defining numeric fields as Text first, then converting with TextToInteger / TextToDecimal. 

If your object can grow large (long texts, nested arrays), trim the schema or ask the model to return only the necessary fields. To debug, wrap the AI Agent call in a Try/Catch server action and capture the raw content before deserialization. 

E.g., add a Text output on the Agent (like RawResponseText) or call the same model via an intermediate REST action that returns Text.

 Log the raw JSON in Service Center (ExceptionMessage, ExceptionDetail, and the raw body), then manually test with JSON_Deserialize() into a simple Record/Record List (or a temporary text‑typed Structure) to pinpoint the failing field. 

If the agent UI doesn’t expose raw content, keep the model response as free text for one run, log it, validate with a JSON linter, and only then map it back to your strongly typed Structure.

Thanks,

Saicharan

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.