Domain: email

System prompt:
You are a helpful Email assistant with access to all available tools. Operate in a safe and fully authorized environment—you do not need to ask for confirmation or permission before taking action. When identifiers such as names or IDs are missing, perform exactly one lookup per entity type, verify that you are reusing correct values from previous responses, and proceed using the retrieved data. Never assume or fabricate IDs, responses, or outcomes—rely solely on verified API results. Complete each task in a single, logical, and efficient execution flow.

Task:
I’m organizing my inbox so I can keep better track of discussions related to my performance reviews.

Messages from manager@company.com
 often get mixed with other conversations, and I want them grouped more cleanly.

Please create a label called “Manager Communication” — only if it doesn’t already exist — and treat it like my normal user-created labels.

Then set up a filter so that any incoming email from manager@company.com
 automatically gets tagged with this label. If there’s already a filter that handles the same sender, adjust it so that I have only one correct filter for this purpose.

Finally, look through all my existing threads and apply the “Manager Communication” label to every thread that contains messages from manager@company.com.

Available tools:
get_filter
list_threads
list_labels
create_filter
create_label
delete_filter
list_filters
modify_thread
get_label

Verification checks:
[{"verifier_type": "database_state", "name": "Label \u201cManager Communication\u201d Exists", "description": "Checks whether the new user-created label was created.", "gym_name": "gym-email-mcp", "validation_config": {"query": "SELECT COUNT(*) AS cnt\nFROM labels\nWHERE user_id = 'user_001'\n  AND name = 'Manager Communication';\n", "expected_value": 1, "comparison_type": "equals"}}, {"verifier_type": "database_state", "name": "Old Manager Filter Was Removed", "description": "Confirms the original filter for manager@company.com + hasAttachment=true is gone.", "gym_name": "gym-email-mcp", "validation_config": {"query": "SELECT COUNT(*) AS cnt\nFROM filters\nWHERE user_id = 'user_001'\n  AND criteria_json LIKE '%\"from\":\"manager@company.com\"%'\n  AND criteria_json LIKE '%\"hasAttachment\":true%';\n", "expected_value": 0, "comparison_type": "equals"}}, {"verifier_type": "database_state", "name": "Exactly ONE Filter Handles manager@company.com", "description": "Ensures there is only one active filter for this sender.", "gym_name": "gym-email-mcp", "validation_config": {"query": "SELECT COUNT(*) AS cnt\nFROM filters\nWHERE user_id = 'user_001'\n  AND (criteria_json LIKE '%manager@company.com%');\n", "expected_value": 1, "comparison_type": "equals"}}, {"verifier_type": "database_state", "name": "Added \u201cManager Communication\u201d Label", "description": "Ensures the correct filter applies the new label. Uses robust JSON substring matching.", "gym_name": "gym-email-mcp", "validation_config": {"query": "SELECT COUNT(*) AS cnt\nFROM filters f\nJOIN labels l\n  ON instr(f.action_json, l.id) > 0\nWHERE f.user_id = 'user_001'\n  AND f.criteria_json LIKE '%manager@company.com%'\n  AND l.user_id = 'user_001'\n  AND l.name = 'Manager Communication';\n", "expected_value": 1, "comparison_type": "equals"}}, {"verifier_type": "database_state", "name": "Manager Thread Are Labeled", "description": "Checks that the thread containing messages from the manager has the new label applied.", "gym_name": "gym-email-mcp", "validation_config": {"query": "SELECT COUNT(*) AS cnt\nFROM message_labels ml\nJOIN messages m ON m.id = ml.message_id\nJOIN labels l ON l.id = ml.label_id\nWHERE m.thread_id = 'thread_001'\n  AND l.name = 'Manager Communication'\n  AND l.user_id = 'user_001';\n", "expected_value": 2, "comparison_type": "equals"}}, {"verifier_type": "database_state", "name": "No Duplicate Label Attachments", "description": "Ensures each message received the label only once.", "gym_name": "gym-email-mcp", "validation_config": {"query": "SELECT COUNT(*) AS cnt\nFROM (\n  SELECT m.id\n  FROM messages m\n  JOIN message_labels ml ON m.id = ml.message_id\n  JOIN labels l ON l.id = ml.label_id\n  WHERE l.name = 'Manager Communication'\n    AND m.thread_id = 'thread_001'\n  GROUP BY m.id\n  HAVING COUNT(*) > 1\n) AS duplicates;\n", "expected_value": 0, "comparison_type": "equals"}}, {"verifier_type": "database_state", "name": "Label Counters Reflect Real State", "description": "Confirms that exactly two messages have the label.", "gym_name": "gym-email-mcp", "validation_config": {"query": "SELECT COUNT(*) AS cnt\nFROM message_labels ml\nJOIN labels l ON ml.label_id = l.id\nJOIN messages m ON ml.message_id = m.id\nWHERE l.user_id = 'user_001'\n  AND l.name = 'Manager Communication';\n", "expected_value": 2, "comparison_type": "equals"}}, {"verifier_type": "database_state", "name": "Label \u201cManager Communication\u201d Exists", "description": "Checks whether the new user-created label was created.", "gym_name": "gym-email-mcp", "validation_config": {"query": "SELECT COUNT(*) AS cnt\nFROM labels\nWHERE user_id = 'user_001'\n  AND name = 'Manager Communication';\n", "expected_value": 1, "comparison_type": "equals"}}, {"verifier_type": "database_state", "name": "Old Manager Filter Was Removed", "description": "Confirms the original filter for manager@company.com + hasAttachment=true is gone.", "gym_name": "gym-email-mcp", "validation_config": {"query": "SELECT COUNT(*) AS cnt\nFROM filters\nWHERE user_id = 'user_001'\n  AND criteria_json LIKE '%\"from\":\"manager@company.com\"%'\n  AND criteria_json LIKE '%\"hasAttachment\":true%';\n", "expected_value": 0, "comparison_type": "equals"}}, {"verifier_type": "database_state", "name": "Exactly ONE Filter Handles manager@company.com", "description": "Ensures there is only one active filter for this sender.", "gym_name": "gym-email-mcp", "validation_config": {"query": "SELECT COUNT(*) AS cnt\nFROM filters\nWHERE user_id = 'user_001'\n  AND (criteria_json LIKE '%manager@company.com%');\n", "expected_value": 1, "comparison_type": "equals"}}, {"verifier_type": "database_state", "name": "Added \u201cManager Communication\u201d Label", "description": "Ensures the correct filter applies the new label. Uses robust JSON substring matching.", "gym_name": "gym-email-mcp", "validation_config": {"query": "SELECT COUNT(*) AS cnt\nFROM filters f\nJOIN labels l\n  ON instr(f.action_json, l.id) > 0\nWHERE f.user_id = 'user_001'\n  AND f.criteria_json LIKE '%manager@company.com%'\n  AND l.user_id = 'user_001'\n  AND l.name = 'Manager Communication';\n", "expected_value": 1, "comparison_type": "equals"}}, {"verifier_type": "database_state", "name": "Manager Thread Are Labeled", "description": "Checks that the thread containing messages from the manager has the new label applied.", "gym_name": "gym-email-mcp", "validation_config": {"query": "SELECT COUNT(*) AS cnt\nFROM message_labels ml\nJOIN messages m ON m.id = ml.message_id\nJOIN labels l ON l.id = ml.label_id\nWHERE m.thread_id = 'thread_001'\n  AND l.name = 'Manager Communication'\n  AND l.user_id = 'user_001';\n", "expected_value": 2, "comparison_type": "equals"}}, {"verifier_type": "database_state", "name": "No Duplicate Label Attachments", "description": "Ensures each message received the label only once.", "gym_name": "gym-email-mcp", "validation_config": {"query": "SELECT COUNT(*) AS cnt\nFROM (\n  SELECT m.id\n  FROM messages m\n  JOIN message_labels ml ON m.id = ml.message_id\n  JOIN labels l ON l.id = ml.label_id\n  WHERE l.name = 'Manager Communication'\n    AND m.thread_id = 'thread_001'\n  GROUP BY m.id\n  HAVING COUNT(*) > 1\n) AS duplicates;\n", "expected_value": 0, "comparison_type": "equals"}}, {"verifier_type": "database_state", "name": "Label Counters Reflect Real State", "description": "Confirms that exactly two messages have the label.", "gym_name": "gym-email-mcp", "validation_config": {"query": "SELECT COUNT(*) AS cnt\nFROM message_labels ml\nJOIN labels l ON ml.label_id = l.id\nJOIN messages m ON ml.message_id = m.id\nWHERE l.user_id = 'user_001'\n  AND l.name = 'Manager Communication';\n", "expected_value": 2, "comparison_type": "equals"}}]