-
Notifications
You must be signed in to change notification settings - Fork 8
Description
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:
- The "Ghost List" Anti-pattern: Instead of accepting the incoming data as a Microflow Parameter, it uses a
Create Variableactivity to instantiate a brand-new, empty list. - The O(N^2) Anti-pattern: It then attempts to merge the data using standard programming paradigms (a
LOOPinside aLOOPwith aDecisiondiamond) 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 theReviewReasonon theQuotationDetail:
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.
Expected Behavior:
The AI should recognize this as a Mendix list-matching/delta-merge scenario. It should:
- Define the imported JSON list as a Microflow Parameter (not a created variable).
- Generate a single loop for the incoming objects.
- 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 anIF $Match != emptycheck 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"