← Back to PRs

#6965: feat: add CONTACTS.md for persistent WhatsApp contact storage

by negativenagesh open 2026-02-02 07:29 View on GitHub →
docs agents
Fixes #6919 ## Problem When WhatsApp tool is connected, the agent can send messages to contacts when given the number. But in a new session, the agent doesn't remember previously used contacts and asks for the number again. ## Solution Add persistent CONTACTS.md file in the workspace that stores contact information: - **Created on-demand** - Only when agent first sends a WhatsApp message - **Auto-updated** - When new contact info is provided - **Injected into system prompt** - When messaging is available ## Changes Made ### New Files - `src/agents/contacts.ts` - Contact parsing utilities (loadContacts, parseContactsMarkdown, findContactByName) - `docs/reference/templates/CONTACTS.md` - Template file for the phonebook ### Modified Files - `src/agents/workspace.ts` - Add CONTACTS.md to bootstrap file loading - `src/agents/system-prompt.ts` - Add contacts guidance section instructing the agent to: - Check CONTACTS.md for saved numbers before asking user - Use WRITE tool to create file on first contact - Use EDIT tool to APPEND new contacts (preserves existing!) ## How It Works 1. **First contact**: Agent creates CONTACTS.md with template + first contact row 2. **New contacts**: Agent uses EDIT to APPEND rows (existing contacts preserved) 3. **New sessions**: CONTACTS.md is auto-loaded in bootstrap context, agent finds saved numbers ## Testing - Send message with new contact → CONTACTS.md created - Start new session → send to same contact → agent uses saved number without asking <img width="623" height="254" alt="Screenshot 2026-02-02 at 12 33 32" src="https://github.com/user-attachments/assets/8ee036de-1d90-4133-9e15-9932b137ab86" /> <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR adds a persistent contact phonebook mechanism for messaging by introducing a `CONTACTS.md` template (under `docs/reference/templates/`) and wiring workspace bootstrap loading to include `CONTACTS.md` when present. It also adds `src/agents/contacts.ts` with basic parsing and lookup helpers, and extends the system prompt to instruct the agent to consult and maintain CONTACTS.md when the `message` tool is available. Overall the approach fits the existing workspace-template/bootstrap model (AGENTS.md, TOOLS.md, etc.), but there are a couple correctness edge cases in the parser/matcher that can drop valid rows or lead to surprising matches, and one silent failure path when CONTACTS.md can’t be accessed. <h3>Confidence Score: 4/5</h3> - This PR looks safe to merge with minor correctness/UX tweaks. - Changes are localized (new parser + prompt text + workspace bootstrap inclusion) and don’t alter core execution paths beyond adding an optional context file. The main concerns are edge cases in contact parsing/matching and silent skipping of CONTACTS.md on unexpected access errors, which could cause confusing behavior but not systemic breakage. - src/agents/contacts.ts (parsing/matching behavior), src/agents/workspace.ts (error handling around CONTACTS.md access) <!-- greptile_other_comments_section --> <sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub> <!-- /greptile_comment -->

Most Similar PRs