One calendar, two names: fixing duplicate memories in Cognee's Google Calendar connector
AI agents are only as good as what they remember. Cognee is an open-source memory layer for agents: you hand it documents, chats or data, and it builds a knowledge graph the agent can query later. For Mergetober (WeMakeDevs × Cognee) I spent my contribution on the Google Calendar connector, which turns your calendar into agent memory, so you can ask things like "what did I agree to in last week's…
One of the most important aspects of artificial intelligence is the information it retains. Cognee provides an open-source memory layer for AI agents, allowing them to store and query data. For the WeMakeDevs × Cognee event, the contributor spent time developing a Google Calendar connector that turns calendar information into agent memory. This enables users to ask questions like what I agreed to in last week’s design review? or when is my next 1:1 with Priya?.
The connector operates as a direct link to Cognee. The user provides the necessary information, and Cognee processes it. Each event is transformed into a brief text document, which is then broken down and converted into entities and relationships. Later syncs use Google's sync tokens, ensuring only updated events are re-read, and deleted events are disregarded.
However, a bug surfaced - with Google Calendar, the main calendar has two names: the alias 'primary', and its actual email address. The connector's helper script examples/login.py lists calendars using their real IDs, causing a natural setup issue. When these two IDs are treated as separate calendars, each event gets stored twice, leading to double the LLM calls and duplicate facts in the graph. This type of bug is quiet and may not crash the system, but it can make the agent noisier and more expensive.
To fix the issue, the code was modified to list calendars once and find the primary calendar's real ID. The primary name and this ID are treated as the same key, keeping only the first spelling configured. The existing fix keeps the first spelling, while the second one is removed from the config, allowing the connector's existing forget path to clean up any duplicates on the next run.
The fix was tested using the connector's tests, which run on an in-memory fake of the Calendar API without needing a Google account. Three tests were added: both spellings sync as one calendar, keeping the first spelling, and eliminating any leftover duplicates from older syncs. The entire test suite was then run, along with ruff on Python 3.11 and 3.13, all through GitHub Actions on the contributor's fork.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.
This story
This is one outlet's version. Read the fullest account.
- Google determines the names for bodies of water in Google Earth (2008) publicpolicy.googleblog.com