Skip to content

generate-mdl skill writes bare-list relationships.yml that the loader silently ignores #2672

Description

@Sean-Liu-GitHub

Bug summary

The generate-mdl skill template (core/wren/src/wren/skills_content/generate-mdl/SKILL.md) instructs agents to write relationships.yml as a bare YAML list:

# relationships.yml (what the skill template shows)
- name: orders_customers
  models:
    - orders
    - customers
  join_type: many_to_one
  condition: "orders.customer_id = customers.customer_id"

But load_relationships() in context.py expects a dict with a top-level relationships: key:

# context.py — load_relationships()
data = yaml.safe_load(rel_file.read_text(encoding="utf-8")) or {}
rels = data.get("relationships") if isinstance(data, dict) else None
if not isinstance(rels, list):
    return []

A bare YAML list parses as a Python list, so isinstance(data, dict) is False, and the function returns []. The relationships are silently dropped.

The CLI's own writer (_convert_mdl_to_project_files) correctly uses the wrapper format:

yaml.dump({"relationships": rels_snake}, ...)

Expected format

# relationships.yml (what the loader expects)
relationships:
  - name: orders_customers
    models:
      - orders
      - customers
    join_type: many_to_one
    condition: "orders.customer_id = customers.customer_id"

Steps to reproduce

  1. Follow the quickstart guide to generate an MDL project using Claude Code with the /wren skill
  2. The skill generates relationships.yml as a bare list (following the SKILL.md example)
  3. Run wren context validate — reports 0 relationships
  4. Run wren context buildtarget/mdl.json has "relationships": []

Impact

  • Any project generated via the generate-mdl skill will have relationships silently ignored
  • wren context validate reports 0 relationships without any warning
  • Queries still work because agents can write explicit JOIN ... ON clauses, so the bug is hidden
  • AI agents lose relationship context from wren memory fetch, reducing their ability to generate correct JOINs automatically

Suggested fix

Update the YAML example in core/wren/src/wren/skills_content/generate-mdl/SKILL.md (Phase 4, Step 3) to include the relationships: top-level key, matching the format that load_relationships() expects.

Environment

  • wren CLI installed via pip install wrenai
  • Discovered while debugging a DuckDB-backed project where relationships were defined but missing from the compiled MDL

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