Skip to content

nitindavegit/ClauseIQ

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

ClauseIQ – AI-Powered Multi-Agent Contract Risk Analyzer

License: CC BY 4.0 Made with Google ADK Model: Gemini 2.5 Flash Lite

Transform contract review from hours to minutes with intelligent multi-agent AI


🧾 Problem Statement

Contract review is slow, tedious, and expensive. Organizations signing vendor agreements, SaaS licenses, NDAs, and partnership contracts must identify legal and financial risks before approval — but this requires time, legal expertise, and manual effort.

Reading each clause word-by-word, identifying obligations, renewal traps, liability exposure, confidentiality terms, and negotiating leverage is mentally exhausting.

The Result:

  • Teams spend hours reviewing documents, or
  • Sign contracts without fully understanding their exposure
  • Leading to harmful financial commitments, unlimited liabilities, and operational risks

Manual review makes it impossible to scale: more contracts means more delays, more risk, and increased workload for legal and procurement teams.


💡 Solution

ClauseIQ applies multi-agent AI to automate contract understanding. A user uploads a PDF, and the system performs three core steps automatically:

  1. Extract clauses from the contract and structure them into categories
  2. Evaluate legal and financial risks
  3. Generate an executive summary targeted at business decision-makers

Users can also ask follow-up questions such as:

  • "Which clauses are high risk?"
  • "What should we renegotiate?"
  • "Explain the indemnification clause"

ClauseIQ stores memory across the session, enabling grounded follow-up answers based strictly on the uploaded contract rather than hallucination. This turns contract review into a fast, scalable workflow that empowers decision-makers with clarity before signing.


🏗 Architecture

ClauseIQ is a multi-agent system built using Google's Agent Development Kit (ADK). It is not a single general model — instead, it is a team of specialized agents coordinated by a central orchestrator.

Agent Responsibility
Extractor Agent Reads PDF artifacts and extracts structured clauses
Risk Analyst Agent Evaluates risk level and business/legal exposure for each clause
Reporter Agent Writes an executive-style summary for business leadership
Root Agent Manages delegation and answers follow-up questions

🔹 Extractor Agent

Reads the uploaded PDF using ADK's artifact loader and returns structured JSON with:

  • Clause ID
  • Title
  • Content
  • Category (payment, termination, liability, IP, confidentiality, renewal, indemnification, warranty, general)

🔹 Risk Analyst Agent

Analyzes each clause to determine risk level (low, medium, high) with justification — such as:

  • Unlimited liability
  • Auto-renewal
  • Penalty clauses
  • Perpetual IP rights

Provides recommendations for each risk identified.

🔹 Reporter Agent

Synthesizes clause and risk data into a concise executive summary written for non-legal business audiences. It highlights risk distribution and negotiation talking points.

🔹 Root Agent

Acts as the user-facing coordinator. It:

  • Launches the pipeline automatically after PDF upload
  • Enables follow-up conversations
  • Leverages ADK memory, tools, and session state to avoid repeated processing
  • Grounds answers in the uploaded contract

🛠 Tools & Utilities

ClauseIQ uses three ADK tools to support specialized reasoning:

Tool Purpose
load_artifacts_tool Reads the uploaded contract PDF
load_memory_tool Remembers extracted clauses, risks, and summaries across queries
google_search_tool Optional external factual research if needed

By combining tools with specialized agents, ClauseIQ converts:

Contract text → Structured clauses → Risk intelligence → Business-ready insights


📋 Technical Implementation

Model Configuration

  • Model: Gemini 2.5 Flash Lite
  • Retry Configuration: 5 attempts with exponential backoff
  • HTTP Status Codes Handled: 429, 500, 503, 504

Agent Definitions

1. Extractor Agent

  • Output: JSON array of clauses
  • Categories: payment, termination, liability, IP, confidentiality, renewal, indemnification, warranty, general
  • Tools: artifacts_tool, memory_tool

2. Risk Analyst Agent

  • Output: JSON array with risk assessments
  • Risk Levels: low, medium, high
  • Analysis Factors: One-sided terms, unlimited liability/indemnity, automatic renewal, penalties, perpetual IP rights
  • Tools: memory_tool, search_tool

3. Reporter Agent

  • Output: Executive summary
  • Report Structure:
    • Overall risk rating
    • Contract overview (4-6 sentences)
    • Top critical issues (3-5 bullets)
    • Negotiation recommendations/redlines
  • Tools: memory_tool

4. Root Agent

  • Role: User-facing coordinator
  • Workflow:
    1. Call extractor_agent to obtain clauses
    2. Call risk_analyst_agent to assess risks
    3. Call reporter_agent to generate summary
  • Tools: artifacts_tool, memory_tool, AgentTools for all sub-agents

🔧 Setup Instructions

Requirements

pip install google-adk google-genai pymupdf

Environment Configuration

import os

os.environ["GOOGLE_API_KEY"] = "your_api_key"
os.environ["GOOGLE_GENAI_USE_VERTEXAI"] = "FALSE"

Creating the Agent

adk create clauseiq_agent --model gemini-2.5-flash-lite --api_key $GOOGLE_API_KEY

Running ADK Web Interface

adk web --url_prefix {url_prefix}

📊 Usage Example

  1. Upload a contract PDF through ADK Web interface
  2. Ask: "Analyze this contract and summarize the risks"
  3. Follow-up queries:
    • "Which clauses are high risk and why?"
    • "What should we renegotiate before signing?"
    • "Explain the indemnification clause"

The system maintains session memory, so follow-up questions are answered based on the already-processed contract data without re-extraction.


🚀 Value Statement

ClauseIQ reduces contract review time from hours to minutes while improving clarity and risk awareness. It empowers founders, procurement teams, and legal-ops professionals to make confident decisions without requiring a full legal review for every document.

Key Benefits

  • Time Savings – Review contracts in minutes instead of hours
  • 📉 Risk Reduction – Identify hidden liabilities automatically
  • 📈 Scalability – Handle more contracts without increasing headcount
  • 🧠 Intelligence – Data-driven insights for better negotiation

🔮 Future Enhancements

With more time, the next evolution would add a Negotiation Agent to automatically recommend redlines and generate counter-proposal text — turning contract analysis and contract negotiation into a unified AI-driven workflow.


📌 Conclusion

ClauseIQ demonstrates how multi-agent systems can transform legal and business processes. Instead of relying on a single general model, ClauseIQ divides the complex task of contract review into focused subtasks handled by dedicated agents — extraction, risk evaluation, and executive summarization — coordinated by a Root Agent.

Running on ADK Web, the system supports interactive review: users upload a contract, receive immediate insights, and ask follow-up questions without reprocessing the PDF. This modular architecture makes the system scalable, reusable, and easy to extend.


📄 License

This project is released under the Creative Commons Attribution 4.0 International (CC BY 4.0) license.


👨‍💻 Author

Nitin Dave


🔗 Quick Links

Resource Link
📓 Kaggle Notebook ClauseIQ Final Version
🎥 YouTube Demo Watch Demo
📝 Kaggle Writeup Competition Entry
🏆 Competition Track Enterprise Agents – Agents Intensive Capstone Project

About

ClauseIQ automates contract review using multi-agent AI, turning complex legal documents into clear, actionable risk insights

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors