Skip to content

feat(platform): Add contract comparison workflow template #664

Closed

Description

@larryro

Summary

Create a predefined workflow template that compares multiple documents (e.g., contracts) and produces a structured comparison report highlighting differences and frequently modified sections.

Motivation

A common use case for document-heavy organizations is comparing multiple versions of similar documents to identify patterns, differences, and frequently negotiated sections. This workflow automates what would otherwise be hours of manual side-by-side reading.

Proposed Workflow Design

Step 1 (LLM node):
  Tools: [document_list]
  Prompt: "List the most recent {count} documents matching {filter criteria}"
  Output: JSON array of document IDs and metadata

Step 2 (Loop node):
  Collection: Step 1 output document list
  Per iteration (LLM node):
    Tools: [document_retrieve]
    Prompt: "Retrieve document {item.id} and extract its structural outline
             (sections, clauses, key terms). Output as structured JSON."
    Output format: JSON with clause structure

Step 3 (LLM node):
  Prompt: "Compare all extracted structures from Step 2 iterations.
           Identify: (1) clauses present in all documents,
           (2) clauses that differ across documents,
           (3) most frequently modified sections.
           Produce a comparison summary."
  Output format: JSON

Step 4 (LLM node):
  Tools: [docx]
  Prompt: "Generate a DOCX comparison report from the analysis in Step 3.
           Include a summary table, per-clause comparison, and frequency statistics."

Implementation Notes

  • Add to services/platform/convex/predefined_workflows/ following existing patterns
  • The workflow should accept input parameters: document filter criteria (folder, date range, limit)
  • Use threadId sharing across LLM steps for context continuity
  • Output schema for Step 2 iterations should be consistent for aggregation in Step 3

Dependencies

Acceptance Criteria

  • Predefined workflow registered and available in the system
  • Accepts configurable parameters (folder filter, document count, etc.)
  • Produces a downloadable DOCX comparison report
  • Handles documents of varying sizes via paginated retrieval
  • End-to-end test with sample documents

Metadata

Metadata

Assignees

No one assigned

    Labels

    featpriority: lowservice: platform

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions