Skip to content

feat(assistant): read connected mail, calendars and files from chat - #533

Merged
adeelahmad merged 6 commits into
mainfrom
claude/project-thread-sg6j7c
Oct 18, 2026
Merged

adeelahmad merged 6 commits into
mainfrom
claude/project-thread-sg6j7c

Conversation

@adeelahmad

Copy link
Copy Markdown
Owner

Requested by Adeel · project thread

Description

Before: the sources an admin connected under Settings › Sources (Gmail and IMAP mailboxes, Google Calendar, S3, Drive and the other rclone storage) only fed imports. Asking the assistant "what did Mara send about the harbour?" or "what's on my calendar Friday?" went nowhere.

After: an admin's assistant has a "Mail, calendars and files" tool group with connections, search_mail, read_mail, calendar_events, list_files, find_files, read_file and import_from_connection. Only the tools for what is connected are offered (no calendar connected, no calendar_events), and non-admins see "for admins" in the tool catalog. Gmail is searched with its own query language, IMAP by words over the newest subjects and senders (the result says so); Google Calendar gives the events of a window; files are found by name through rclone and read when they are text, PDFs or Word files. Answers cite a message or an event with a link that opens it, in the web app too. import_from_connection goes through approvals like every other change.

What each tool returns is wrapped as untrusted text, so a mail or a file that tries to steer the assistant marks the conversation wary and outbound tools wait, as web pages do today.

Motivation and Context

Part of "Chat tools for Gmail, Calendar, Drive, S3 and Bash" (project thread above). This is the read half; sending mail, adding events and writing files after a yes, and the Bash tool's node seam for remote sandboxes, follow in their own PRs.

Refine later (also in docs/assistant.md): server-side IMAP search, Drive full-text search, iCal feeds by time window, sharing a connection with non-admins.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change; ! in the title)

Checklist:

  • The title is a Conventional Commit.
  • My code follows the code style of this project (make hooks checks it on commit).
  • I added or updated tests.
  • My change requires documentation updates, and I have updated docs/ accordingly.
  • Users need more than the title to understand it, so I wrote it under ## Unreleased in CHANGELOG.md.

Done questions (AGENTS.md)

  • Goal: the read half of the ask; merged on green CI. Writes and the Bash node seam follow in their own PRs.
  • Agents: the tools are assistant tools, so the chat API, the OpenAI-compatible endpoint and MCP chat reach them.
  • Zero setup: nothing new to install or set; they appear once a source is connected.
  • Fewest clicks: no clicks, the assistant picks the only connection when there is one and asks only when there are several.
  • Configurable: no new setting; the group can be switched off like any other under Settings › AI assistant › Disabled tools.
  • Light: no new dependency or process; reads are bounded (50 mails, 100 events, 200 files, 20 MB per file, 8k chars).
  • Private and secure: reads the person's own connected sources from their server; results wrapped as untrusted; admins only; threat model updated (new entry point "the assistant's connection tools").
  • Cost: no model calls of its own; each read is one API or rclone call, logged in the activity ledger (gmail.search, gmail.read, google.calendar, connections.*).
  • User decides: reads run at once, import_from_connection waits for the yes; no default changed.
  • Upgrades: n/a, no stored data changes.
  • Honest: mail and events are cited with links; docs label it built and list what's refined later.
  • Tests: 7 backend tests in test_connection_tools.py, a frontend citation test; docs, README, requirements and the OpenAPI client regenerated with make openapi.
  • Open standards: IMAP, Gmail and Calendar REST APIs, rclone; no new dependency.
  • Reported in the project thread with this PR; "refine later" items in docs/assistant.md.
  • Reuse: gmail.py, gcal.py, feeds.py, sources.py (browse, stream, import_files), convert.parse_email, DOC_READERS, untrusted.wrap, the approvals flow and the web citation path.

Generated by Claude Code

An admin's assistant gets tools for the sources they connected under
Settings › Sources: connections, search_mail, read_mail, calendar_events,
list_files, find_files, read_file and import_from_connection. Only the
tools for what is connected are offered. Reads run at once; bringing
things into Lens waits for the person's yes through approvals. Messages
and events are cited with a link that opens them, in the web app too.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GbBS222wEEQgkuui6CHo6c
@adeelahmad adeelahmad self-assigned this Oct 17, 2026
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GbBS222wEEQgkuui6CHo6c
…-sg6j7c

# Conflicts:
#	CHANGELOG.md
#	fastapi_backend/app/domain/ai_tools.py
…-sg6j7c

# Conflicts:
#	CHANGELOG.md
#	docs/assistant.md
#	fastapi_backend/app/api/v1/routes/chats.py
#	fastapi_backend/app/domain/ai_tools.py
#	fastapi_backend/app/schemas/chats.py
#	nextjs-frontend/app/openapi-client/types.gen.ts
#	nextjs-frontend/components/chat/cite.ts
#	nextjs-frontend/components/recording/chat-tab.tsx
#	nextjs-frontend/openapi.json
@adeelahmad
adeelahmad merged commit 05c18ca into main Oct 18, 2026
12 checks passed
@adeelahmad
adeelahmad deleted the claude/project-thread-sg6j7c branch October 18, 2026 06:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants