cl1p.net - The internet clipboard
cl1p.net Discord
Login/Sign Up
cl1p.net/4569
cl1p.net/4569
cl1p.net Discord
Login/Sign Up
This cl1p will be deleted in in 22 hours.
Copy
# Standing Order: Gmail Storage Cleanup ## Program: Gmail Storage Cleanup **Purpose:** Reduce Gmail storage usage safely by reviewing old email in small batches, applying Gmail labels, and maintaining durable local reports. This program must never delete, trash, archive, send, unsubscribe, create filters, or change Gmail settings automatically. **Token discipline:** Keep each run small and concise. Do not paste email bodies, large tool results, full ledgers, or long reports into chat. Use metadata/snippets first. Read full message bodies only when classification is impossible from metadata/snippet alone. **Authority:** The agent may inspect Gmail messages/threads and apply cleanup labels only. The agent may create missing approved labels and write local report files. The owner will manually review and delete/unsubscribe later. **Trigger:** Manual command or scheduled OpenClaw cron job. **Default batch size:** Process at most 25 messages per manual/test run and at most 100 messages per scheduled run unless the owner explicitly requests otherwise. Never process more than 500 messages in one run. **Default search scope:** ```text older_than:6m -label:oc-cleanup/processed ``` Prefer oldest-first processing by date window. Do not rely on Gmail pagination alone as the durable cursor. The durable checkpoint is the `oc-cleanup/processed` label. --- ## Compact Runtime Summary If context is tight, this section is the minimum required rule set: Run Gmail cleanup in batches. Label only. Never delete/trash/archive/send/draft/unsubscribe/create filters/change settings. Use labels: `oc-cleanup/processed`, `oc-cleanup/delete-candidate`, `oc-cleanup/keep`, `oc-cleanup/review`, `oc-cleanup/unsubscribe-candidate`, `oc-cleanup/large-attachment`, `oc-cleanup/bulk-sender`, `oc-cleanup/never-delete`. Default query: `older_than:6m -label:oc-cleanup/processed`. Max 25 test/manual, max 100 scheduled unless owner says otherwise. Process oldest-first where possible. Always add `processed` after classification. Maintain `gmail-cleanup/ledger.jsonl`, `summary.md`, `runs/*.json`, and final report. If uncertain, choose `review` or `keep`. Never paste email bodies or full ledgers into chat. --- ## Required Gmail Labels Ensure these labels exist before normal cleanup runs: ```text oc-cleanup/processed oc-cleanup/delete-candidate oc-cleanup/keep oc-cleanup/review oc-cleanup/unsubscribe-candidate oc-cleanup/large-attachment oc-cleanup/bulk-sender oc-cleanup/never-delete ``` A message may have multiple signal labels. However, exactly one final disposition label should be used where possible: ```text oc-cleanup/delete-candidate oc-cleanup/keep oc-cleanup/review ``` If uncertain, choose `oc-cleanup/review`. --- ## Allowed Actions The agent may: - List Gmail labels. - Create missing `oc-cleanup/*` labels. - Search Gmail messages/threads using safe queries. - Read message metadata, sender, date, labels, subject/snippet, size/attachment indicators, and limited body content only when needed for classification. - Apply Gmail labels from the approved `oc-cleanup/*` label set. - Append/update local reports and ledgers. - Report concise progress to the owner. --- ## Forbidden Actions The agent must never: - Delete messages. - Batch delete messages. - Trash messages. - Archive messages. - Mark messages read or unread. - Send emails. - Create, update, send, or delete drafts. - Click unsubscribe links. - Use Gmail unsubscribe automatically. - Create, update, or delete Gmail filters. - Change forwarding, delegate, send-as, vacation responder, IMAP/POP, S/MIME, language, or other Gmail settings. - Remove labels unless the owner explicitly asks for a correction. - Process more than the configured batch size. - Dump full email bodies, full message payloads, full tool output, or the full ledger into chat. If using a broad Gmail MCP, only use read/list/get label tools and modify-message/thread label tools. Do not call delete, trash, send, draft, filter, delegate, forwarding, settings-update, or other destructive/account-changing tools. --- ## MCP Tool Safety If Gmail MCP tools are visible, prefer only tools equivalent to: ```text list_labels create_label list_messages / list_threads get_message / get_thread modify_message / modify_thread batch_modify_messages, label-only use only get_profile ``` Avoid tools equivalent to: ```text delete_message batch_delete_messages trash_message untrash_message delete_thread trash_thread send_message create_draft update_draft send_draft delete_draft create_filter update_filter delete_filter update_auto_forwarding add_delegate remove_delegate create_forwarding_address update_send_as verify_send_as insert_smime_info set_default_smime_info ``` When applying labels with a batch-modify tool, only add approved `oc-cleanup/*` labels. Do not remove labels unless explicitly requested by the owner. --- ## Classification Rules ### Final disposition labels Apply one of: #### `oc-cleanup/delete-candidate` Use for messages that are likely safe for the owner to manually delete later, such as: - Old newsletters. - Marketing/promotional email. - Sale notifications. - Old automated status notifications. - Expired event reminders. - Old shipping/delivery notifications that are no longer useful. - Duplicate or low-value bulk mail. - Old alerts with no apparent ongoing account/security value. #### `oc-cleanup/keep` Use for messages that should probably be retained, such as: - Personal correspondence. - Family/friends messages. - Legal, tax, finance, insurance, medical, identity, security, or account-access messages. - Purchase receipts for important goods/services. - Warranty/license/subscription/account records. - Work/client/project correspondence. - Anything that appears uniquely important. #### `oc-cleanup/review` Use whenever uncertain, including: - Ambiguous sender or unclear purpose. - Possible account/security/billing relevance. - Messages with unusual attachments. - Messages that might be personal or work-related. - Any classification with low confidence. ### Signal labels Apply all relevant signal labels in addition to the final disposition: #### `oc-cleanup/unsubscribe-candidate` Use when the sender appears to be recurring promotional/newsletter/bulk mail and future messages are probably unwanted. Do not unsubscribe automatically. Only label and include in reports. #### `oc-cleanup/bulk-sender` Use for senders with repeated similar emails. #### `oc-cleanup/large-attachment` Use for messages likely to materially affect storage, especially messages matching or similar to: ```text larger:10M ``` #### `oc-cleanup/never-delete` Use for especially sensitive or important messages that should not be deletion candidates. --- ## Batch Execution Procedure For each cleanup run: 1. Ensure required `oc-cleanup/*` labels exist. 2. Load or create local cleanup state/report files. 3. Select the next date window or search query. 4. Search for messages matching: ```text older_than:6m -label:oc-cleanup/processed ``` or the current date-window equivalent. 5. Fetch at most the configured batch size. 6. Sort fetched messages oldest-first by Gmail/internal date when possible. 7. For each message/thread: - Inspect metadata/snippet first. - Read limited body content only if needed to classify safely. - Choose one final disposition label: delete-candidate, keep, or review. - Add any relevant signal labels. - Always add `oc-cleanup/processed` after classification. - Append one compact row to the durable ledger. 8. Update cumulative summary files. 9. Send a concise progress report. 10. Stop after one batch unless the owner explicitly asks to continue. 11. If no unprocessed messages remain, generate the final report. --- ## Reporting and Persistence Maintain these local files: ```text gmail-cleanup/ledger.jsonl gmail-cleanup/summary.md gmail-cleanup/runs/YYYY-MM-DD-HHMM.json gmail-cleanup/final-report.md ``` ### `ledger.jsonl` Append one compact JSON object per inspected message/thread. Include: ```json { "timestamp": "ISO timestamp", "messageId": "gmail message id", "threadId": "gmail thread id", "date": "message date", "from": "sender email or domain", "subjectHashOrShortSnippet": "short snippet or hash; avoid full subject/body when possible", "finalDecision": "delete-candidate | keep | review", "signals": ["unsubscribe-candidate", "bulk-sender", "large-attachment"], "reason": "brief reason", "queryOrWindow": "query/date window used" } ``` Avoid storing full email bodies unless explicitly requested. ### Per-run summary Each run should record: - Run timestamp. - Search query/date window. - Batch size requested. - Number processed. - Counts by final disposition. - Counts by signal label. - Oldest/newest message date in the batch. - Any failures or skipped messages. - Estimated remaining unprocessed count if available. ### Chat/Telegram report Keep the chat report brief, for example: ```text Processed 25 messages. 14 delete-candidate, 6 keep, 5 review. Signals: 7 unsubscribe-candidate, 2 large-attachment. Ledger and summary updated. No deletes performed. ``` Do not dump the full ledger, full per-message report, or email bodies into chat. --- ## Final Report When no messages remain matching the unprocessed cleanup query, generate: ```text gmail-cleanup/final-report.md ``` Include: 1. Overall totals. 2. Count by final disposition. 3. Top delete-candidate senders. 4. Top unsubscribe-candidate senders. 5. Large attachment candidates. 6. Review queue summary. 7. Suggested Gmail searches for manual review: ```text label:oc-cleanup/delete-candidate label:oc-cleanup/unsubscribe-candidate label:oc-cleanup/review label:oc-cleanup/large-attachment label:oc-cleanup/never-delete ``` 8. Safety notes and anything the owner should inspect before deleting. --- ## Token-Bloat Prevention Rules - Process one small batch per run. - Prefer fresh/isolated runs for scheduled batches. - Do not continue long Telegram conversations for many batches. - Do not paste full tool outputs into chat. - Do not store or repeat full email bodies. - Keep chat reports brief. - Keep durable details in local files, not conversation history. - If the model context becomes large, stop and ask the owner to run the next batch in a fresh session or cron job. Recommended OpenClaw config ideas for this agent: ```json5 { agents: { list: [ { id: "gmail-cleanup", contextInjection: "continuation-skip", contextLimits: { toolResultMaxChars: 8000, postCompactionMaxChars: 1200 }, compaction: { mode: "safeguard", truncateAfterCompaction: true, maxActiveTranscriptBytes: "5mb", keepRecentTokens: 12000 } } ] } } ``` --- ## Safety Defaults - If classification confidence is low, label `oc-cleanup/review`. - If a message appears sensitive, label `oc-cleanup/keep` or `oc-cleanup/never-delete`. - Prefer false positives in review/keep over false positives in delete-candidate. - Never perform destructive actions. - Never silently skip errors. Log and report them. - Stop after one batch per run unless the owner explicitly asks to continue. --- ## Example Manual Test Prompt ```text Dry-run the Gmail Storage Cleanup standing order on at most 5 messages. Do not apply labels. Do not modify Gmail. Use metadata/snippets first and do not read full bodies unless required. Report only concise counts and examples of decisions. ``` --- ## Example Real Batch Prompt ```text Execute the Gmail Storage Cleanup standing order. Process one batch only, maximum 25 messages, using the default unprocessed cleanup query. Apply labels only. Never delete, trash, archive, send, draft, unsubscribe, create filters, or change Gmail settings. Update the ledger and summary, then report concise counts. ``` --- ## Example Cron Prompt ```text Execute the Gmail Storage Cleanup standing order. Process one isolated batch only, maximum 100 messages, using the default unprocessed cleanup query. Apply labels only. Never delete, trash, archive, send, draft, unsubscribe, create filters, or change Gmail settings. Update the ledger and summary, then report concise counts. ```