Skip to content

[recipes] Google Activity import: include Gemini answers from safeHtmlItem#455

Open
araece wants to merge 1 commit into
NateBJones-Projects:mainfrom
araece:fix/gemini-answers-safehtmlitem
Open

[recipes] Google Activity import: include Gemini answers from safeHtmlItem#455
araece wants to merge 1 commit into
NateBJones-Projects:mainfrom
araece:fix/gemini-answers-safehtmlitem

Conversation

@araece

@araece araece commented Jul 16, 2026

Copy link
Copy Markdown

[recipes] Google Activity import: include Gemini's answers from safeHtmlItem

What

The Google Activity importer currently reads only title and time from Takeout's
MyActivity.json records — which for Gemini Apps means it imports what the user asked,
but never what Gemini answered
.

It turns out the answers ARE in the export: most Gemini prompt records carry the response
as HTML in a top-level safeHtmlItem field:

{
  "title": "Prompted How does polarization work in sunglasses?",
  "time": "2026-03-02T09:15:00.000Z",
  "safeHtmlItem": [{ "html": "<p>Polarized lenses contain a <strong>filter</strong> ..." }]
}

Verified against a real export (July 2026): 1,161 of 1,640 Gemini records included it
(median ~420 chars, p90 ~3.7k, max ~86k). The widespread "Takeout exports prompts only"
belief appears to be outdated.

Changes

  • extractGeminiAnswer() + dependency-free htmlToText() — strips the safeHtmlItem
    HTML to plain text (tags removed, entities decoded, <li>- bullets), capped at
    1,000 chars per answer.
  • groupByDay() appends Gemini's answer: … beneath the prompt title. Records without
    safeHtmlItem — all other categories, and the ~30% of Gemini records lacking it — behave
    exactly as before (the helper is a no-op for them).
  • Summarization prompt: one added paragraph telling the model to use answers to capture
    what was learned/decided, but to attribute facts that appear only in an answer as
    AI-generated ("Gemini answered/suggested …") rather than established truth.
  • Transcript cap raised 6k → 12k chars for Gemini Apps only, so answers survive the
    truncation (~3.4k tokens ≈ $0.0005/day at gpt-4o-mini rates). Other categories keep 6k.
  • README: documents the discovery.

Why it matters

Day summaries built from prompts alone can only say what the user was asking about.
With the answers included, they can capture what the user actually found out — which is
the part worth remembering in a personal knowledge base.

Requirements

Unchanged from the existing recipe: a working Open Brain setup, an OpenRouter API key,
Node.js 18+. No new services, dependencies, or secrets (metadata.json bumped to 1.1.0,
gemini tag and description updated).

Testing

Tested against my own Open Brain instance:

  • node --check passes.
  • Dry-run (--dry-run --raw --verbose --categories "Gemini Apps") against synthetic
    records: answer extracted and appended, HTML/entities cleaned, answerless record
    untouched, other categories unaffected.
  • The same parsing approach is running in production on my instance against a real
    1,640-record export.

Not in scope (possible follow-up)

Localized exports use different filenames/prefixes (German: MeineAktivitäten.json,
titles starting Eingegebener Prompt: ), which findMyActivityFiles()/the filters don't
match — non-English Takeout exports are currently invisible to this recipe. Happy to send
that separately if there's interest.

🤖 Generated with Claude Code

@github-actions github-actions Bot added the recipe Contribution: step-by-step recipe label Jul 16, 2026
@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown

OB1 PR Gate

Folder structure — All files are in allowed directories
Required files — README.md and metadata.json found in all contribution folders
Metadata valid — All metadata.json files passed JSON Schema validation
No credentials — No API keys, tokens, or secrets detected
SQL safety — No destructive SQL or core table modifications
Category artifacts — Required file types present for each category
PR format — Title follows [category] Description format
No binary blobs — No oversized or binary files
README completeness — All READMEs include Prerequisites, Steps, and Expected Outcome
Contribution dependencies — All declared skill and primitive dependencies exist and are linked in README
LLM clarity review — Covered by Claude PR Review workflow
Remote MCP pattern — No local MCP server patterns detected — uses remote MCP correctly
Tool audit link — Extensions/integrations link to the MCP Tool Audit guide
Scope check — All changes are within the contribution folder(s)
Internal links — All relative links in READMEs resolve to existing files

Result: All 15 checks passed! Ready for human review.


Post-Merge Tasks

These don't block merge — they're reminders for admins after this PR lands.

@araece
araece force-pushed the fix/gemini-answers-safehtmlitem branch from 6c5b5d6 to 4a70aea Compare July 16, 2026 12:26
@araece araece changed the title google-activity-import: include Gemini answers from safeHtmlItem [recipes] Google Activity import: include Gemini answers from safeHtmlItem Jul 16, 2026
Gemini Apps Takeout records are widely believed to contain only the
user prompts, and the importer read only `title`/`time` accordingly.
That is no longer true: most prompt records carry Gemini's answer as
HTML in a top-level `safeHtmlItem` field ([{"html": "<p>..."}]) -
verified against a real July 2026 export, where 1,161 of 1,640 records
included it (median ~420 chars, p90 ~3.7k).

Changes:
- extractGeminiAnswer() + dependency-free htmlToText(): strip the
  safeHtmlItem HTML to plain text (tags removed, entities decoded,
  list items kept), capped at 1,000 chars per answer
- groupByDay() appends "Gemini's answer: ..." beneath the prompt
  title; records without safeHtmlItem (all other categories, and the
  ~30% of Gemini records lacking it) behave exactly as before
- summarization prompt: instructs the model to use answers for what
  was learned/decided, but to attribute answer-only facts as
  AI-generated rather than established truth
- transcript cap raised 6k -> 12k chars for Gemini Apps only (answers
  need the room; ~$0.0005/day at gpt-4o-mini rates), other categories
  unchanged
- README: document the safeHtmlItem discovery

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@araece
araece force-pushed the fix/gemini-answers-safehtmlitem branch from 4a70aea to b9a1b11 Compare July 16, 2026 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

recipe Contribution: step-by-step recipe

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant