KatInterview

Designing an LLM-Driven Test Automation Platform for Pull Requests

System DesignModel answer
MediumModel answerSystem Designllm-agentstest-automationsandboxing

Last updated

Design a multi-agent system that turns specs and diffs into reviewed tests, runs them in isolation, repairs broken scripts, and separates script faults from real product regressions.

Scenario

A large engineering organization merges thousands of changes every day, and writing and maintaining tests by hand has become the bottleneck. You are asked to design an LLM-agent-driven test automation platform. It consumes product requirement documents, code diffs, OpenAPI specs and design links, and coordinates several specialized agents to produce:

  • reviewed, structured test cases,
  • synthetic test data,
  • runnable test scripts (browser end-to-end and API integration),
  • execution results and a report, with draft bug tickets for real failures.

Functional requirements

  • Traceability. Every artifact links in both directions: requirement, test case, script, execution run.
  • Data and script generation. Fixtures must be realistic but contain no real personal data. Scripts target a browser-automation framework for UI flows and a Python test framework for APIs.
  • Isolated execution with repair. Run generated scripts in a sandbox. When a script fails for script-level reasons (syntax, broken selector), retry with automatic fixes up to a fixed limit, without hiding genuine product defects.
  • Human review gates. Risky or destructive tests and data require human approval before they run.
  • Reporting. Produce a structured report with evidence (logs, network traces, screenshots) and draft de-duplicated defect tickets.

Non-functional requirements

  • Determinism. Agent-to-agent handoffs must be schema-validated to limit hallucinated content.
  • Security. Untrusted, model-written code must not reach production systems, leak data, or break out of its runtime.
  • Latency. Typical changes complete the pipeline in under 15 minutes.

Load assumptions

  • 2,500 changes or specs per day.
  • About 20 generated test cases per spec.
  • Up to 50,000 test executions per day across a distributed runner fleet.

What to cover

  1. The agent roles and the state machine or graph that orchestrates them.
  2. Typed contracts for the artifacts passed between agents.
  3. The sandbox used to run untrusted code.
  4. How the system decides whether a failure is a bad script or a real regression.

Include capacity estimates and a latency budget, and discuss trade-offs.

Hints

Hint 1

Start with arithmetic: executions per day, retry multiplier, peak rate and test duration give you the number of concurrent sandboxes. Then split the 15-minute budget across stages.

Hint 2

Treat the model as an untrusted component: validate every handoff against a schema, use deterministic non-LLM checks wherever possible, and run the workflow on a durable engine with idempotent steps.

Hint 3

For repair versus regression, ask what the repair agent is allowed to change. If it can alter expected results, it can silently erase real bugs, so lock the assertions and compare against a baseline build.