Skip to content

AI invents empty lists and defaults to nested loops for delta merges #21

@MauVisser

Description

@MauVisser

Environment:

  • Mendix Version: Studio Pro 11.8.0
  • mxcli Version: v0.2.0-dirty (2026-03-15T09:22:47Z)

AI invents empty lists and defaults to nested loops for delta merges
Severity: Medium | Area: AI Skills / Code Generation | Status: Open

When providing the AI (via Claude Code) with a standard business specification to merge delta updates (e.g., imported JSON data) into existing Mendix records, the AI fundamentally hallucinates the Mendix data model in two distinct ways:

  1. The "Ghost List" Anti-pattern: Instead of accepting the incoming data as a Microflow Parameter, it uses a Create Variable activity to instantiate a brand-new, empty list.
  2. The O(N^2) Anti-pattern: It then attempts to merge the data using standard programming paradigms (a LOOP inside a LOOP with a Decision diamond) rather than a Mendix List Operation.

Repro / Prompt:
Ask the CLI agent to generate a microflow based on this standard business specification for processing AI Agent outputs:

String-to-Enum Translation & Delta Merge (SUB_Agent3_ApplyDelta)
Iterate through the imported JSON objects (Agent 3's flagged items). Merge the audit findings into the generated records (Quotation Details).
The Append Logic: To prevent Agent 3 from overwriting Agent 2's notes, use this logic when updating the ReviewReason on the QuotationDetail:
if $Agent3_FlaggedItem/ReviewReason != empty then $QuotationDetail/ReviewReason + ' \n ' + $Agent3_FlaggedItem/ReviewReason else $QuotationDetail/ReviewReason

Actual Behavior (Generated MDL):
Because the prompt asks to "Iterate" and "Merge," the AI constructs a broken architecture. It generates a Create Variable activity for the Agent 3 items (creating an empty list), loops over that empty list, and places an inner loop inside it iterating through the entire list of QuotationDetail records using a Decision diamond ($DetailItem/LineNumber = $FlaggedItem/LineNumber) to find the match.

Image Image

Expected Behavior:
The AI should recognize this as a Mendix list-matching/delta-merge scenario. It should:

  1. Define the imported JSON list as a Microflow Parameter (not a created variable).
  2. Generate a single loop for the incoming objects.
  3. Inside that loop, use an in-memory retrieve (RETRIEVE $Match FROM $QuotationDetails WHERE ... LIMIT 1) which acts as a Mendix List Operation: Find, followed by an IF $Match != empty check to apply the append logic.

Proposed Fix:
The bundled .claude/skills/mendix/patterns-data-processing.md skill file needs an explicit Anti-Patterns section adding rules such as:

  • "NEVER INVENT LISTS: If processing imported data, pass the list as a parameter, do not use Create Variable."
  • "NEVER USE NESTED LOOPS FOR MATCHING: Always loop over the primary list and use a RETRIEVE ... FROM $List WHERE ... LIMIT 1"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions