Building Custom Cloud Agent Infrastructure for Legal AI at Scale
harvey · Legal · 2026 · source Agentic: yes · promotional bias: high · summary-only (no fetched source) · extracted with prompt 0.5.5 (schema v2)
Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.
Problem
Domain: Legal AI cloud-agent infrastructure
Harvey needed to run large-scale legal agents over privileged client data while satisfying law-firm requirements that managed frontier-lab or cloud-provider runtimes could not meet: multi-model flexibility, true zero data retention, conflict-aware governance, and cost optimization for workflows spanning huge document sets.
Constraints:
- Legal matters can involve privileged and confidential data that cannot persist on third-party servers.
- Law-firm clients may object to specific model providers because of commercial or competitive conflicts.
- Long-running agents are stateful and accumulate working memory, intermediate files, tool results, and checkpoints.
- A single legal agent run can involve hundreds of model and tool calls over a large corpus.
- The runtime must support routing across frontier labs, cloud-provider runtimes, and open-source or self-hosted models.
Architecture
Harvey built its own cloud-agent runtime instead of relying solely on managed agent platforms. The application layer sends legal work to a provider-normalizing abstraction layer that hides differences in tool-call formats, stop conditions, streaming behavior, failure modes, and sandboxes. A model router uses conflict policy, LAB benchmark results, cost, quality thresholds, and workload characteristics to pick a model or runtime. Agent execution runs inside Harvey's security boundary with session-scoped working memory, intermediate files, tool results, checkpoints, and sandbox compute that are purged after the workflow. The runtime also supports legal-specific governance such as data residency, sovereign deployments, inspectable action records, and conflict-aware model allowlists.
Diagram confidence: reconstructed (reconstructed from prose).
flowchart LR legal-workflow-request[Legal workflow request] --> conflict-aware-governance[Conflict-aware governance] conflict-aware-governance --> model-router[Model router] conflict-aware-governance --> data-residency-controls[Data residency controls] model-router --> lab-benchmark[LAB benchmark] model-router --> provider-abstraction-layer[Provider abstraction layer] model-router --> cost-optimizer[Cost optimizer] provider-abstraction-layer --> frontier-lab-runtimes[Frontier lab runtimes] provider-abstraction-layer --> cloud-provider-runtimes[Cloud provider runtimes] provider-abstraction-layer --> self-hosted-open-models[Self-hosted open models] provider-abstraction-layer --> legal-agent-orchestrator[Legal agent orchestrator] legal-agent-orchestrator --> session-scoped-state[Session-scoped state] legal-agent-orchestrator --> ephemeral-sandbox[Ephemeral sandbox] legal-agent-orchestrator --> inspectable-action-record[Inspectable action record] session-scoped-state --> zero-retention-purge[Zero-retention purge] ephemeral-sandbox --> zero-retention-purge
Components
| Component | Role | Interacts with |
|---|---|---|
Legal workflow request |
Matter-level request such as data-room review or issue-list generation. | Conflict-aware governance |
Conflict-aware governance |
Policy layer encoding which models a client or matter is allowed to use. | Model router, Data residency controls |
Model router |
Routing layer that chooses the most efficient allowed model meeting the quality threshold. | LAB benchmark, Provider abstraction layer, Cost optimizer |
LAB benchmark |
Legal AI benchmark used to evaluate model performance by practice area and task type. | — |
Cost optimizer |
Optimization logic for routing away from unnecessary frontier-model usage and tuning sandbox execution. | — |
Provider abstraction layer |
Interface that normalizes provider harnesses, tool formats, stop conditions, streaming, failures, and sandboxes. | Frontier lab runtimes, Cloud provider runtimes, Self-hosted open models, Legal agent orchestrator |
Frontier lab runtimes |
Managed runtimes from model labs that can offer newest models but may create lock-in or lack ZDR. | — |
Cloud provider runtimes |
Model-flexible managed runtimes that may lag newest models or have reliability limits. | — |
Self-hosted open models |
Open-source or hosted-by-Harvey models used when they meet quality thresholds at lower cost. | — |
Legal agent orchestrator |
Runtime that manages model/tool calls, file loading, parallelization, compute sizing, and state for legal workflows. | Session-scoped state, Ephemeral sandbox, Inspectable action record |
Session-scoped state |
Working memory, intermediate files, tool results, and checkpoints that are kept only for the session. | Zero-retention purge |
Ephemeral sandbox |
Execution environment optimized for loading files, parallelizing work, and sizing compute for legal workloads. | Zero-retention purge |
Zero-retention purge |
Lifecycle control that removes session state after execution to preserve ZDR guarantees. | — |
Data residency controls |
Jurisdictional and sovereign-deployment controls for where legal matters may run. | — |
Inspectable action record |
Complete record of agent actions for work-product and privilege review. | — |
Data flow
A legal workflow such as data-room review enters Harvey's cloud-agent platform with matter-specific constraints. Governance policy determines which model providers are allowed for that client or matter, then the routing layer compares model quality and cost using LAB benchmark data. The selected provider or self-hosted model is invoked through the abstraction layer, while the legal agent orchestrator manages hundreds of model and tool calls, loads files, parallelizes work, sizes compute, and maintains temporary session state. During execution, working memory, intermediate files, tool results, and checkpoints remain inside Harvey's boundary and are purged when the session ends. Audit and inspectability requirements preserve an action record without relying on third-party retained state.
4 supporting quotes
Why this architecture
Harvey chose runtime ownership because the legal market turns ordinary agent-platform tradeoffs into hard requirements. Managed lab runtimes create model and orchestration lock-in, and managed state persistence conflicts with zero data retention. Cloud runtimes improve model flexibility but can lag newest models or expose uptime/redundancy limits. Owning the runtime lets Harvey keep state inside its boundary, purge it after sessions, normalize providers, route by matter-specific governance, use smaller or open-source models when tasks are intelligence-saturated, and optimize sandboxes around legal workloads.
4 supporting quotes
Models used: Anthropic Claude Managed Agents · OpenAI offerings · AWS runtimes · Microsoft Foundry · Google runtimes · Open-source models · GPT-5.4 grader
Scale
- Harvey evolved from a chat-based product to a full cloud-agent platform.“Harvey is a legal AI company that has evolved from a chat-based product to a full cloud agent platform capable of completing complex legal tasks end-to-end”summary, stated
- Legal data-room review can span hundreds of thousands of documents.“reviewing entire data rooms and producing issues lists across hundreds of thousands of documents.”summary, stated
- Large legal workflows may cover hundreds of thousands or millions of files.“a firm's full document set (hundreds of thousands or millions of files)”summary, stated
- A single agent run can involve hundreds of model and tool calls.“A single agent run can involve hundreds of model and tool calls over a large corpus”summary, stated
- Harvey reports 3-5x cost reductions compared with a frontier-only approach.“empirically seeing 3-5x cost reductions versus a frontier-only approach”summary, stated
- The LAB benchmark is graded by GPT-5.4 according to the summary.“rubrics graded by GPT-5.4”summary, stated
Alternatives considered (roads not taken)
Use frontier-lab managed agent runtimes.
Rejected because: They tie customers to one lab's models, create maximum lock-in, and do not offer the zero-retention architecture Harvey needs.
Use only cloud-provider managed runtimes.
Rejected because: Cloud runtimes are more model-flexible but may lag newest models and have redundancy or uptime limits.
Store state during execution and delete it afterward.
Rejected because: Retention followed by deletion is not zero data retention; true ZDR requires never writing customer data to persistent storage.
Route all legal work to the strongest frontier model.
Rejected because: Many tasks are intelligence-saturated, so using the largest model overspends without improving quality enough to justify cost.
Patterns
model-routing (operations)
Harvey routes each legal task to an allowed model that meets a quality threshold, using multi-model support to avoid conflicts, lock-in, and overuse of frontier models.
cost-aware-routing (operations)
The runtime routes intelligence-saturated legal tasks to smaller, open-source, or self-hosted models where they meet quality thresholds, reducing cost versus frontier-only execution.
safety-policy-enforcement (safety)
The runtime enforces legal security constraints by keeping data inside Harvey's boundary, scoping state to the session, purging it afterward, and encoding model-provider conflicts.
tool-use-orchestration (architecture)
Harvey's legal agents orchestrate hundreds of model and tool calls across documents, files, sandboxes, and model providers.
eval-driven-development (evaluation)
Harvey uses LAB benchmark results by practice area and task type to drive model selection and routing decisions.
observability-tracing (operations)
The legal-specific layer includes complete inspectable records of agent actions for work-product and privilege review.
Tradeoffs
Own the agent runtime.
Chose A custom Harvey runtime with provider normalization and ZDR lifecycle controls over Relying only on managed agent runtimes from model labs or cloud providers.
Rationale: Runtime ownership increased engineering burden but was necessary for multi-model routing, zero retention, cost control, conflict-aware governance, and legal-specific deployment requirements.
Prefer true ZDR over managed state persistence.
Chose Session-scoped state inside Harvey's security boundary over Managed runtime persistence of working memory, files, tool results, and checkpoints.
Rationale: Managed persistence helps reliability, but for privileged legal data it conflicts with zero-retention requirements.
Route by efficient sufficiency.
Chose The cheapest and fastest model that meets task quality over The strongest model for every legal task.
Rationale: As legal tasks become intelligence-saturated, routing everything to a frontier model overspends and prevents economical full-document-set agents.
Build a durable legal-specific layer while absorbing ecosystem improvements.
Chose Custom legal governance, data residency, sovereign deployment, and audit capabilities over Routing around provider ecosystems indefinitely.
Rationale: Harvey expects general cloud capabilities to improve, but legal-specific requirements remain durable and need a layer Harvey controls.
Gotchas (what bit them)
Managed runtimes can create lock-in at the agent workforce level, not just the model level.
Root cause: Agents built inside a provider runtime depend on that provider's formats and orchestration, so switching providers means moving the operational agent system too.
Resolution: Harvey built a provider abstraction layer that normalizes harnesses, sandboxes, formats, streaming behavior, and failure modes.
3 supporting quotes
Zero data retention cannot be added as a deletion endpoint after a run.
Root cause: Deleting persisted state after execution still means data was retained, which violates ZDR requirements for privileged legal data.
Resolution: Harvey designed ZDR as a runtime property where data is never written to persistent storage and session state is purged afterward.
Stateful agents make ZDR harder than stateless chat.
Root cause: Long-running agents need working memory, intermediate files, tool results, and checkpoints, and managed runtimes often persist that state to deliver reliability.
Resolution: Harvey keeps the whole agent lifecycle inside its boundary and scopes state to the session.
3 supporting quotes
Frontier-only routing can make full-corpus legal agents economically impossible.
Root cause: Large legal workflows can require hundreds of model/tool calls over enormous document sets, and many subtasks no longer need the largest model.
Resolution: Harvey routes by task quality threshold and cost, including open-source models and sandbox optimization.
3 supporting quotes
Provider-specific tool behavior causes cross-model quality drops.
Root cause: Each provider exposes different tool-call formats, stop conditions, streaming behavior, failure modes, and sandboxes, and tasks tuned for one model can underperform on another.
Resolution: Harvey normalizes those provider differences behind a single interface before making model choice a routing decision.
Evaluation
Harvey evaluates models with LAB, a Legal AI Benchmark split by practice area and task type and graded with rubrics. Those benchmark results feed routing decisions so the runtime can choose the most efficient allowed model that satisfies quality thresholds as model capabilities evolve.
Metrics: LAB benchmark performance by practice area · LAB benchmark performance by task type · Quality threshold for routing · Cost per workload · Open-source versus frontier quality spread · 3-5x cost reduction versus frontier-only baseline · Provider capacity, uptime, and feature availability
3 supporting quotes
Outcomes
- Harvey moved from a chat product to a cloud-agent platform
- the runtime supports multi-model routing across providers and self-hosted models
- session state is scoped and purged to satisfy zero-retention constraints
- routing and sandbox optimization reportedly reduce costs 3-5x versus a frontier-only approach
- the architecture makes agent workflows over hundreds of thousands or millions of legal files economically viable
- Harvey retained a durable legal-specific layer for conflicts, data residency, sovereign deployment, and inspectable records
The summary describes workflows across hundreds of thousands of documents, full firm document sets of hundreds of thousands or millions of files, single agent runs with hundreds of model/tool calls, 3-5x cost reductions, LAB benchmark routing, and model-rubric grading by GPT-5.4.