SupportPilot

Architecture

How SupportPilot turns an inbound ticket into a grounded, cited, human-approved reply.

  1. 1. Ticket intake→
  2. 2. Validation→
  3. 3. Classification→
  4. 4. Knowledge retrieval→
  5. 5. Evidence ranking→
  6. 6. Response generation→
  7. 7. Citation verification→
  8. 8. Confidence gate→
  9. 9. Human approval→
  10. 10. Simulated delivery→
  11. 11. Audit log

API layer

REST and server functions expose tickets, drafts, knowledge, analytics, health, and demo reset. Errors use a stable envelope with code, message, and request_id. Pagination is limit/offset on list endpoints in the production FastAPI service.

Background workers

Celery + Redis run extraction, chunking, embedding, reindex, draft generation, and retryable simulated delivery. The live preview runs the same stages in-process with explicit job states so a failed ingest keeps its reason.

PostgreSQL + pgvector

Tickets, documents, drafts, and audit events live in Postgres. Production stores chunk embeddings in pgvector; this preview uses a deterministic hash embedding stored as JSON so it runs without extensions.

Redis

Queue broker, rate-limit counters, and short-lived job state. Preview rate limits are an in-memory sliding window with the same error code.

Document storage

An object-storage abstraction accepts PDF, DOCX, TXT, Markdown, and HTML. Filename sanitization, MIME checks, and an 8 MB cap happen before extraction. Binary PDF/DOCX extractors are interfaces; the demo indexes text formats and records failed encrypted PDFs.

Model-provider abstraction

EmbeddingProvider and GenerationProvider sit behind sandbox implementations (hash embeddings + extractive drafting). Hosted adapters exist as types only and throw if constructed without credentials. Preview never calls a paid model.

Observability

Structured JSON logs, request IDs, audit events, document processing events, and safety events for prompt injection. Secrets and obvious credential patterns are redacted before log write.

Security controls

Untrusted customer text and indexed documents. Prompt-injection detection, HTML escaping, workspace isolation, role checks in the FastAPI artifact, citation validation, confidence thresholds, and a human approval gate before any send. Send is simulated in this workspace.

Confidence gate

  • Below 0.55: escalate; do not treat the draft as sendable without a specialist.
  • 0.55–0.86: operator edit expected.
  • 0.86 and above: still requires human approve + simulated send.
  • Insufficient evidence: refuse to invent policy, recommend escalation, keep the draft blocked.