Delivered remotely for a business based in Austin, United States. Names withheld by agreement.
Project Overview
Professionals coordinating across calendar suites, email threads, issue trackers, and chat channels spend substantial mental energy assembling context before taking simple actions. Early AI chat tools promised relief through natural-language prompts, yet raw chat interfaces break down when asked to inspect live schedules, draft contextual replies, or coordinate multi-step follow-ups across real accounts. Worse, granting an autonomous model unrestricted write access to corporate inboxes creates unacceptable operational risk.
Working remotely with a product group based in Austin, United States, we engineered an AI personal assistant platform powered by Python, FastAPI, React, and external LLM APIs. Rather than building an opaque autonomous bot, the architecture centers on a deterministic tool-execution gateway: the assistant gathers cross-app context, reasons over priorities, and stages structured action proposals that users inspect and approve inside a fast React workspace.
Operational Fragmentation
Building a practical executive assistant required resolving four recurring failure modes common in early agent prototypes:
- Unchecked tool side effects: Language models occasionally misinterpret ambiguous pronoun references or time zones, making unguarded writes to calendars or email recipients dangerous.
- Blocking synchronization loops: Polling external mail and calendar APIs synchronously inside a chat request freezes user interfaces whenever third-party endpoints throttle or lag.
- Context bloat across long days: Stuffing raw email bodies and full meeting histories into every prompt rapidly degrades reasoning quality and inflates inference cost.
- Fragile token management: Multi-connector assistants must handle expiring OAuth grants, partial scope revocations, and per-provider rate caps gracefully without silently dropping scheduled tasks.
Architectural Strategy
We structured the platform around a two-tier execution boundary enforced in Python and FastAPI. Read-only operations—searching upcoming calendar slots, fetching recent thread summaries, or checking open tasks—run dynamically during reasoning turns under strict per-user OAuth scopes. Any action that alters external state—sending a message, declining an invite, or updating a ticket—must emit a typed action proposal validated by Pydantic schemas and parked in a pending confirmation state.
In the browser, React renders these pending tool invocations as inline, editable cards rather than burying intent inside prose. Users can adjust a subject line, swap an attendee, or cancel an action with one click before FastAPI commits the downstream API call.
Core Capabilities
- Unified Daily Briefings: Scheduled Celery jobs synthesize overnight inbox priority items, calendar conflicts, and overdue commitments into a scannable morning digest.
- Interactive Action Staging: Drafted emails, meeting invitations, and task updates appear as structured React preview cards with diffed fields and explicit one-click confirmation.
- Scoped Semantic Recall: PostgreSQL paired with pgvector indexes distilled meeting notes, recurring scheduling preferences, and contact context for fast hybrid retrieval.
- Connector Policy Controls: Organization administrators define permitted integrations, data retention ceilings, and mandatory human-review rules per role.
- Keyboard-First Command Workspace: Operators trigger quick actions, inspect tool execution logs, and jump between active workstreams without leaving the primary React canvas.
Technical Architecture
Every interactive turn enters FastAPI over an authenticated session, streams reasoning tokens via Server-Sent Events (SSE), and delegates heavy background synchronization to Celery queues backed by Redis.
Flow: React Workspace → FastAPI SSE Gateway (Auth & Policy Middleware) → Python Context Assembler (PostgreSQL / pgvector + Redis Window) → LLM API Router (Typed Tool Schemas) → Action Ledger (Auto-Run Reads / User-Approved Writes) → Celery Connector Workers
Splitting interactive inference from background connector ingestion kept response times predictable. Webhooks from connected mail and calendar providers land on dedicated ingestion endpoints, enqueue normalization jobs in Celery, and update structured summaries in PostgreSQL before the user ever opens a new prompt. When a user asks for availability or thread history, FastAPI queries pre-normalized local records first and falls back to live connector fetches only when cache freshness windows expire.
Technology Stack
| Category | Technology detail |
|---|---|
| API & Streaming Layer | Python with FastAPI async endpoints and Server-Sent Events (SSE) |
| Frontend Workspace | React with TypeScript, optimistic action cards, and keyboard-first command palette |
| Reasoning & Tool Calling | External LLM APIs via typed function schemas and provider fallback routing |
| Primary & Vector Storage | PostgreSQL with pgvector for user preferences, audit logs, and memory embeddings |
| Session & Throttle State | Redis for short-term turn buffers, distributed locks, and rate limiting |
| Background Orchestration | Celery workers for scheduled morning digests and webhook-driven inbox sync |
| Credential Vault | Envelope-encrypted OAuth2 token store with per-connector scope isolation |
| Observability | OpenTelemetry traces capturing prompt latency, tool failures, and token spend |
Engineering Trade-offs & Solutions
| Engineering Challenge | Solution & Trade-off |
|---|---|
| Balancing automation speed against risky external writes | Split tools into autonomous read queries and confirmation-gated write proposals; adds one extra user click on outbound actions while eliminating silent mis-sends. |
| Handling large raw email threads within model context limits | Pre-summarized incoming messages into concise structured digests via Celery upon ingestion, trading verbatim long-tail archiving in prompts for consistent latency and lower token overhead. |
| Supporting multiple LLM providers without rewriting agent loops | Built a unified Python adapter normalizing tool-call JSON schemas and streaming chunks, introducing modest abstraction code in exchange for clean failover during upstream outages. |
| Preventing concurrent Celery sync jobs from duplicating digest items | Coordinated per-user sync mutexes and idempotency keys in Redis, adding minor lock management overhead while keeping morning briefings clean and duplicate-free. |
Security & Authorization Boundaries
An assistant holding email and calendar integrations becomes a high-value target if permissions are loosely scoped. Every FastAPI route enforces strict tenant and user ownership checks, ensuring semantic vector queries in pgvector filter by user identity before similarity scoring runs.
External OAuth refresh tokens are stored using envelope encryption with isolated key references, never exposed to browser clients or injected into LLM system prompts. Furthermore, inbound email content fed into summarization pipelines is tagged explicitly as untrusted data inside structured message boundaries, accompanied by server-side schema validation so malicious text inside an incoming message cannot hijack outbound tool parameters.
Performance & Scale
FastAPI's non-blocking event loop sustains concurrent SSE streams cleanly without tying up worker threads while waiting on upstream LLM inference. Redis buffers active conversation turns and enforces per-user token-bucket throttling so runaway loops or burst retries cannot exhaust shared API quotas.
On the frontend, React code-splits connector configuration panels and audit viewers away from the main assistant canvas, keeping initial workspace loads crisp. Database indices on (user_id, created_at) and partial indices on pending action proposals keep ledger queries consistently fast as historical logs grow.
Operational Outcomes
Moving from an unguarded prompt wrapper to a schema-enforced assistant architecture delivered dependable daily utility:
- Predictable delegation: Operators rely on the assistant to prepare schedules and correspondence because every state-changing operation surfaces a clear, editable preview prior to execution.
- Resilient multi-provider operation: Typed validation and Redis circuit breakers absorb upstream LLM hiccups without corrupting active threads or dropping pending drafts.
- Transparent auditability: Security teams and users alike can trace every tool call, retrieved memory record, and approved outbound action in an immutable PostgreSQL ledger.
- Clean extensibility: Adding new workplace connectors requires implementing a single typed Python adapter and OAuth scope definition without altering the core React workspace.