October workshops are openBuild a Search AI Agent$99 early bird

Enroll now
Skip to content

PATHWAY PROJECT · CAPSTONE PROJECT · 3 SMALL IDEAS + A GUIDED LAB

Contract comparison review agent

A comparison table should reveal differences in the documents, not hide an extractor's mistake.

You will learn to: Separate candidate extraction from source verification and prepare a scoped, reviewable comparison of fictional service agreements.

Preparing your lesson and this browser’s progress…
Read the complete lessonAll the ideas in one place · works without the editor

Use these notes to review a concept or read at your own pace. The interactive workspace above adds predictions, editable code, and actual run results.

IDEA 1

Choose a neutral comparison criterion

A useful comparison asks the same question of each document. 'How many days of termination notice does this clause state?' is a concrete criterion. 'Which agreement is obviously better?' mixes factual extraction with a value judgment. Students can debate which criteria matter after the helper has made the documented differences inspectable.

This project compares fictional service agreements A and B. Each has a declared version and a rule annotation beside an authored passage. The records are teaching fixtures, not real laws or executed contracts. The program returns a difference table; it does not decide enforceability, give legal advice, or infer an unstated exception from a missing field.

Ask the same question twice

  1. Criterion. Compare the stated notice period.
  2. Agreement A. The authored passage says two days.
  3. Agreement B. The authored passage says three days.

Fictional records for learning. Follow the evidence and the checks.

Work through the example

const rule = policy.rules.find(r => r.criterion === input.criterion);

Finding the criterion identifies a field to compare. The number's meaning comes from the criterion and passage, not from a ranking of policies.

Think it through: Agreement B has no notice-period rule. What should its table cell say?

IDEA 2

Treat extracted values as candidates

An extractor turns source material into structured fields. A live model can do this, but it may omit a condition or invent a value. In our lab the candidate extraction is explicitly authored input, including a wrong result. No live model or language understanding is hidden inside extractRule. Its purpose is to let you test a verifier against a visible error.

The checker compares the candidate with the original fixture's rule annotation. A verified row keeps its source ID, version, and passage. A disagreement becomes extraction_mismatch and blocks a completed comparison. This narrow equality check demonstrates separation between proposing and verifying; it does not establish that arbitrary legal interpretation can be reduced to exact string or number equality.

Keep the candidate separate from the source

  1. Original. The source annotation says three days.
  2. Candidate. The authored extractor incorrectly suggests one day.
  3. Verifier. Compare with the captured original and reject the mismatch.

Fictional records for learning. Follow the evidence and the checks.

Work through the example

const check = tools.checkClaimSource(id, input.criterion, candidate.value);
if (!check.matches) {
  rows.push({ policyId: id, status: "needs_review", reason: "extraction_mismatch", version: policy.version });
}

The verifier does not trust the extractor's self-assessment. A failure stays visible instead of silently replacing the candidate and claiming the extraction succeeded.

Think it through: The extractor reports 1, but the source's explicit rule annotation says 3. Which report is honest?

IDEA 3

Bind the preview to versions and review scope

Before comparing, establish which version of each agreement the task expects. If a fetched agreement is a different version, report version_conflict. Do not combine an older clause from A with a newer approval for B and present the table as one reviewed package. The source set is part of what the reviewer needs to see.

A complete table without approval is still a useful draft. The optional local preview requires approval for the criterion and both source versions. The preview tool rechecks the rows against its captured records, including passages and values. No real publication occurs. The resulting artifact supports a contract reviewer by preserving the exact comparison and unresolved questions. People must still interpret conditions, assess context, and decide what the terms mean.

Review the actual comparison

  1. Source set. The task expects A version 1 and B version 2.
  2. Review scope. Approval names the criterion and those versions.
  3. Preview. The tool independently rechecks the complete table.

Fictional records for learning. Follow the evidence and the checks.

Work through the example

const ready = rows.every(row => row.status === "verified");
if (!ready) return { status: "needs_review", criterion, comparison: "unresolved", rows };

Only verified rows can support a same-or-different comparison. Review status is not a judgment that either agreement is a better policy.

Think it through: All rows verify, but there is no review approval. What should this workflow produce?

Put it into practice

Verify extracted values, expose missing or stale rules, and gate the local comparison preview on the exact source scope.

  1. Inspect the fictional input and the selected case's expected result.
  2. Run the starter. Locate its missing rule using the output and actual tool trace.
  3. Insert the explained snippet at the TODO and rerun the same case.
  4. Run all three cases, then change the experiment input and explain what the evidence now supports.

Your next experiment: Both agreements now agree, but approval is absent. Predict the comparison field and the draft status; no preview tool should be called.

A useful comparison separates what the source says, what the extractor proposed, and what the reviewer approved.

Key terms

Criterion
The same explicit question or attribute compared across documents.
Extraction
Turning source material into structured fields; the result still needs checking.
Source scope
The document IDs, versions, and relevant subject covered by the task and review.

Sources and scope

Original Stemtiq teaching, reviewed 2026-09-14. The named researchers and organizations do not endorse this course. Classroom cases are authored exercises, not published findings.

Anthropic: Writing effective tools for agents — with agents

11 September 2025

Design distinct tools with clear parameters, relevant returned information, and evaluations of how the agent actually uses them.

A description or schema does not guarantee the right action. A live tool can return different data for the same arguments as its environment changes.

Anthropic: Demystifying evals for AI agents

9 January 2026

Define tasks, trials, and graders; inspect both execution records and final outcomes; repeat trials when model behavior varies.

A score depends on its cases and grading rules. Repeating a deterministic classroom case does not measure the variability of a live model.

OpenAI: Guardrails and human review

Reviewed 13 September 2026 · undated documentation

Distinguish automatic checks from approval decisions, pause sensitive tool requests, retain state, and resume after an application approves or rejects them.

Model-generated approval text is not authorization. Resume examples that automatically approve a request do not establish that a person reviewed it.

AWS · Amazon Bedrock AgentCore: Policy in Amazon Bedrock AgentCore: Control Agent Interactions

Reviewed 13 September 2026 · undated documentation

Evaluate identity and tool inputs at a gateway before allowing a call. Treat policy authoring, review, enforcement, and decision logging as separate operations.

The gateway governs capabilities routed through it. A classroom approval check is not an AgentCore integration or a complete production authorization system.

Your JavaScript really runs. The model decisions and school data are authored simulations, so you can learn without an API key. Every workspace also includes a separate real SDK example to explore next. Passing the lab’s cases is practice, not proof that an agent is ready for real-world use.