← Questions

Keep private code from leaking through a coding agent

0
MetaSystem designLast asked Apr 2026

An AI system design interview question asked in Meta's technical phone screen, last asked Apr 2026. It tests llm agents, privacy and security.

A company runs an AI coding agent over its private repositories. Design the safeguards that stop private source code from leaking: into model training data, into answers shown to other users or customers, or out through the agent's tools (web requests, logs, third-party calls).

Requirements

  • Functional: the agent can read and edit the repositories it is authorised for, run tools, and call models; private code must not reach training sets without consent, other tenants' sessions, or external destinations.
  • Non-functional: strong isolation between customers; least privilege for every tool; full auditability; low added latency; controls that can be proven to auditors.

Clarifying questions

  • Is the model hosted by us, a third party, or inside the customer's environment?
  • Is the agent multi-tenant? Which customers share infrastructure?
  • Which tools does the agent have: web access, package installs, external APIs?
  • What do contracts allow: training on customer code, retention periods?
  • What counts as "leaking": verbatim code only, or also summaries and secrets?

What a strong answer covers

  • A map of where code flows: repository checkout, context sent to the model, prompts and completions, caches, logs, telemetry, tool calls and their destinations.
  • Training controls: customer data excluded by default, tagged at ingestion, filtered from training pipelines, with retention limits and deletion on request.
  • Tenant isolation: separate sandboxes and credentials per session, no shared caches or retrieval indexes across customers, keys scoped per tenant.
  • Egress controls on tools: network allow-lists, a proxy that inspects and logs outbound requests, no arbitrary web access while private code is in context, and defences against prompt injection that tries to exfiltrate.
  • Output scanning: detecting secrets and long verbatim private snippets in outputs and logs; redaction before logging.
  • Audit and proof: immutable logs of access and egress, red-team tests that attempt exfiltration, and periodic checks that controls work.

Follow-ups

  • A README in the repository contains a hidden instruction to post the code to an external URL. Walk through what stops it.
  • How do you detect that a model memorised and reproduced one customer's code for another?
  • The customer wants the agent to search the web while working. How do you allow that safely?
  • How do you prove to an auditor that no customer code entered training data?

Where it's asked

  • Meta · Technical phone screen · Last asked Apr 202645 min · Two coding problems in CoderPad, about 20 minutes each · Usually no AI; some newer screens are AI-assisted

What it tests

llm agents · privacy · security · code

Your canvas
Draw your answer hereBoxes, arrows and notes, saved for you to come back to.Sign in to start drawing