Skip to content

Bug: compound "or" in trigger.tag_groups silently stored as "and" (Pydantic union deserialization) #1583

@yugandhar-maram

Description

@yugandhar-maram

Bug Description

When passing a compound {"or": [...]} expression in trigger.tag_groups during mental model create or update, the server accepts it (200 OK) but stores and returns it as {"and": [...]}. This makes it impossible to scope a mental model's refresh trigger to multiple non-overlapping tag sets with OR semantics.

Steps to Reproduce

# PATCH a mental model with "or" in tag_groups
curl -X PATCH "http://127.0.0.1:8888/v1/default/banks/my-bank/mental-models/<mm_id>" \
  -H "Content-Type: application/json" \
  -d '{
    "trigger": {
      "tag_groups": [{"or": [
        {"tags": ["ns:a"], "match": "all_strict"},
        {"tags": ["ns:b"], "match": "all_strict"}
      ]}]
    }
  }'

# Read it back
curl "http://127.0.0.1:8888/v1/default/banks/my-bank/mental-models/<mm_id>"

Expected Behavior

trigger.tag_groups returns:

[{"or": [{"tags": ["ns:a"], "match": "all_strict"}, {"tags": ["ns:b"], "match": "all_strict"}]}]

Actual Behavior

trigger.tag_groups returns:

[{"and": [{"tags": ["ns:a"], "match": "all_strict"}, {"tags": ["ns:b"], "match": "all_strict"}]}]

Version

hindsight-all 0.6.0 / hindsight_api_slim 0.5.6

LLM Provider

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions