Unexpected data format in agent output

Updated: 2026-08-01Reading time: 3 min

Fix issues where agent output contains incorrectly typed values, missing fields, malformed JSON, or misformatted dates that cause downstream steps or systems to reject the data.

Identifying the format mismatch

When a downstream step or external system rejects data from an agent, the first step is to view the actual output produced by the agent. In the Activity tab, open a failed run, navigate to the step that produced the data, and click 'View output' in the step detail panel. Compare the actual output structure to the schema the downstream system expects. Common mismatches include: a numeric value being output as a string (for example, `"42"` instead of `42`), a date formatted as `MM/DD/YYYY` when the target system requires ISO 8601 (`YYYY-MM-DD`), or a nested object being flattened into dot-notation keys when the target expects a true nested structure.

Using transform steps to reshape data

Cotonity's Transform step lets you reshape, cast, and reformat data between workflow steps without writing code. Open the workflow editor, add a Transform step immediately after the step producing the unexpected output, and use the visual mapping interface to correct each field. To cast a string to a number, select the field and choose 'Number' from the type dropdown. To reformat a date, select the field, choose 'Date', and specify both the input format and the desired output format using standard format tokens. For complex transformations such as splitting a full name into first and last name fields, switch the Transform step to 'Expression mode' and use the built-in string functions.

Handling null and missing fields

A frequent source of format errors is a field that is present in some records but absent in others. When a downstream step receives a payload with a missing field it expects, it may throw an error or silently produce incorrect results. Defend against this by adding null-check conditions before sensitive steps, or by using the 'Default value' option on input fields within steps — this substitutes a specified value when the upstream field is null or absent. For boolean fields specifically, be aware that an absent field and a false value are semantically different; use explicit default values rather than relying on the step to infer the intent.