- Home
- Skills
- Agents & Orchestration
- email-threading-gate
Works with the AI Agents you already use
Email Threading Gate
by Tradeplier
Prevent Gmail thread splitting and encoding corruption with a strict pre-send validation gate.
$27.39
email-threading-gate
Example session with this skill installed
Before this reply goes out, run the email threading gate on it.
Thread FIXTURE_THREAD_ID, In-Reply-To anchor-message-id@mail.example.com,
outgoing subject 'Important Thread -- Details'.
- Read your context and instructions
- Compiled the email-threading-gate
[threading_gate] E4: immediate parent is own send (sender@example.com). Resolving subject from References chain.
[threading_gate] E4: resolved original_subject='Important Thread — Details' from References anchor anchor_id
AssertionError
Threading gate: Reply subject mismatch after stripping Re:/Fwd:.
Outgoing (stripped): 'Important Thread -- Details'
Original (stripped): 'Important Thread — Details'
Do not normalize a reply subject -- normalization changes the conversation key and splits the thread.
Telegram alert fired
⛔ Threading gate STOP: Threading gate: Reply subject mismatch after stripping Re:/Fwd:.
Outgoing (stripped): 'Important Thread -- Details'
Original (stripped): 'Important Thread — Details'
Do not normalize a reply subject -- normalization changes the conversation key and splits the thread.
(Same reply with the original em-dash subject intact: gate returns None, no alert, send proceeds.)
Connects securely to your tools. The creator never sees your data.
About this skill
The problem
Automated Gmail workflows often fail silently when message threads split due to subject encoding mojibake or using the wrong In-Reply-To source. These threading errors are difficult to debug after the fact and unprofessional for recipients.
What it does
- Enforces a single choke point before outbound API calls to prevent invalid sends.
- Detects and blocks subject encoding corruption like em-dash normalization and latin-1 mojibake bigrams.
- Verifies In-Reply-To provenance against the sending account's own mailbox; when the immediate parent is your agent's own send, resolves the true subject through the References chain instead of trusting the caller.
- Fires immediate Telegram alerts for precondition failures or degraded service states.
- Gracefully handles "Fresh Send" modes while maintaining type and mojibake safety checks.
Frameworks & tools
Python 3.11+, google-api-python-client, and google-auth. Designed specifically for Google Workspace with Domain-Wide Delegation (DWD).
Why this beats prompting it yourself
The checks in this gate grew out of documented production failures: a latin-1 subject mangle that forked a client thread despite correct In-Reply-To headers; a cross-account thread ID that 404'd; an em-dash retyped as a double hyphen that split a 27-message thread three times in one evening; and a degraded mode that silently skipped its own subject check for two days because one caller omitted one parameter. Each incident is documented in the included PROVENANCE.md, dated, and mapped to the test that now catches it.
The suite collects 38 cases across ten test files; a standard run reports 36 passed and 2 skipped (the two live cross-namespace Gmail tests, which run only when credentials are configured). It includes replays of the actual failing inputs through the production call path. This is not threading logic an LLM guessed at; it is the scar tissue of a production fleet that runs a real company, packaged.
Use cases
- Preventing automated support responses from splitting into multiple threads.
- Auditing outbound sales sequences for subject line encoding integrity.
- Ensuring internal bot notifications correctly thread under the specific trigger email.
- Standardizing email send safety across multiple service accounts or apps.
Known limitations
Gmail-specific by design, targeting the Gmail API thread model and RFC 2822 headers. The Telegram alert hook is a documented swap-point: it defaults to the OpenClaw CLI and swaps cleanly for your own alert channel.
About the builder
Built by Tradeplier: a licensed Massachusetts builder running a $1M/yr construction company on an agent back office, in production since April 2026. We file the bugs we find upstream: six issues on openclaw/openclaw to date, four rated diamond lobster by the project. If this skill breaks in your fleet, the incident becomes a test and you get the fix. The full audit story behind all three, including the part where the audit caught these packages themselves, is at https://www.tradeplier.com/audit-story/
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 4 months ago
- Accounts
Telegram
Gmail
- Software
Python
Permissions
Allowed Hosts
File Scopes
Network: Gmail API over Google endpoints (gmail.googleapis.com, www.googleapis.com) and oauth2.googleapis.com for OAuth token refresh. Gmail calls are read-only (messages.get, threads.get): the skill validates outbound sends but never sends mail itself. Telegram alerts go through one fixed-argument subprocess call to the local openclaw CLI, which is why Terminal/Shell is declared. No shell=True, no user input in the command, best-effort only (a failed alert never blocks). Files: reads four Gmail credential files under ~/.openclaw/secrets/ (two refresh tokens, OAuth client id, OAuth client secret), read-only. The skill writes no files, no logs, no state. Env vars: GOOGLE_SERVICE_ACCOUNT_KEY (required, service account credentials) and GOOGLE_POLLER_SA_KEY (optional override). Two further vars gate the single live test, which is skipped by default. No telemetry, no phone-home, no external fetches at runtime.
What's inside
Frequently Asked Questions
New in Agents & Orchestration
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Agents & Orchestration.