Scaling Agent-Based Architecture for Legal AI Assistant
harvey · Legal · 2025 · source Agentic: yes · promotional bias: low · source-backed · extracted with prompt 0.5.6 (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 assistant feature scaling
Harvey needed to scale its Assistant from bespoke LLM orchestration into a shared agent framework so multiple teams could add retrieval, drafting, review, integrations, and product modes without a single team becoming the bottleneck or degrading quality.
Constraints:
- Assistant needed to proactively plan, create, and execute end-to-end legal tasks using tools inside and outside Harvey.
- Users were not discovering dedicated modes such as Draft mode.
- Multiple retrieval calls behind one interface were complex to maintain.
- New integrations did not have a clear launch path in the existing monolithic system.
- Multiple engineers editing one core system prompt could create conflicts and regressions.
Architecture
Harvey moved Assistant to a pure agent framework in mid-2025. Top-level thread interfaces became agents, formerly forced retrieval calls and bespoke editing logic became tool calls, and feature capabilities were packaged as Tool Bundles that include tools, sub-agents, and partial prompt instructions. The team adopted the OpenAI Agent SDK to avoid custom orchestration, gave feature teams controlled prompt/tool contribution boundaries, and enforced leave-one-out eval gates for Tool Bundles and system prompt upgrades.
Diagram confidence: explicit (topology described by the source).
flowchart LR A["Assistant thread agent"] --> B["OpenAI Agent SDK"] A --> C["System prompt"] A --> D["Tool Bundles"] D --> E["Retrieval capabilities"] D --> F["Drafting capabilities"] D --> G["Review and integration capabilities"] C --> H["Eval gates"] D --> H H --> I["Feature teams"] I --> D E --> A F --> A G --> A
Components
| Component | Role | Interacts with |
|---|---|---|
Assistant thread agent |
Top-level conversational interface that plans and executes legal tasks in one thread. | OpenAI Agent SDK, System prompt, Tool Bundles |
OpenAI Agent SDK |
External agent framework that encourages tool-calling loops over bespoke workflow orchestration. | Assistant thread agent |
System prompt |
Central reasoning instructions shared across capabilities and susceptible to cross-team conflicts. | Tool Bundles, Eval gates |
Tool Bundles |
Portable capability packages containing tools, sub-agents, and scoped instructions. | Retrieval capabilities, Drafting capabilities, Review and integration capabilities, Eval gates |
Retrieval capabilities |
Knowledge-source and tax-law retrieval tools used inside Assistant. | Assistant thread agent |
Drafting capabilities |
Drafting and editing tools/sub-agents available inside the thread. | Assistant thread agent |
Review and integration capabilities |
Document review tables, Ask LexisNexis, iManage, Deep Research, and other product integrations. | Assistant thread agent |
Eval gates |
Datasets, evaluators, thresholds, and leave-one-out tests that block regressions. | Feature teams |
Feature teams |
Teams contributing new Assistant capabilities with minimal centralized-team involvement. | Tool Bundles |
Data flow
A user asks a legal task in an Assistant thread. The agent reasons over the system prompt and available Tool Bundles, chooses retrieval, drafting, review, LexisNexis, iManage, or Deep Research tools as needed, executes tool calls in a loop, and combines results in-thread. Feature teams package new capabilities as Tool Bundles with instructions and datasets. Any system prompt or bundle change runs eval gates, including leave-one-out validation, before deployment.
3 supporting quotes
Why this architecture
Harvey adopted agents because open-ended legal tasks and many integrations fit a model-driven tool-calling loop better than bespoke orchestration. Tool Bundles created a contribution interface for feature teams, while eval gates protected quality as capabilities multiplied.
3 supporting quotes
Models used: OpenAI Agent SDK · Foundation models · Drafting sub-agent
Scale
- The agent framework scaled in-thread feature development from one team to four.“Adopting a single agent framework scaled our in‑thread feature development from one team to four”article, stated
- Assistant became the home for integrations such as Ask LexisNexis and iManage plus new modes like Deep Research.“Assistant also became the home for critical integrations (like Ask LexisNexis and iManage) and new product modes”article, stated
- Tool Bundles must maintain datasets, evaluators, and thresholds.“developers to maintain datasets and evaluators for each of their Tool Bundles, along with thresholds that fire if metrics drop below a certain score.”article, stated
Alternatives considered (roads not taken)
Continue bespoke Python plus LLM orchestration
Rejected because: It produced tuned systems but limited feature discoverability, retrieval integration, and cross-team contribution paths.
One centralized team integrates every new capability
Rejected because: Harvey needed feature and integration developers to contribute without bottlenecking on Assistant owners.
Let all teams edit the core system prompt freely
Rejected because: Prompt goals can collide, creating English merge conflicts and quality regressions.
Write a custom agent library with workflow-style orchestration
Rejected because: The OpenAI Agent SDK forced the team to lean into model tool-calling loops instead of rebuilding hybrid orchestrators.
Patterns
tool-use-orchestration (orchestration)
Harvey converted retrieval, integrations, and bespoke editing logic into agent tool calls inside a shared thread interface.
multi-agent-orchestration (orchestration)
Tool Bundles can package multiple tools and sub-agents, such as a drafting bundle with an editing tool and drafting sub-agent.
eval-driven-development (evaluation)
Tool Bundles and prompt upgrades must pass leave-one-out gates, datasets, evaluators, and thresholds before deployment.
prompt-versioning (prompting)
Harvey treated system prompt and Tool Bundle instruction changes as shared artifacts that need ownership boundaries and regression gates.
structured-output-contract (interfaces)
Tool Bundles define stable capability packages and contribution boundaries for feature teams.
Tradeoffs
Agent framework versus bespoke orchestration
Chose OpenAI Agent SDK and no custom orchestration over custom workflow-style orchestrators.
Rationale: The framework forced the team to exploit tool-calling strengths of modern models and unlocked integrations across knowledge sources and Deep Research.
Capability contribution model
Chose Tool Bundles with partial prompt control over central Assistant-team integration for every feature.
Rationale: Tool Bundles let feature teams ship capabilities while keeping boundaries and portability.
Quality control
Chose leave-one-out eval gates over trusting individual feature evals or manual coordination.
Rationale: Capabilities can interfere with each other, so gates must detect when one bundle or prompt upgrade harms another.
Gotchas (what bit them)
Mode-specific UX hid powerful features.
Root cause: Users had to discover when to enter Draft mode or choose knowledge-source recommendations.
Resolution: Move capabilities into one in-thread agent interface that can choose tools.
Agent collaboration creates prompt conflicts.
Root cause: Different feature teams can encode incompatible instructions in the shared system prompt.
Resolution: Use Tool Bundles to scope partial prompt control and eval gates to catch regressions.
Tool output can cause context rot.
Root cause: New tools may inject significant context that degrades agent behavior.
Resolution: Require bundle-specific datasets, evaluators, thresholds, and leave-one-out gates.
Framework adoption reduced determinism.
Root cause: Moving from deterministic bespoke workflows to tool-calling loops meant execution could not be guaranteed in the same way.
Resolution: Tune prompts, accept the agent framework boundary, and rely on evals to validate recall and integration quality.
Evaluation
Harvey evaluates agent changes with centralized evals, Tool Bundle datasets, evaluators, thresholds, leave-one-out gates, and capability-specific recall checks.
Metrics: In-thread feature development scaled from one team to four · Tool Bundles and system prompt upgrades must pass leave-one-out gates · Retrieval datasets define many queries with expected recall across knowledge sources · Future work includes scaling eval gates to combinatorial Tool Bundle interactions
3 supporting quotes
Outcomes
- Harvey scaled in-thread Assistant feature development from one team to four.
- Tool Bundles enabled portable capabilities and safer team contributions.
- The OpenAI Agent SDK and no-custom-orchestration rule centralized behavior around tool-calling loops.
- Eval gates protected quality as capabilities multiplied.
- The agent framework enabled emergent combinations across retrieval, drafting, review, and integrations.
The case centers on organizational and capability scale: one to four teams, multiple integrations, top-level thread agents, and leave-one-out gates for every Tool Bundle or system prompt upgrade.