Skip to content

Auto-validate agent-generated domain models and feed errors back for self-correction #522

Description

@ArmenSl

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

  1. Agent generates a domain model (current behavior).
  2. Backend immediately runs the validation pipeline on the generated model.
  3. 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.
  4. Loop until validation passes or max retries reached (suggest 2–3).
  5. If max retries hit, return the best attempt + the remaining issues so the user can fix manually.

Metadata

Metadata

Assignees

Labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions