Post-Training a Frontier Legal AI Agent Through Full-Stack Optimization

harvey · Legal · 2026 · source Agentic: yes · promotional bias: med · 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 agents and post-training infrastructure

Harvey and Applied Compute needed to train an open-weight legal agent that could satisfy strict legal benchmark criteria where partial success is not enough, while ensuring the grader signal could be trusted, long-document tasks could fit through an agent harness, and tool use became efficient and grounded rather than brute-force.

Constraints:

Architecture

Applied Compute and Harvey optimized the whole legal-agent training stack. They established trusted grader signals by comparing frontier graders and cheaper candidate graders against a gold-trace consensus; reduced grader cost by batching criteria through GPT-5 Mini; improved Harvey's LAB harness with tool-output limits, broken-tool-call repairs, tool-use advice, output reminders, and compaction; trained GLM-5.1 with full-parameter fully-asynchronous reinforcement learning on AC2; and analyzed the resulting model for learned behaviors such as artifact completeness, specificity/exactness, grounding, and more efficient tool use.

Diagram confidence: explicit (topology described by the source).

flowchart LR
  Legal_Agent_Benchmark["Legal Agent Benchmark"] --> Agent_harness["Agent harness"]
  Legal_Agent_Benchmark --> Grader_evaluation_system["Grader evaluation system"]
  AC2_platform["AC2 platform"] --> Agent_harness
  AC2_platform --> Grader_evaluation_system
  AC2_platform --> Full_parameter_RL_trainer["Full-parameter RL trainer"]
  Agent_harness --> GLM_5_1_agent["GLM-5.1 agent"]
  Agent_harness --> Compaction_module["Compaction module"]
  Agent_harness --> Legal_source_documents["Legal source documents"]
  Compaction_module --> GLM_5_1_agent
  Grader_evaluation_system --> GPT_5_Mini_grader["GPT-5 Mini grader"]
  Grader_evaluation_system --> Frontier_grader_consensus["Frontier grader consensus"]
  Full_parameter_RL_trainer --> GLM_5_1_agent
  Full_parameter_RL_trainer --> Behavior_analysis["Behavior analysis"]
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
Legal Agent Benchmark Provides legal tasks, source documents, instructions, and binary rubric criteria. Agent harness, Grader evaluation system
AC2 platform Runs evaluations, training jobs, consistency checks, RL, and supporting analysis. Agent harness, Grader evaluation system, Full-parameter RL trainer
Agent harness Sandboxed legal-agent environment with read, grep, bash, document-generation, verification, tool advice, and output reminders. GLM-5.1 agent, Compaction module, Legal source documents
GLM-5.1 agent Base open-weight model trained into the final legal agent. Agent harness, Full-parameter RL trainer
Legal source documents Large task-specific files the agent reads, searches, summarizes, and cites. Agent harness
Compaction module Summarizes long episode transcripts at a context threshold and starts a fresh conversation from the summary. Agent harness, GLM-5.1 agent
Grader evaluation system Runs LLM-as-judge grading, self-consistency checks, cross-consistency checks, and cost-alignment comparisons. GPT-5 Mini grader, Frontier grader consensus, Legal Agent Benchmark
Frontier grader consensus Gold-trace ground truth derived from high-agreement frontier model judgments. Grader evaluation system
GPT-5 Mini grader Cost-effective aligned grader used with batched criteria calls for evaluation at scale. Grader evaluation system
Full-parameter RL trainer Runs fully-asynchronous reinforcement learning to improve GLM-5.1's tool use, legal reasoning, and document grounding. GLM-5.1 agent, Behavior analysis
Behavior analysis Attributes score gains to artifact completeness, specificity/exactness, grounding, and tool-use efficiency. Full-parameter RL trainer

Data flow

LAB tasks provide source documents, instructions, and task-specific rubrics. Candidate agent rollouts run in a sandboxed harness with read, grep, bash, docx generation, and verification tools. When context grows too large, the harness summarizes the episode transcript and starts a fresh conversation from that summary. Outputs and traces are graded by an aligned LLM-as-judge setup using batched criteria calls. AC2 runs evaluations, consistency checks, RL training, and behavioral analysis, then compares baseline and trained checkpoints on held-out tasks.

4 supporting quotes
“We optimized the end-to-end training process, spanning data and grader analysis, harness engineering, and full-parameter reinforcement learning.”article, stated
“Each datapoint includes source documents, task instructions, and a task-specific rubric.”article, stated
“We conducted evaluations, training jobs, consistency checks, and the supporting analysis on our platform”article, stated
“Compaction involves the harness sending the current episode's transcript to the same agent for summarization”article, stated

Why this architecture

The team optimized grader, harness, and model together because LAB's strict legal tasks make weak evaluation signals and poor tool scaffolding dangerous. A trusted and affordable grader made RL scalable; harness improvements made tool-using rollouts feasible; compaction let the agent work beyond native context limits; and full-parameter RL taught GLM-5.1 to use tools and documents better rather than only relying on prompt scaffolding.

4 supporting quotes
“Training a frontier model on tasks as difficult to verify as LAB requires trust in the optimization signal.”article, stated
“This finding enabled us to scale up grading and sampling for high-compute RL runs.”article, stated
“only improved when it was trained to better utilize tools and address its own failure cases.”article, stated
“we trained GLM-5.1 into a state-of-the-art legal agent by optimizing the full stack: grader, harness, and full-parameter reinforcement learning on AC2.”article, stated

Models used: GLM-5.1 · AC GLM-5.1 · GPT-5.5 xhigh · Opus 4.8 Max · Claude Opus 4.7 Max · GPT-5 Mini · Claude Sonnet 4.6 · GPT-5 Nano · Claude Haiku 4.5 · Qwen 3.6 35B A3B · Kimi K2.6

Scale

Alternatives considered (roads not taken)

Trust the original benchmark grader setup without analysis

Rejected because: The team believed a powerful model would exploit flawed grader signals, so they established frontier-model consensus and candidate-grader consistency first.

“A powerful open-weight model will learn to exploit any flaw in the grader via loopholes in the evaluation criteria and environment.”article, stated
“We treat this consensus set as the gold-trace ground truth and use it to evaluate the candidate graders”article, stated

Grade one criterion per call with Claude Sonnet 4.6

Rejected because: GPT-5 Mini with batched criteria kept high alignment while cutting grader costs by 40x to 100x.

“switching to smaller grader models, and grouping multiple criteria into each grader call instead of evaluating one criterion per call.”article, stated
“40x (at 16-per-group) and 100x (at all-criteria-in-one-group) cost savings”article, stated

Use the base LAB harness unchanged

Rejected because: The team found scalable improvements through token-output restrictions, tool-call repair, tool-use advice, output reminders, and compaction.

“We began with the harness published by Harvey in the LAB repository”article, stated
“restricting the number of tokens in tool output, repairing broken tool calls, providing advice on tool-use, and adding reminders to produce outputs led to large improvements”article, stated

Rely on native context length

Rejected because: Large legal files caused rollouts to hit context limits, so compaction extended effective working context while forcing better context use.

“reach the max context length limit due to the abundance of large files which the agent pulls into context.”article, stated
“Due to our compaction harness, the model can ingest far more tokens than its max context length”article, stated

Train with parameter-efficient or scaffolding-only changes

Rejected because: GLM-5.1 did not meaningfully improve from harness updates alone and needed full-parameter RL to improve tool use and failure modes.

“GLM-5.1 stayed roughly the same after the harness update and only improved when it was trained”article, stated
“full-parameter fully-asynchronous RL on AC2.”article, stated

Patterns

fine-tuning-adaptation (model-adaptation)

Applied Compute post-trained GLM-5.1 with full-parameter reinforcement learning on legal-agent tasks to improve tool use, grounding, exactness, and artifact completion.

“We collaborated with Harvey to post-train a frontier legal model on top of GLM-5.1. In Harvey's Legal Agent Benchmark⌝ (LAB), our trained model outperformed every available model on rubric pass rate.”article, stated
“we set out to train the best possible model with full-parameter fully-asynchronous RL on AC2.”article, stated

eval-driven-development (evaluation)

The whole training process is organized around held-out LAB evaluation, grader alignment, self-consistency, cross-consistency, rubric pass rate, all-pass rate, and behavioral analysis.

“We optimized the end-to-end training process, spanning data and grader analysis, harness engineering, and full-parameter reinforcement learning. All reported eval scores are on a held-out test split that mirrors the full LAB distribution.”article, stated
“We conducted a thorough analysis over data and graders to determine the best setup for training.”article, stated

cost-aware-routing (cost)

The team chose a cheaper aligned grader and batched criteria per grader call to make high-compute RL grading affordable.

“we examined exchanging quality for cost compared to the largest and most expensive models.”article, stated
“This finding enabled us to scale up grading and sampling for high-compute RL runs.”article, stated

tool-use-orchestration (agent-architecture)

The legal agent uses read, grep, bash, document-generation, and verification tools, and training shifts it toward targeted tool use.

“We began with the harness published by Harvey in the LAB repository, which includes simple tools like read and grep over files mounted into a sandboxed execution environment. We worked to closely match the reported scores from the Initial Results on Legal Agent Benchmark blogpost.”article, stated
“In contrast, the trained model avoids unhelpful tool calls and uses targeted reads to collect context and relies on only two tool calls to construct and then verify its final deliverable.”article, stated

context-compaction (context)

The harness summarizes the episode transcript at a token threshold, starts a fresh conversation from the summary, and permits up to four compactions.

“automatically triggering compaction to summarize the current conversation when it reached a certain token limit.”article, stated
“Then, a fresh conversation starts from that summary. For the final compaction harness, we use a compaction trigger of context_tokens >= 131072 and up to 4 max_compactions.”article, stated

observability-tracing (operations)

AC2 analyzes traces, training/eval scores, tool-use patterns, domain shifts, and behavior-level failure-to-pass flips to interpret what the model learned.

“We analyzed the way the model changes over the course of training using the AC2 platform. We see the train and eval scores increase from the beginning to the end of training, but what learnings and advancements are actually driving those improvements in scores?”article, stated
“We can directly observe these learned behaviors by comparing traces from held-out eval points at the beginning and end of training.”article, stated

model-distillation (model-adaptation)

The conclusion identifies relevance-masked self-distillation as a future complementary technique to further strengthen grounding.

“We expect further gains from relevance-masked self-distillation to strengthen grounding and agentic router training to optimize for cost alongside quality.”article, stated

Tradeoffs

Optimize the full stack rather than only the model.

Chose grader analysis, harness engineering, compaction, and full-parameter RL over model training alone.

Rationale: The model could only improve safely and affordably if the grader signal, tool harness, and long-context management were also reliable.

“we trained GLM-5.1 into a state-of-the-art legal agent by optimizing the full stack: grader, harness, and full-parameter reinforcement learning on AC2.”article, stated

Use a cheaper batched grader setup.

Chose GPT-5 Mini with batched criteria-per-call over the original one-criterion-per-call Claude Sonnet 4.6 setup.

Rationale: The batched setup preserved alignment above 97% while making RL grading and sampling economically scalable.

“We found that medium-sized models such as GPT-5 Mini and Claude Sonnet 4.6 largely maintained quality, staying above 97% alignment with the agreed-upon frontier ground truth.”article, stated
“This finding enabled us to scale up grading and sampling for high-compute RL runs.”article, stated

Use compaction to extend legal-agent work.

Chose automatic transcript summarization and fresh conversations over terminating or truncating long-context rollouts at native context length.

Rationale: LAB tasks include very large documents, and compaction lets the agent continue while learning to avoid context rot.

“Compaction involves the harness sending the current episode's transcript to the same agent for summarization (using the same weights, but a different system prompt).”article, stated
“Due to our compaction harness, the model can ingest far more tokens than its max context length but must learn to effectively use that effective context and avoid context rot.”article, stated

Use full-parameter RL for GLM-5.1.

Chose full-parameter fully-asynchronous reinforcement learning over harness-only improvements or lighter adaptation.

Rationale: GLM-5.1's baseline performance was strong, but harness changes alone did not improve it; RL taught it better tool usage and document reasoning.

“We conducted derisking runs with Qwen 3.6 35B A3B and Kimi K2.6 to determine the strongest harness and hyperparameters, and we ultimately settled on training GLM-5.1 due to its superior performance on the baseline.”article, stated
“We attribute the capabilities gains on the model mostly to improved tool call usage and reasoning about the source documents.”article, stated

Gotchas (what bit them)

A powerful model can optimize against grader flaws instead of legal quality.

Root cause: LAB uses LLM-as-a-Judge signals, and RL will exploit loopholes in criteria or environment if the signal is weak.

Resolution: Build a gold-trace ground truth from frontier-grader agreement and validate cheaper graders against self- and cross-consistency.

“A powerful open-weight model will learn to exploit any flaw in the grader via loopholes in the evaluation criteria and environment.”article, stated
“We treat this consensus set as the gold-trace ground truth and use it to evaluate the candidate graders: GPT-5.5, Claude Opus 4.7, GPT-5 Mini, Claude Sonnet 4.6, GPT-5 Nano, and Claude Haiku 4.5.”article, stated

Naive grader calls make high-compute RL too expensive.

Root cause: The original setup evaluated one criterion per call with a larger grader model.

Resolution: Use GPT-5 Mini and batch multiple criteria per call after confirming high alignment with frontier ground truth.

“grouping multiple criteria into each grader call instead of evaluating one criterion per call.”article, stated
“By switching to GPT-5 Mini and batching multiple criteria per-call, we observed between 40x (at 16-per-group) and 100x (at all-criteria-in-one-group) cost savings relative to the original setup.”article, stated

Legal-agent rollouts can overflow context through broad file reads.

Root cause: Large source files and tool outputs dump hundreds of thousands of tokens into the context window.

Resolution: Limit tool-output tokens, encourage targeted reads, and use compaction to summarize long transcripts before continuing.

“1. read documents/market-data-summary.xlsx returned over 200,000 characters into the token stream.”article, stated
“the model can ingest far more tokens than its max context length but must learn to effectively use that effective context and avoid context rot.”article, stated

Harness improvements do not guarantee capability gains for every base model.

Root cause: GLM-5.1 did not materially improve from the harness update alone because it needed to learn better tool use and failure-case handling.

Resolution: Train the model with full-parameter RL after confirming harness parity and improvements.

“Notably, while almost all models largely benefit from the jump from the base harness to the AC harness, our chosen base model for training GLM-5.1 stayed roughly the same after the harness update and only improved when it was trained to better utilize tools and address its own failure cases.”article, stated
“Notably, while almost all models largely benefit from the jump from the base harness to the AC harness, our chosen base model for training GLM-5.1 stayed roughly the same after the harness update and only improved when it was trained to better utilize tools and address its own failure cases.”article, stated

Legal answers fail when they are broad, rounded, or insufficiently grounded.

Root cause: The base model rounded numbers, hallucinated source items, invented findings, and made poorly supported claims.

Resolution: RL improved artifact completeness, specificity/exactness, and grounding, flipping hundreds of criteria from fail to pass.

“2. Specificity and Exactness: The base GLM-5.1 model suffers from poor calculations or referring to imprecise numbers, often rounding figures during math (like 1.9 to 2), which is punished by legal graders. This behavior flips 243 criteria from failing to passing.”article, stated
“the checkpoint sometimes hallucinates source document items or invents findings from outside the provided documents.”article, stated

Evaluation

Evaluation uses LAB's held-out test split, task-specific binary rubrics, rubric pass rate, all-pass rate, grader alignment against frontier consensus, self-consistency across reruns, cross-consistency correlations, domain-level score shifts, and behavior-level failure-to-pass analysis.

Metrics: Rubric pass rate · All-pass rate · Per-criteria grader alignment · Per-criteria self-consistency · Cross-consistency Pearson correlation · Cost per trace · Domain-level score shift · Tool calls · Read calls · Bash calls · Tool payload tokens · Criteria flipped by artifact completeness · Criteria flipped by specificity/exactness · Criteria flipped by grounding

4 supporting quotes
“We optimized the end-to-end training process, spanning data and grader analysis, harness engineering, and full-parameter reinforcement learning. All reported eval scores are on a held-out test split that mirrors the full LAB distribution.”article, stated
“Harvey's open-source Legal Agent Benchmark (LAB) is designed around that standard. It is difficult not only because the tasks are complex, but also because the grading schema is strict: a task passes only when all of its required criteria are satisfied.”article, stated
“Alignment for these top four graders is further supported by cross-consistency metrics like a 0.99 Pearson correlation across criteria.”article, stated
“The model learned to properly use tools and always create an output artifact. This behavior flipped 185 relevant rubric criteria”article, stated

Outcomes

The work targets a legal benchmark with more than 1,250 tasks, 24 practice areas, and over 75,000 binary criteria. The final system uses compaction at 131,072 context tokens with up to four compactions to handle source documents that can exceed 200,000 tokens.

5 supporting quotes
“our trained model outperformed every available model on rubric pass rate.”article, stated
“The resulting model lifts rubric pass rate from 0.853 to 0.913 and all-pass rate from 0.059 to 0.126, making it the strongest available model by rubric pass rate and second only to Opus 4.8 Max on all-pass rate.”article, stated
“Tool calls 104 42”article, stated
“Tool payload tokens 461k 250k”article, stated
“these gains to concrete, interpretable behaviors in improved artifact completeness, sharper specificity, and stronger grounding”article, stated