When the modeling agent generates a domain model, it occasionally hallucinates invented datatype, dangling associations, invalid multiplicities, or attributes that violate metamodel constraints. Today these slip through to the user, who has to spot and report them manually.
This issue proposes wiring the existing validation pipeline directly into the agent's generation loop so quality issues are caught and corrected automatically before the result is returned.
### Motivation
- Hallucinations degrade trust in the agent and force users to debug generated models.
- The validation infrastructure already exists (/validate-diagram, three-layer validation: construction, metamodel .validate(), OCL).
- The agent is capable of self-correcting when given concrete error messages — we just aren't giving them to it.
### Proposed behavior
- Agent generates a domain model (current behavior).
- Backend immediately runs the validation pipeline on the generated model.
- If validation returns errors/warnings:
- Errors and warnings are formatted into a structured feedback message.
- The message is sent back to the agent with the original prompt + generated model + error list.
- Agent produces a corrected model.
- Loop until validation passes or max retries reached (suggest 2–3).
- If max retries hit, return the best attempt + the remaining issues so the user can fix manually.
When the modeling agent generates a domain model, it occasionally hallucinates invented datatype, dangling associations, invalid multiplicities, or attributes that violate metamodel constraints. Today these slip through to the user, who has to spot and report them manually.
This issue proposes wiring the existing validation pipeline directly into the agent's generation loop so quality issues are caught and corrected automatically before the result is returned.
### Motivation
### Proposed behavior
- Errors and warnings are formatted into a structured feedback message.
- The message is sent back to the agent with the original prompt + generated model + error list.
- Agent produces a corrected model.