Repository navigation
feat: let Knowledge learn from your Gmail through Composio - #207266
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs changes before merge. What this changesAdds a Knowledge Mail scribe that reads Gmail through Composio and saves selected threads once or on a schedule. Example: Ann emails [email protected] asking for a signed contract, and the owner promises to send it Thursday.
Review scores
The scores reflect the reviewer's assessment. Real behavior proof is not required for maintainer- or bot-authored pull requests. ProductKind: Feature · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 3 items remain Keep this PR open: the Mail scribe is a useful addition, but the Composio response adapter and deletion reconciliation need repair before merge. Reviewed head: Before merge
Findings
Agent review detailsHow this fits togetherThe Knowledge Scribes UI creates agent conversations and automations; the new ingestion skill reads Gmail through the Composio CLI, requests triage decisions, and publishes Knowledge sources, claims, and checkpoint notes. flowchart LR
A[Scribes UI] --> B[Agent conversation or automation]
B --> C[Mail ingestion skill]
C --> D[Composio CLI]
D --> E[Gmail]
C --> F[Decision model]
C --> G[Knowledge sources and checkpoints]
Technical reviewBest possible solution: Keep the existing scribe architecture, resolve Composio's stored response files, and preserve historical snapshot coverage when reconciling whole threads. Do we have a high-confidence way to reproduce the issue? Source inspection establishes the large-response and shrinking-coverage failures, but no product execution was performed under this read-only review. Is this the best way to solve the issue? Reusing the existing catalog, automation, settings, and manifest owners is appropriate; the reader must consume the real CLI contract and complete snapshots must retain coverage of previously observed messages. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e2fa67aec0a9. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +1031, Tests +634, Docs +197, Other +3. Total +1865 across 15 files. Added test files: 2. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 28, 2026, 12:47 AM ET / 05:47 UTC. |
fdd1dc8 to
88a3ed4
Compare
783e2be to
b793b93
Compare
…tect calendar parts
OpenClaw-Publication: c853f838-3413-89f0-a2e4-ed76001d773e
Composio CLI 0.6.x saves a large tool answer to a local file and prints only storedInFile and outputFilePath. The Gmail reader now reads the whole answer from that file and then removes the file and its folder, which hold the owner's mail. Before, those threads came back with no messages.
Each run now works in a private mktemp folder, so its thread files and the Composio CLI's saved answers land there, and removes it with rm -rf when the run ends. Live runs had left copies of mail in /tmp and the workspace.
…ocale strings Rebased onto main, where scribe titles, blurbs and labels and the plugin readiness lines moved into i18n/locales/en-scribes.ts.
…n folder The CLI saves large answers under COMPOSIO_RUN_OUTPUT_DIR and COMPOSIO_SESSION_DIR, which default to the system temporary folder, not the working folder. gmail-read.mjs now points both at .composio in the working folder, so removing the run folder also removes an answer an interrupted read left behind.
…and allocate the Mail scribe test lines CI runs this suite under Bun, whose directory is the only runtime on the test PATH, so the stand-in CLI's #!/usr/bin/env node shebang found no node and every read failed as signed-out. The stand-in now lives in composio.cjs behind a sh wrapper that execs process.execPath. The Mail scribe adds 658 test lines against the 400 allowance; the allocation records the other 258.
The Bun-safe stand-in CLI wrapper added 4 lines, so the scribe now adds 662 net test lines against the 400 allowance.
207cea5 to
2abe1a2
Compare
…line * commit '652611b9d924c754ac7a18d0081cce6e1ec765df': (527 commits) refactor(infra): simplify audit recovery write progress (#157141) fix: show restart blockers in service logs (#207879) test(infra): exercise group identity in session roundtrip (#207671) test(infra): exercise live owner expiry policy (#207672) feat: let Knowledge learn from your Gmail through Composio (#207266) test: stop the history-worker overload test from failing CI on slow runners (#207862) test(auth): assert SecretRef plaintext is absent from storage (#207698) chore(doctor): hold expired doctor migrations as removal-pending (#207865) fix: show ended one-time automations in History (#201280) chore(release): update appcast for 2026.11.11 (#207504) fix: let updates back up deeply nested databases (#207756) fix(telegram): stop resending earlier messages to the model on every turn in DM topics (#207684) feat(workboard): choose which sessions appear on a board (#207781) fix: acknowledge updates when the Gateway first becomes ready (#207819) chore: stop the cron recovery test from failing CI on slow runners (#207837) fix: queue follow-ups when session creation reuses an active chat (#207800) feat(clawrouter): consume qualified native memory embeddings (#191874) fix: save the account for main-session prompts and converted reminders (#207776) test(infra): measure worker Buffer storage directly (#207663) feat(workboard): hide sessions and filter subagents per board (#207744) ...
…line * commit 'c876514dc21154a07f3755320495d2a93584b46b': (538 commits) perf(agents): reuse prepared tool catalog executors (#207900) fix: show the Gateway command default beside host rules in Devices (#207887) fix: verify chat Stop recovery after dashboard pairing (#207888) test(activity): check midnight refresh against the elapsed window (#207859) test(ui): use one persisted message ID in queued-image handoff (#207861) test(agents): release configured MCP fixture resources (#207716) fix(workboard): clear CI failures in the session filter editor (#207858) perf(ai): reduce allocation in OpenAI Responses streams (#207889) chore: stop the Workboard resident-owner CLI test from failing on main (#207898) test(agents): isolate endpoint-based overflow classification (#207688) chore(doctor): record why the root defaultModel migration stays (#207890) refactor(infra): simplify audit recovery write progress (#157141) fix: show restart blockers in service logs (#207879) test(infra): exercise group identity in session roundtrip (#207671) test(infra): exercise live owner expiry policy (#207672) feat: let Knowledge learn from your Gmail through Composio (#207266) test: stop the history-worker overload test from failing CI on slow runners (#207862) test(auth): assert SecretRef plaintext is absent from storage (#207698) chore(doctor): hold expired doctor migrations as removal-pending (#207865) fix: show ended one-time automations in History (#201280) ...
* commit '2194d14488091e2047d2f87ebbb093212f30840e': (540 commits) fix: stop reporting a child worker as finished when the Gateway loses contact (#207713) fix: keep the Activity visibility test stable at midnight (#207847) perf(agents): reuse prepared tool catalog executors (#207900) fix: show the Gateway command default beside host rules in Devices (#207887) fix: verify chat Stop recovery after dashboard pairing (#207888) test(activity): check midnight refresh against the elapsed window (#207859) test(ui): use one persisted message ID in queued-image handoff (#207861) test(agents): release configured MCP fixture resources (#207716) fix(workboard): clear CI failures in the session filter editor (#207858) perf(ai): reduce allocation in OpenAI Responses streams (#207889) chore: stop the Workboard resident-owner CLI test from failing on main (#207898) test(agents): isolate endpoint-based overflow classification (#207688) chore(doctor): record why the root defaultModel migration stays (#207890) refactor(infra): simplify audit recovery write progress (#157141) fix: show restart blockers in service logs (#207879) test(infra): exercise group identity in session roundtrip (#207671) test(infra): exercise live owner expiry policy (#207672) feat: let Knowledge learn from your Gmail through Composio (#207266) test: stop the history-worker overload test from failing CI on slow runners (#207862) test(auth): assert SecretRef plaintext is absent from storage (#207698) ...
…207266) * feat(knowledge): add the Learn from Mail scribe * fix(knowledge): read whole Gmail threads, keep HTML quotes out and detect calendar parts * chore(knowledge): format and lint the Learn from Mail scribe * test(knowledge): type the Gmail reader slug check * feat: let Knowledge learn from your Gmail through Composio OpenClaw-Publication: c853f838-3413-89f0-a2e4-ed76001d773e * fix(knowledge): read Gmail answers the Composio CLI saves to a file Composio CLI 0.6.x saves a large tool answer to a local file and prints only storedInFile and outputFilePath. The Gmail reader now reads the whole answer from that file and then removes the file and its folder, which hold the owner's mail. Before, those threads came back with no messages. * fix(knowledge): Learn from Mail runs remove their working copies of mail Each run now works in a private mktemp folder, so its thread files and the Composio CLI's saved answers land there, and removes it with rm -rf when the run ends. Live runs had left copies of mail in /tmp and the workspace. * refactor(knowledge): move Learn from Mail page text into the scribe locale strings Rebased onto main, where scribe titles, blurbs and labels and the plugin readiness lines moved into i18n/locales/en-scribes.ts. * fix(knowledge): keep the Composio CLI's saved Gmail answers in the run folder The CLI saves large answers under COMPOSIO_RUN_OUTPUT_DIR and COMPOSIO_SESSION_DIR, which default to the system temporary folder, not the working folder. gmail-read.mjs now points both at .composio in the working folder, so removing the run folder also removes an answer an interrupted read left behind.
What Problem This Solves
Knowledge can learn from chat history, Granola meetings, Memory and Slack, but not from email. Email is where a lot of commitments, decisions and introductions actually happen. Today an owner has to repeat them to the agent by hand, or they never reach Knowledge.
User Impact
The Scribes tab gains Learn from Mail. It runs once or on a schedule (weekdays at 8 AM, 12 PM and 4 PM) and has these options:
It reads Gmail through the Composio CLI, read-only, and picks the threads worth remembering. From those it saves decisions and commitments in both directions (what the owner promised, and who is waiting on whom) and news, keeping the people and project pages current. It never sends, drafts, labels, archives or deletes mail.
Setup on the Gateway host:
@composio/composioplugin.composio loginandcomposio link gmail.The page checks that the Composio plugin is installed and turned on. It can't see the CLI's sign-in or linked accounts. Each run checks those first and stops with a
Scribe status: failedline that names what is missing (CLI not installed, signed out, or Gmail not linked).Why This Change Was Made
Josh decided to build Knowledge scribes for mail, calendar and Drive through Composio, mail first, with a decision model deciding which threads are ingested. gbrain's email-to-brain and open-loop guides inspired the extraction rules. No code was copied from them.
skills/knowledge-source-ingest/scripts/gmail-read.mjs. It allowlists three Composio tools:GMAIL_GET_PROFILE,GMAIL_LIST_THREADSandGMAIL_FETCH_MESSAGE_BY_THREAD_ID. The slugs come from Composio's Gmail toolkit page. The script runscomposiowithexecFile, never a shell, and checks thread IDs before the CLI sees them. The skill tells the agent never to runcomposioitself.gmail-normalize.mjs triageapplies a deterministic prefilter first. It leaves out mailing lists (List-Unsubscribe, List-Id or bulk Precedence headers), automated senders, calendar notices (found by the iCalendar MIME method, with the subject as a fallback), bulk Gmail categories, and spam or trash. A thread the owner wrote in is always kept. Updates mail is kept too.decision_evaluateinput (contractVersion 2): a booleaningestquestion and akindchoice, over the subject and short excerpts of the newest messages. With no decision model, or an unavailable, error or abstaining answer, the agent applies the same criteria itself.Knowledge scribe checkpoint · Learn from Mailrecords each thread's triage outcome with its history ID and a digest of its message IDs. A skipped thread is triaged again only when its messages change.gmail:<address>/<threadId>. It has complete snapshot manifests and keeps its Gmail deep link. Senders and recipients are matched to person pages byemail:<address>.Design choices that differ from the plan in the epic:
complete, notpartialas in Slack, because each run reads the whole thread.listbatch. A boolean answer would cover the whole list rather than each item, so a batch can't give one answer per thread. GPT-6 Luna, the decision model used for the live check below, also rejectsliststate as unsupported input.Evidence
Tests. Focused Vitest passed on Crabbox AWS (run
run_d375c9f0db957cc4065d3ec60b2d7f71and earlier runs) for gmail-scripts, scribe-mail-fields, scribes-state, scribes-view, scribe-slack-fields, skill-packaging and slack-read-normalize. The last full run passed 68 of 68.composiobinary. The test checks that only the three read slugs ever reach the CLI, and covers pagination of thread lists and of long threads, invalid thread IDs, and each failure class.chat-transcript.mjsandsource-manifest.mjs.Checks. Typecheck for
tsconfig.extensions.jsonand the extension tests, oxlint onextensions/knowledge, and format all pass on the final head.Inherited failures. CI Planner Benchmark's
validatejob fails its unused-file scan onscripts/e2e/lib/upgrade-survivor/system-event-account.mjs, which this branch doesn't touch and nothing on main references. Locally,check:changed's dead-export scan also flags three exports this branch doesn't touch (src/agents/command/types.ts: AgentCommandPluginIngressOpts,src/plugins/native-module-require.ts: clearNativeRepositorySourceModulesForTest,src/gateway/server-methods/update.test-harness.ts: resolveUpdateInstallSurfaceMock). The earlierdoctor-deprecationfailure came from main and is gone after rebasing onto chore(doctor): hold expired doctor migrations as removal-pending #207865.Test lines. The scribe adds 662 net test lines against the 400 allowance;
config/test-lines-allocations/knowledge-mail-scribe.txtrecords the other 262 (the reader against a stand-in Composio CLI, the normalizer and the Mail dialog fields).CI fix. CI runs
gmail-scripts.test.tsunder Bun, and the test PATH holds only the test runtime's directory, so the stand-in Composio CLI's#!/usr/bin/env nodeshebang found nonodeand every read failed as signed-out. The stand-in now runs fromcomposio.cjsbehind ashwrapper that execsprocess.execPath. Reproduced under Bun withnodeabsent from PATH: the old shebang fails as signed-out, the wrapper reads.Live decision model triage. The scribe's rubric was run unchanged through
decision_evaluateagainstclawrouter/openai/gpt-6-lunaon eight synthetic Gmail threads. Six were built as saved Gmail threads, run throughgmail-normalize.mjs triage, and evaluated with the rubric it emits. Two more checked borderline cases. Every call returnedstatus: ok. The run marks a thread for ingestion whenprobabilityTrueis at least 0.5.The split is clean: every thread to keep scored 0.84 or above, and every routine thread scored 0.25 or below. The rubric was not changed. For prefiltered threads the rubric was run on the same state shape to check it. A real run never sends those threads to the model.
The coffee scheduling thread counts as ingest because the rubric treats an open request to the owner as someone waiting on them. The receipt passes the prefilter because its sender (
receipts@) is not an automated local part, so the model is what keeps it out.Live Gmail runs. Two scheduled-run equivalents ran on the owner's Gateway (openclaw-fsn1) against a real Gmail account, through Composio CLI 0.6.4:
storedInFile: trueandoutputFilePath. The reader treated those 11 threads as having no messages.gmail-read.mjsnow reads the whole answer from that file, then removes the file and its folder. The new test case fails on the old reader and passes with the fix. A live re-read of a thread that had come back empty returned all 6 messages and left no saved file behind.Run hygiene. The live runs left their working copies of mail in
/tmpand the workspace. Each run now works in a privatemktemp -dfolder, so its thread files land there, and removes it withrm -rfwhen the run ends.gmail-read.mjspoints the CLI'sCOMPOSIO_RUN_OUTPUT_DIRandCOMPOSIO_SESSION_DIRat.composioin that folder; by default they sit in the system temporary folder whatever the working folder is. An answer an interrupted read left behind is removed with the run folder.Rebase. Rebased onto current main, which moved scribe page text into
i18n/locales/en-scribes.tsand renamed conversations to sessions and chat history. The Mail catalog text and the "plugin on" and run-checks lines now live in the locale strings. Focused Vitest (gmail-scripts, scribe-mail-fields, scribe-slack-fields, scribes-state, scribes-view and skill-packaging; 72 tests) passes on the rebased head.Review. An independent review found one P1 and three P2 issues, all fixed and covered by tests:
<blockquote>replies are now treated as quoted text.🦞 Made with OpenClaw