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 trying to reorganize my mailbox before we close out the quarter. I need you to set up a few things for me across different parts of my account.
First, create two new labels named “Q4 Priority” and “Needs Review”, but only if they don’t already exist.

After that, go through my recent threads and do the following:
– Apply Q4 Priority to any thread whose snippet includes the word “deadline” and that contains at least four messages.
– Apply Needs Review to any thread whose snippet contains “review” and has exactly one message.

Once the labels are applied, set up a new filter that automatically applies Q4 Priority to future messages coming from “pm@contoso.com
”. If such a filter already exists, update it so it continues to apply that label.

Finally, check if auto-forwarding is enabled for my account. If it isn’t, enable forwarding to “backup-inbox@contoso.com
” while keeping a copy of forwarded messages in my inbox. Don’t create another forwarding address if the same one already exists; just update the settings to match the behavior I described.

Available tools:
update_auto_forwarding
get_thread
list_labels
modify_thread
create_filter
list_forwarding_addresses
list_filters
list_threads
create_forwarding_address
get_auto_forwarding
create_label

Verification checks:
[{"verifier_type": "database_state", "name": "Q4 Priority Label Created", "description": "Ensure a label named Q4 Priority exists for the user.", "gym_name": "gym-email-mcp", "validation_config": {"query": "SELECT COUNT(*) AS cnt\nFROM labels\nWHERE user_id = 'user_001'\n  AND name = 'Q4 Priority';\n", "expected_value": 1, "comparison_type": "equals"}}, {"verifier_type": "database_state", "name": "Needs Review Label Created", "description": "Ensure a label named Needs Review exists for the user.", "gym_name": "gym-email-mcp", "validation_config": {"query": "SELECT COUNT(*) AS cnt\nFROM labels\nWHERE user_id = 'user_001'\n  AND name = 'Needs Review';\n", "expected_value": 1, "comparison_type": "equals"}}, {"verifier_type": "database_state", "name": "Needs Review Applied", "description": "Confirm Needs Review label was applied to at least one message that belongs to a thread whose snippet contains 'review' and that thread has exactly 1 message.", "gym_name": "gym-email-mcp", "validation_config": {"query": "SELECT COUNT(DISTINCT t.id) AS cnt\nFROM message_labels ml\nJOIN labels l ON l.id = ml.label_id\nJOIN messages m ON m.id = ml.message_id\nJOIN threads t ON t.id = m.thread_id\nWHERE l.user_id = 'user_001'\n  AND l.name = 'Needs Review'\n  AND LOWER(t.snippet) LIKE '%review%'\n  AND (\n      SELECT COUNT(*) FROM messages m2 WHERE m2.thread_id = t.id\n  ) = 1;\n", "expected_value": 2, "comparison_type": "equals"}}, {"verifier_type": "database_state", "name": "Filter for pm@contoso.com  exists and applies Q4 Priority", "description": "Ensure a filter exists whose criteria reference pm@contoso.com and whose action_json applies the Q4 Priority label (action_json should contain the label name or id).", "gym_name": "gym-email-mcp", "validation_config": {"query": "SELECT COUNT(*) AS cnt\nFROM filters f\nWHERE f.user_id = 'user_001'\n  AND LOWER(f.criteria_json) LIKE '%pm@contoso.com%'\n  AND f.action_json LIKE '%' || (\n        SELECT id FROM labels\n        WHERE user_id = 'user_001'\n        AND name = 'Q4 Priority'\n     ) || '%';\n", "expected_value": 1, "comparison_type": "equals"}}, {"verifier_type": "database_state", "name": "Forwarding address created for backup-inbox@contoso.com", "description": "Ensure forwarding address entry exists.", "gym_name": "gym-email-mcp", "validation_config": {"query": "SELECT COUNT(*) AS cnt\nFROM forwarding_addresses\nWHERE user_id = 'user_001'\n  AND forwarding_email = 'backup-inbox@contoso.com';\n", "expected_value": 1, "comparison_type": "equals"}}, {"verifier_type": "database_state", "name": "Auto-forwarding enabled and configured to keep copy", "description": "Ensure auto_forwarding settings are enabled for backup-inbox@contoso.com and configured to keep a copy (disposition = 'leaveInInbox').", "gym_name": "gym-email-mcp", "validation_config": {"query": "SELECT COUNT(*) AS cnt\nFROM auto_forwarding af\nWHERE af.user_id = 'user_001'\n  AND af.enabled = 1\n  AND LOWER(af.email_address) = 'backup-inbox@contoso.com'\n  AND af.disposition = 'leaveInInbox';\n", "expected_value": 1, "comparison_type": "equals"}}]