Email Loop Extraction Engine (google/loops-extract.ts)

gbrain · src/core/google/loops-extract.ts · typescript · MIT
ai, email, tag:knn-classified, tag:extraction, tag:commitments, tag:open-loops

Uses an LLM to parse Google email thread pages, extracting commitments and pending decisions, and writes them to open_loops, facts, and relationship edges for downstream recall and UI.

// Source: https://github.com/garrytan/gbrain | License: MIT | Copyright 2026 Garry Tan
// Provided via justclaw.it.com; keep this notice with the code.
/**
 * loops-extract — the LLM half of the open-loop engine.
 *
 * One model call per email thread page extracts commitments ("I'll send the
 * deck by Friday" — direction, counterparty, due date, verbatim quote) and
 * pending decisions. ONE extractor, not two (outside-voice F5): the results
 * project into BOTH substrates in the same pass —
 *   - an open_loops row (dedup 'commit:<sha8(canonical)>', detector llm_extract)
 *   - a facts row via writeSingleFact (kind=commitment, fence-first, deduped)
 *     whose id lands on open_loops.fact_id, so entity cards / recall see the
 *     commitment through the existing read paths with zero new

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key