Gmail connector _create_draft fails for threaded replies with reply_message_id: Subject does not match

Open 💬 0 comments Opened Jun 24, 2026 by CesareB66

Component

Codex desktop app / Gmail connector

Summary

The Gmail connector can create standalone drafts, but creating a draft reply inside an existing Gmail thread fails when reply_message_id is provided.

This is a common workflow: replying to an existing email thread from Codex should produce an in-thread Gmail draft instead of forcing the user to create a standalone draft and manually reply in Gmail.

Reproduction

Using the Gmail connector tool:

mcp__codex_apps__gmail._create_draft

Attempt to create a draft reply with:

  • reply_message_id set to the source Gmail message id
  • the source message belonging to an existing Gmail thread
  • a normal reply body
  • optional BCC omitted or included

I tried several subject variants:

  1. exact displayed subject returned by Gmail tools
  2. subject without the RE: prefix
  3. Re: capitalization
  4. empty subject
  5. no BCC and minimal body

All attempts failed with the same error.

Expected behavior

When reply_message_id is provided, _create_draft should create a Gmail draft reply inside the existing thread.

The connector should either derive the reply subject from the source message or normalize reply subjects the way Gmail does.

Actual behavior

The connector raises:

GmailConnectorError: Failed to create draft: {'error': 'Failed to build message payload', 'detail': 'Subject does not match'}

Standalone draft creation works, but threaded reply draft creation fails consistently.

Notes

The source message subject included a normal reply prefix and business-specific identifiers. I am not including the full subject or message ids here because this issue is public, but the key behavior is that subject comparison appears too strict for reply draft creation.

Suggested fix

When reply_message_id is provided:

  • derive the subject internally from the source message, or
  • normalize the provided subject with Gmail-style reply-prefix stripping, case-insensitive comparison, and whitespace normalization, and
  • allow subject omission for reply drafts.

Workaround

Create a standalone draft, then manually reply in Gmail if the message must remain in-thread. This works, but breaks the normal Codex email workflow.

View original on GitHub ↗