Skip to content

docs(gmail): default get_thread to MINIMAL; escalate to FULL_CONTENT only on body-parse#409

Merged
potiuk merged 1 commit into
apache:mainfrom
potiuk:feat-gmail-thread-minimal-default
May 31, 2026
Merged

docs(gmail): default get_thread to MINIMAL; escalate to FULL_CONTENT only on body-parse#409
potiuk merged 1 commit into
apache:mainfrom
potiuk:feat-gmail-thread-minimal-default

Conversation

@potiuk
Copy link
Copy Markdown
Member

@potiuk potiuk commented May 31, 2026

Summary

Profiling a 12-tracker bulk sync surfaced that Gmail `get_thread` calls were responsible for ~170 KB of in-context spillover (single largest: 440 KB). Most call sites only needed the chronologically-last message ID, label state, or thread-exists check — all of which `MINIMAL` satisfies at ~5K tokens vs ~60-100K for `FULL_CONTENT` on a typical reporter conversation.

Changes

`tools/gmail/operations.md`

  • Flip the default example from `FULL_CONTENT` to `MINIMAL`.
  • Document a clear escalation rule — default to `MINIMAL`; escalate to `FULL_CONTENT` only when the call site actually processes the message body:
    • `security-issue-import` Step 3 (classification by body scanning)
    • `security-issue-sync` Step 1e (reviewer-comment body parsing)
    • Draft-composition steps that quote the reporter's prior message
    • Credit-form extraction from inbound report bodies
  • Fix a longstanding terminology error — the doc said `METADATA` but the MCP enum is `MINIMAL`.
  • Privacy-LLM contract scoping — `MINIMAL` calls are exempt from the redact-after-fetch protocol (headers only, no free-form body content).

`security-issue-sync` Step 1e

Make the `FULL_CONTENT` requirement explicit — reviewer comment bodies ARE the actionable signal here. Reinforce the contrast with the rest of the skill, which defaults to `MINIMAL`.

Estimated savings

~80% of Gmail-related tokens on typical bulk runs (60-100K → ~5K per call). Compounds on every bulk-sync invocation.

Test plan

  • Doc-only change; no Python code touched; `skill-and-tool-validate` passes
  • Next bulk sync run on `airflow-s/airflow-s` confirms typical `get_thread` calls land at `MINIMAL` size

🤖 Generated with Claude Code

…only on body-parse

Profiling a 12-tracker bulk sync surfaced that Gmail get_thread calls
were responsible for ~170 KB of in-context spillover (top single
spillover file was 440 KB) — a FULL_CONTENT call on a long reporter
conversation routinely lands 60-100K tokens. Most call sites only
needed the chronologically-last message ID for anchoring, the SENT/
DRAFT label state, or the thread-exists check — all of which MINIMAL
satisfies at ~5K tokens.

Changes:

1. tools/gmail/operations.md — flip the default example from
   FULL_CONTENT to MINIMAL. Document a clear escalation rule:
   default to MINIMAL; escalate to FULL_CONTENT only when the call
   site actually processes the message body (Step 3 classification in
   security-issue-import, Step 1e reviewer-comment parsing in
   security-issue-sync, draft-composition that quotes the reporter's
   prior message, credit-form extraction). Also fix a longstanding
   terminology error: the doc said 'METADATA' but the MCP enum is
   'MINIMAL'.

2. security-issue-sync Step 1e — make the FULL_CONTENT requirement
   explicit (reviewer comment bodies ARE the actionable signal).
   Reinforce the contrast with the rest of the skill, which defaults
   to MINIMAL.

The privacy-LLM contract block was updated accordingly — the
redact-after-fetch protocol applies to FULL_CONTENT calls; MINIMAL
calls are exempt (they carry headers only, no free-form body
content).

Estimated savings: ~80% of Gmail-related tokens on typical bulk runs
(60-100K → ~5K per call). Compounds on every bulk-sync invocation.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@potiuk potiuk merged commit 8ba93cc into apache:main May 31, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant