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 reorganizing my mailbox because we’re preparing for our cross-department audit next week.
I need you to set up a structured workflow for all emails related to reviews, proposals, budgets, or milestone updates.

Here’s what I want you to do:

Look for all messages where the subject or sender involves:
- manager@company.com
- team@company.com
- finance@company.com
- anything containing ‘Review’, ‘Proposal’, ‘Budget’, or ‘Milestone’.

For each matched message:
- Apply a new label called “Audit Review Required” (create it if missing).
- If the message has an attachment (check attachments table), also apply a label “Has Attachment”.

For the threads these messages belong to:
- Label the entire thread as “Active Audit Thread”.

Check if I have any draft replies in drafts referencing any matched threads.
- If found, apply label “Pending Reply (Audit)” to those draft messages.

Update my send-as signature for alice@example.com to append the line:
“This email may be part of the Q1 Audit Review process.”

Ensure my forwarding settings send a copy of messages from manager@company.com
 and team@company.com
 to alice.backup@example.com (only if not already configured).

Please confirm everything is set up cleanly and consistently across messages, drafts, labels, threads, and send-as settings.

Available tools:
list_drafts
list_filters
get_user_profile
list_forwarding_addresses
modify_message
list_send_as_aliases
list_messages
create_label
create_filter
modify_thread
get_auto_forwarding
get_send_as_alias
list_labels
patch_send_as_alias
get_message
get_draft

Verification checks:
[{"verifier_type": "database_state", "name": "Draft Pending Reply Label Applied", "description": "draft_msg_001 belongs to thread_001 \u2192 should be labeled.", "gym_name": "gym-email-mcp", "validation_config": {"query": "SELECT COUNT(*)\nFROM message_labels ml\nJOIN labels l ON ml.label_id = l.id\nWHERE l.name = 'Pending Reply (Audit)'\n  AND ml.message_id = 'draft_msg_001';\n", "expected_value": 1, "comparison_type": "equals"}}, {"verifier_type": "database_state", "name": "Audit Labels Created", "description": "Ensures all required audit labels exist.", "gym_name": "gym-email-mcp", "validation_config": {"query": "SELECT COUNT(*)\nFROM labels\nWHERE user_id = 'user_001'\n  AND name IN (\n      'Audit Review Required',\n      'Has Attachment',\n      'Active Audit Thread',\n      'Pending Reply (Audit)'\n  );\n", "expected_value": 4, "comparison_type": "equals"}}, {"verifier_type": "database_state", "name": "Audit Review Required Label Applied", "description": "Verifies that msg_001, msg_002, msg_003 all received Audit Review Required.", "gym_name": "gym-email-mcp", "validation_config": {"query": "SELECT COUNT(DISTINCT ml.message_id)\nFROM message_labels ml\nJOIN labels l ON ml.label_id = l.id\nWHERE l.name = 'Audit Review Required'\n  AND ml.message_id IN ('msg_001', 'msg_002', 'msg_003');\n", "expected_value": 3, "comparison_type": "equals"}}, {"verifier_type": "database_state", "name": "Has Attachment Label Applied", "description": "Only msg_002 contains an attachment \u2192 must be labeled.", "gym_name": "gym-email-mcp", "validation_config": {"query": "SELECT COUNT(*)\nFROM message_labels ml\nJOIN labels l ON ml.label_id = l.id\nWHERE l.name = 'Has Attachment'\n  AND ml.message_id = 'msg_002';\n", "expected_value": 1, "comparison_type": "equals"}}, {"verifier_type": "database_state", "name": "Active Audit Threads Labeled", "description": "thread_001 (msg_001 + msg_003) and thread_002 (msg_002) should be labeled.", "gym_name": "gym-email-mcp", "validation_config": {"query": "SELECT COUNT(DISTINCT m.thread_id)\nFROM message_labels ml\nJOIN labels l ON ml.label_id = l.id\nJOIN messages m ON ml.message_id = m.id\nWHERE l.name = 'Active Audit Thread'\n  AND m.thread_id IN ('thread_001', 'thread_002');\n", "expected_value": 2, "comparison_type": "equals"}}, {"verifier_type": "database_state", "name": "No Extra Draft Labels Applied", "description": "Ensures only the correct draft was labeled.", "gym_name": "gym-email-mcp", "validation_config": {"query": "SELECT COUNT(*)\nFROM message_labels ml\nJOIN labels l ON ml.label_id = l.id\nWHERE l.name = 'Pending Reply (Audit)'\n  AND ml.message_id NOT IN ('draft_msg_001');\n", "expected_value": 0, "comparison_type": "equals"}}, {"verifier_type": "database_state", "name": "Send-As Signature Updated", "description": "Signature must contain the audit line.", "gym_name": "gym-email-mcp", "validation_config": {"query": "SELECT COUNT(*)\nFROM send_as_aliases\nWHERE user_id = 'user_001'\n  AND send_as_email = 'alice@example.com'\n  AND signature LIKE '%This email may be part of the Q1 Audit Review process.%';\n", "expected_value": 1, "comparison_type": "equals"}}, {"verifier_type": "database_state", "name": "Forwarding Filter for Manager Created", "description": "Ensures a forwarding filter sends manager@company.com  mail to alice.backup@example.com.", "gym_name": "gym-email-mcp", "validation_config": {"query": "SELECT COUNT(*)\nFROM filters\nWHERE user_id = 'user_001'\n  AND action_json LIKE '%alice.backup@example.com%'\n  AND criteria_json LIKE '%manager@company.com%';\n", "expected_value": 1, "comparison_type": "equals"}}, {"verifier_type": "database_state", "name": "Forwarding Filter for Team Created", "description": "Ensures forwarding is also applied for team@company.com.", "gym_name": "gym-email-mcp", "validation_config": {"query": "SELECT COUNT(*)\nFROM filters\nWHERE user_id = 'user_001'\n  AND action_json LIKE '%alice.backup@example.com%'\n  AND criteria_json LIKE '%team@company.com%';\n", "expected_value": 1, "comparison_type": "equals"}}, {"verifier_type": "database_state", "name": "No Incorrect Audit Labels Applied", "description": "Ensures that No Incorrect Audit Labels Applied", "gym_name": "gym-email-mcp", "validation_config": {"query": "SELECT COUNT(DISTINCT ml.message_id) FROM message_labels ml JOIN labels l ON ml.label_id = l.id WHERE l.name = 'Audit Review Required' AND ml.message_id NOT IN ('msg_001', 'msg_002', 'msg_003');", "expected_value": 0, "comparison_type": "equals"}}]