diff --git a/submissions/contractiq-ai/README.md b/submissions/contractiq-ai/README.md new file mode 100644 index 00000000..a8c71ea7 --- /dev/null +++ b/submissions/contractiq-ai/README.md @@ -0,0 +1,190 @@ +\# ContractIQ AI + + + +ContractIQ AI is a multi-agent contract analysis system that analyzes PDF and DOCX contracts and produces a structured contract-risk report. + + + +\## What it does + + + +ContractIQ AI uses multiple specialized AI agents instead of relying on a single analysis step. + + + +The system identifies: + + + +\- Hidden charges + +\- Unfair clauses + +\- Liability risks + +\- Automatic renewal risks + +\- Data sharing risks + +\- Termination issues + +\- Confidentiality concerns + +\- Governing-law considerations + + + +It then generates: + + + +\- Contract Health Score + +\- Risk Level + +\- Contract Summary + +\- Important Clauses + +\- Risk Explanations + +\- AI Recommendations + +\- Final Verdict + +\- Suggested Improvements + + + +\## Multi-Agent Workflow + + + +The ContractIQ workflow contains seven specialized agents: + + + +1\. DocumentAgent + + - Processes the uploaded contract information. + + + +2\. RiskAgent + + - Detects legal, financial and contractual risks. + + + +3\. VerdictAgent + + - Generates an overall contract-health verdict. + + + +4\. RecommendationAgent + + - Produces actionable recommendations for identified risks. + + + +5\. EvaluationAgent + + - Evaluates the quality and completeness of the analysis. + + + +6\. DiagnoseAgent + + - Diagnoses weaknesses or missing information in the generated analysis. + + + +7\. OptimizeAgent + + - Combines the available agent outputs and generates the final structured report. + + + +\## Agent Lifecycle + + + +The workflow follows the lifecycle: + + + +SPEC → BUILD → EVALUATE → DIAGNOSE → OPTIMIZE + + + +The final OptimizeAgent produces the final report from the accumulated agent context. + + + +\## Final Report + + + +The final report contains: + + + +\- riskScore + +\- riskLevel + +\- summary + +\- importantClauses + +\- risks + +\- recommendations + +\- finalVerdict + +\- improvementsMade + + + +\## Example Contract Risks + + + +The system has been tested on service agreements containing: + + + +\- Late payment penalties + +\- Automatic renewal clauses + +\- Limitation of liability + +\- Third-party data sharing + +\- Termination conditions + +\- Confidentiality obligations + +\- Governing-law clauses + + + +\## How to Run + + + +The original ContractIQ AI application can be run using: + + + +```bash + +npm install + +npm run dev + diff --git a/submissions/contractiq-ai/agents/DocumentAgent.ts b/submissions/contractiq-ai/agents/DocumentAgent.ts new file mode 100644 index 00000000..d76c33c0 --- /dev/null +++ b/submissions/contractiq-ai/agents/DocumentAgent.ts @@ -0,0 +1,24 @@ +export class DocumentAgent { + + name = "DocumentAgent"; + + + async run(context:any){ + + return { + ...context, + + document:{ + filename: context.filename, + text: context.contractText, + status:"Extracted Successfully" + } + + }; + + } + +} + + +export default DocumentAgent; \ No newline at end of file diff --git a/submissions/contractiq-ai/agents/EvaluationAgent.ts b/submissions/contractiq-ai/agents/EvaluationAgent.ts new file mode 100644 index 00000000..298f6a30 --- /dev/null +++ b/submissions/contractiq-ai/agents/EvaluationAgent.ts @@ -0,0 +1,71 @@ +import { callOpenRouter } from "@/runtime/openRouterClient"; + + +class EvaluationAgent { + + name = "EvaluationAgent"; + + + async run(context:any){ + + const prompt = ` +You are EvaluationAgent of ContractIQ AI. + +Evaluate the generated contract analysis report. + +Check: + +1. Risk Detection Quality +2. Clause Coverage +3. Verdict Accuracy +4. Recommendation Quality +5. Report Completeness + + +Previous Analysis: + +Risk: +${context.riskAnalysis} + + +Verdict: +${context.verdictAnalysis} + + +Recommendations: +${context.recommendationAnalysis} + + +Return ONLY JSON. + +Format: + +{ + "qualityScore":0, + "issues":[ + "" + ], + "evaluation":"" +} + +qualityScore should be between 0-100. + +`; + + const result = await callOpenRouter(prompt); + + + return { + + ...context, + + evaluationAnalysis: result + + }; + + } + +} + + +export default EvaluationAgent; \ No newline at end of file diff --git a/submissions/contractiq-ai/agents/RecommendationAgent.ts b/submissions/contractiq-ai/agents/RecommendationAgent.ts new file mode 100644 index 00000000..e802a75f --- /dev/null +++ b/submissions/contractiq-ai/agents/RecommendationAgent.ts @@ -0,0 +1,66 @@ +import { callOpenRouter } from "@/runtime/openRouterClient"; + + +class RecommendationAgent { + + name = "RecommendationAgent"; + + + async run(context:any){ + + const prompt = ` +You are RecommendationAgent of ContractIQ AI. + +Generate legal recommendations based on the risk analysis and verdict. + +Risk Analysis: + +${context.riskAnalysis} + + +Verdict: + +${context.verdictAnalysis} + + +Generate: +- Risk specific recommendations +- Contract improvement suggestions +- Safer alternatives + + +Return ONLY JSON. + +Format: + +{ + "recommendations":[ + "" + ], + "improvements":[ + "" + ] +} + +Generate 4-6 useful recommendations. +Avoid repeating the same suggestion. + +`; + + const result = await callOpenRouter(prompt); + + + return { + + ...context, + + recommendationAnalysis: result + + }; + + } + +} + + +export default RecommendationAgent; \ No newline at end of file diff --git a/submissions/contractiq-ai/agents/RiskAgent.ts b/submissions/contractiq-ai/agents/RiskAgent.ts new file mode 100644 index 00000000..86bd394a --- /dev/null +++ b/submissions/contractiq-ai/agents/RiskAgent.ts @@ -0,0 +1,64 @@ +import { callOpenRouter } from "@/runtime/openRouterClient"; + +class RiskAgent { + + name = "RiskAgent"; + + + async run(context:any){ + + const prompt = ` +You are RiskAgent of ContractIQ AI. + +Analyze the contract and identify legal risks. + +Find: +- Hidden charges +- Unfair clauses +- Liability issues +- Auto renewal risks +- Data sharing risks +- Termination problems + + +Contract: + +${context.contractText} + + +Return ONLY JSON. + +Format: + +{ + "riskScore":0, + "riskLevel":"", + "risks":[ + { + "title":"", + "description":"", + "severity":"", + "recommendation":"" + } + ] +} + +`; + + + const result = await callOpenRouter(prompt); + +console.log("========== RiskAgent =========="); +console.log(result); + +return { + ...context, + riskAnalysis: result, + risk: result +}; + } + +} + + +export default RiskAgent; \ No newline at end of file diff --git a/submissions/contractiq-ai/agents/VerdictAgent.ts b/submissions/contractiq-ai/agents/VerdictAgent.ts new file mode 100644 index 00000000..11a88b41 --- /dev/null +++ b/submissions/contractiq-ai/agents/VerdictAgent.ts @@ -0,0 +1,72 @@ +import { callOpenRouter } from "@/runtime/openRouterClient"; + + +class VerdictAgent { + + name = "VerdictAgent"; + + + async run(context:any){ + + const prompt = ` +You are VerdictAgent of ContractIQ AI. + +Based on the contract risk analysis, generate a contract health verdict. + +Analyze: + +${JSON.stringify(context.riskAnalysis || context.risk)} + + +Return ONLY JSON. + +Format: + +{ + "healthScore":0, + "verdict":"", + "explanation":"" +} + +Verdict must be one of: + +Safe to Sign +Review Before Signing +High Risk - Legal Review Recommended + +`; + + let result = ""; + +try { + + result = await callOpenRouter(prompt); + +} +catch(error){ + + console.log("VerdictAgent failed:", error); + + result = JSON.stringify({ + healthScore: 50, + verdict: "Review Before Signing", + explanation: "Contract requires manual review." + }); + +} + + +console.log("========== VerdictAgent =========="); +console.log(result); + + +return { + ...context, + verdictAnalysis: result, +}; + } + +} + + +export default VerdictAgent; \ No newline at end of file diff --git a/submissions/contractiq-ai/agents/diagnoseAgent.ts b/submissions/contractiq-ai/agents/diagnoseAgent.ts new file mode 100644 index 00000000..f9455e72 --- /dev/null +++ b/submissions/contractiq-ai/agents/diagnoseAgent.ts @@ -0,0 +1,64 @@ +import { callOpenRouter } from "@/runtime/openRouterClient"; + + +class DiagnoseAgent { + + name = "DiagnoseAgent"; + + + async run(context:any){ + + const prompt = ` +You are DiagnoseAgent of ContractIQ AI. + +Analyze the evaluation report and diagnose weaknesses. + +Find: + +- Missing contract clauses +- Weak risk explanations +- Poor recommendations +- Incomplete analysis +- Possible AI mistakes + + +Evaluation Report: + +${context.evaluationAnalysis} + + +Return ONLY JSON. + +Format: + +{ + "problems":[ + "" + ], + "missingInformation":[ + "" + ], + "improvementPlan":[ + "" + ] +} + +`; + + const result = await callOpenRouter(prompt); + + + return { + + ...context, + + diagnosisAnalysis: result + + }; + + } + +} + + +export default DiagnoseAgent; \ No newline at end of file diff --git a/submissions/contractiq-ai/agents/optimizeAgent.ts b/submissions/contractiq-ai/agents/optimizeAgent.ts new file mode 100644 index 00000000..589b458d --- /dev/null +++ b/submissions/contractiq-ai/agents/optimizeAgent.ts @@ -0,0 +1,99 @@ +import { callOpenRouter } from "@/runtime/openRouterClient"; + + +class OptimizeAgent { + + name = "OptimizeAgent"; + + + async run(context:any){ + +const prompt = ` +You are OptimizeAgent of ContractIQ AI. + +Generate the final contract analysis report. + +Here is the complete agent context: + +${JSON.stringify(context, null, 2)} + +Use available information from: +- Risk Analysis +- Diagnosis +- Verdict +- Recommendations + +Do not ask for missing data. +If any field is missing, make a reasonable analysis from available contract information. + +Return ONLY JSON. + +Format: + +{ +"riskScore":0, +"riskLevel":"", +"summary":"", +"importantClauses":[ + { + "title":"", + "description":"" + } +], +"risks":[], +"recommendations":[], +"finalVerdict":"", +"improvementsMade":[] +} + +Important Clauses Instructions: + +Extract important clauses from the contract. + +Important Clauses must not be empty. + +Include: +- Payment Terms +- Termination Clause +- Liability Clause +- Confidentiality Clause +- Data Sharing Clause +- Auto Renewal Clause +- Governing Law Clause + +Each clause must contain EXACTLY: + +{ +"title":"Clause name", +"clause":"Original or summarized contract clause" +} +Do NOT use the field "description". +Always use the field "clause". +Do not return blank values. +"finalVerdict":"", +"improvementsMade":[] +} + +Final Verdict must be one of: + +Safe to Sign + +Review Before Signing + +High Risk - Legal Review Recommended +`; + +const result = await callOpenRouter(prompt); + +console.log("===== OptimizeAgent ====="); +console.log(result); + +return { + finalReport: result +}; + +} +} + + +export default OptimizeAgent; \ No newline at end of file diff --git a/submissions/contractiq-ai/agentspec.yaml b/submissions/contractiq-ai/agentspec.yaml new file mode 100644 index 00000000..d8bb4d06 --- /dev/null +++ b/submissions/contractiq-ai/agentspec.yaml @@ -0,0 +1,19 @@ +name: ContractIQ AI + +goal: Review legal contracts autonomously. + +input: + - PDF + - DOCX + +tasks: + - Extract Text + - Detect Risks + - Extract Clauses + - Generate Recommendations + - Produce Verdict + - Evaluate Report + - Optimize Report + +output: + - JSON Report \ No newline at end of file diff --git a/submissions/contractiq-ai/contract-analysis-eval.md b/submissions/contractiq-ai/contract-analysis-eval.md new file mode 100644 index 00000000..a8c71ea7 --- /dev/null +++ b/submissions/contractiq-ai/contract-analysis-eval.md @@ -0,0 +1,190 @@ +\# ContractIQ AI + + + +ContractIQ AI is a multi-agent contract analysis system that analyzes PDF and DOCX contracts and produces a structured contract-risk report. + + + +\## What it does + + + +ContractIQ AI uses multiple specialized AI agents instead of relying on a single analysis step. + + + +The system identifies: + + + +\- Hidden charges + +\- Unfair clauses + +\- Liability risks + +\- Automatic renewal risks + +\- Data sharing risks + +\- Termination issues + +\- Confidentiality concerns + +\- Governing-law considerations + + + +It then generates: + + + +\- Contract Health Score + +\- Risk Level + +\- Contract Summary + +\- Important Clauses + +\- Risk Explanations + +\- AI Recommendations + +\- Final Verdict + +\- Suggested Improvements + + + +\## Multi-Agent Workflow + + + +The ContractIQ workflow contains seven specialized agents: + + + +1\. DocumentAgent + + - Processes the uploaded contract information. + + + +2\. RiskAgent + + - Detects legal, financial and contractual risks. + + + +3\. VerdictAgent + + - Generates an overall contract-health verdict. + + + +4\. RecommendationAgent + + - Produces actionable recommendations for identified risks. + + + +5\. EvaluationAgent + + - Evaluates the quality and completeness of the analysis. + + + +6\. DiagnoseAgent + + - Diagnoses weaknesses or missing information in the generated analysis. + + + +7\. OptimizeAgent + + - Combines the available agent outputs and generates the final structured report. + + + +\## Agent Lifecycle + + + +The workflow follows the lifecycle: + + + +SPEC → BUILD → EVALUATE → DIAGNOSE → OPTIMIZE + + + +The final OptimizeAgent produces the final report from the accumulated agent context. + + + +\## Final Report + + + +The final report contains: + + + +\- riskScore + +\- riskLevel + +\- summary + +\- importantClauses + +\- risks + +\- recommendations + +\- finalVerdict + +\- improvementsMade + + + +\## Example Contract Risks + + + +The system has been tested on service agreements containing: + + + +\- Late payment penalties + +\- Automatic renewal clauses + +\- Limitation of liability + +\- Third-party data sharing + +\- Termination conditions + +\- Confidentiality obligations + +\- Governing-law clauses + + + +\## How to Run + + + +The original ContractIQ AI application can be run using: + + + +```bash + +npm install + +npm run dev + diff --git a/submissions/contractiq-ai/evals/contract-analysis-eval.md b/submissions/contractiq-ai/evals/contract-analysis-eval.md new file mode 100644 index 00000000..568b7b22 --- /dev/null +++ b/submissions/contractiq-ai/evals/contract-analysis-eval.md @@ -0,0 +1,18 @@ +ContractIQ AI Evaluation + +## Goal +Evaluate the multi-agent contract analysis workflow. + +## Test Contract +The test contract contains late payment penalties, automatic renewal, limitation of liability, third-party data sharing, termination, confidentiality and governing law clauses. + +## Expected Behavior +- Identify contractual risks. +- Assign risk severity. +- Extract important clauses. +- Generate recommendations. +- Generate a final verdict. +- Generate suggested improvements. + +## Result +PASS diff --git a/submissions/contractiq-ai/mutagent/README.md b/submissions/contractiq-ai/mutagent/README.md new file mode 100644 index 00000000..88d08588 --- /dev/null +++ b/submissions/contractiq-ai/mutagent/README.md @@ -0,0 +1,151 @@ +# ⚖️ ContractIQ AI + +> AI-powered Multi-Agent Legal Contract Review System + +Built for **HackIndia** using a **Mutagent-inspired Multi-Agent Architecture**. + +--- + +# 🚀 Overview + +ContractIQ AI helps users understand legal contracts before signing them. + +Instead of using a single AI prompt, ContractIQ AI divides the work across specialized AI agents coordinated by a Helix Orchestrator. + +The system automatically: + +- 📄 Reads contracts +- ⚠ Detects legal risks +- 📌 Extracts important clauses +- ⚖ Generates legal verdict +- 💡 Suggests improvements +- 📊 Evaluates report quality +- 📥 Exports professional PDF reports + +--- + +# 🧠 Multi-Agent Architecture + +``` + User Upload + │ + ▼ + 📄 DocumentAgent + │ + ▼ + ⚠ RiskAgent + │ + ▼ + ⚖ VerdictAgent + │ + ▼ + 💡 RecommendationAgent + │ + ▼ + ✅ EvaluationAgent + │ + ▼ + 📑 Final Report +``` + +--- + +# 🤖 AI Agents + +## 📄 DocumentAgent + +- Reads PDF / DOCX +- Extracts contract text +- Prepares structured input + +--- + +## ⚠ RiskAgent + +Detects: + +- Hidden Charges +- Auto Renewal +- Liability +- Penalty Clauses +- Data Sharing +- Termination Clauses + +--- + +## ⚖ VerdictAgent + +Generates + +- Contract Health Score +- Risk Level +- Final Legal Verdict + +--- + +## 💡 RecommendationAgent + +Provides practical legal suggestions to reduce contractual risks. + +--- + +## ✅ EvaluationAgent + +Evaluates report quality using: + +- Clause Coverage +- Recommendation Quality +- Risk Detection Accuracy +- Report Completeness + +--- + +# 🏗 Technology Stack + +- Next.js +- React +- TypeScript +- Firebase +- Google Gemini AI +- Tailwind CSS +- jsPDF +- Mutagent-inspired Multi-Agent Architecture + +--- + +# ✨ Features + +- AI Contract Analysis +- Contract Health Score +- Risk Classification +- Important Clause Extraction +- AI Recommendations +- PDF Report Generation +- Firebase Report Storage +- Multi-Agent Workflow + +--- + +# 📸 Screenshots + +(Add screenshots here) + +--- + +# 🔮 Future Scope + +- Self-Improving AI Agents +- Continuous Evaluation Loop +- Prompt Optimization +- Enterprise Compliance Checking +- Multi-language Legal Analysis + +--- + +# 👨‍💻 Team + +HackIndia Submission + +Project Name: + +## ContractIQ AI diff --git a/submissions/contractiq-ai/mutagent/agents/DocumentAgent.ts b/submissions/contractiq-ai/mutagent/agents/DocumentAgent.ts new file mode 100644 index 00000000..d76c33c0 --- /dev/null +++ b/submissions/contractiq-ai/mutagent/agents/DocumentAgent.ts @@ -0,0 +1,24 @@ +export class DocumentAgent { + + name = "DocumentAgent"; + + + async run(context:any){ + + return { + ...context, + + document:{ + filename: context.filename, + text: context.contractText, + status:"Extracted Successfully" + } + + }; + + } + +} + + +export default DocumentAgent; \ No newline at end of file diff --git a/submissions/contractiq-ai/mutagent/agents/EvaluationAgent.ts b/submissions/contractiq-ai/mutagent/agents/EvaluationAgent.ts new file mode 100644 index 00000000..298f6a30 --- /dev/null +++ b/submissions/contractiq-ai/mutagent/agents/EvaluationAgent.ts @@ -0,0 +1,71 @@ +import { callOpenRouter } from "@/runtime/openRouterClient"; + + +class EvaluationAgent { + + name = "EvaluationAgent"; + + + async run(context:any){ + + const prompt = ` +You are EvaluationAgent of ContractIQ AI. + +Evaluate the generated contract analysis report. + +Check: + +1. Risk Detection Quality +2. Clause Coverage +3. Verdict Accuracy +4. Recommendation Quality +5. Report Completeness + + +Previous Analysis: + +Risk: +${context.riskAnalysis} + + +Verdict: +${context.verdictAnalysis} + + +Recommendations: +${context.recommendationAnalysis} + + +Return ONLY JSON. + +Format: + +{ + "qualityScore":0, + "issues":[ + "" + ], + "evaluation":"" +} + +qualityScore should be between 0-100. + +`; + + const result = await callOpenRouter(prompt); + + + return { + + ...context, + + evaluationAnalysis: result + + }; + + } + +} + + +export default EvaluationAgent; \ No newline at end of file diff --git a/submissions/contractiq-ai/mutagent/agents/RecommendationAgent.ts b/submissions/contractiq-ai/mutagent/agents/RecommendationAgent.ts new file mode 100644 index 00000000..e802a75f --- /dev/null +++ b/submissions/contractiq-ai/mutagent/agents/RecommendationAgent.ts @@ -0,0 +1,66 @@ +import { callOpenRouter } from "@/runtime/openRouterClient"; + + +class RecommendationAgent { + + name = "RecommendationAgent"; + + + async run(context:any){ + + const prompt = ` +You are RecommendationAgent of ContractIQ AI. + +Generate legal recommendations based on the risk analysis and verdict. + +Risk Analysis: + +${context.riskAnalysis} + + +Verdict: + +${context.verdictAnalysis} + + +Generate: +- Risk specific recommendations +- Contract improvement suggestions +- Safer alternatives + + +Return ONLY JSON. + +Format: + +{ + "recommendations":[ + "" + ], + "improvements":[ + "" + ] +} + +Generate 4-6 useful recommendations. +Avoid repeating the same suggestion. + +`; + + const result = await callOpenRouter(prompt); + + + return { + + ...context, + + recommendationAnalysis: result + + }; + + } + +} + + +export default RecommendationAgent; \ No newline at end of file diff --git a/submissions/contractiq-ai/mutagent/agents/RiskAgent.ts b/submissions/contractiq-ai/mutagent/agents/RiskAgent.ts new file mode 100644 index 00000000..86bd394a --- /dev/null +++ b/submissions/contractiq-ai/mutagent/agents/RiskAgent.ts @@ -0,0 +1,64 @@ +import { callOpenRouter } from "@/runtime/openRouterClient"; + +class RiskAgent { + + name = "RiskAgent"; + + + async run(context:any){ + + const prompt = ` +You are RiskAgent of ContractIQ AI. + +Analyze the contract and identify legal risks. + +Find: +- Hidden charges +- Unfair clauses +- Liability issues +- Auto renewal risks +- Data sharing risks +- Termination problems + + +Contract: + +${context.contractText} + + +Return ONLY JSON. + +Format: + +{ + "riskScore":0, + "riskLevel":"", + "risks":[ + { + "title":"", + "description":"", + "severity":"", + "recommendation":"" + } + ] +} + +`; + + + const result = await callOpenRouter(prompt); + +console.log("========== RiskAgent =========="); +console.log(result); + +return { + ...context, + riskAnalysis: result, + risk: result +}; + } + +} + + +export default RiskAgent; \ No newline at end of file diff --git a/submissions/contractiq-ai/mutagent/agents/VerdictAgent.ts b/submissions/contractiq-ai/mutagent/agents/VerdictAgent.ts new file mode 100644 index 00000000..11a88b41 --- /dev/null +++ b/submissions/contractiq-ai/mutagent/agents/VerdictAgent.ts @@ -0,0 +1,72 @@ +import { callOpenRouter } from "@/runtime/openRouterClient"; + + +class VerdictAgent { + + name = "VerdictAgent"; + + + async run(context:any){ + + const prompt = ` +You are VerdictAgent of ContractIQ AI. + +Based on the contract risk analysis, generate a contract health verdict. + +Analyze: + +${JSON.stringify(context.riskAnalysis || context.risk)} + + +Return ONLY JSON. + +Format: + +{ + "healthScore":0, + "verdict":"", + "explanation":"" +} + +Verdict must be one of: + +Safe to Sign +Review Before Signing +High Risk - Legal Review Recommended + +`; + + let result = ""; + +try { + + result = await callOpenRouter(prompt); + +} +catch(error){ + + console.log("VerdictAgent failed:", error); + + result = JSON.stringify({ + healthScore: 50, + verdict: "Review Before Signing", + explanation: "Contract requires manual review." + }); + +} + + +console.log("========== VerdictAgent =========="); +console.log(result); + + +return { + ...context, + verdictAnalysis: result, +}; + } + +} + + +export default VerdictAgent; \ No newline at end of file diff --git a/submissions/contractiq-ai/mutagent/agents/diagnoseAgent.ts b/submissions/contractiq-ai/mutagent/agents/diagnoseAgent.ts new file mode 100644 index 00000000..f9455e72 --- /dev/null +++ b/submissions/contractiq-ai/mutagent/agents/diagnoseAgent.ts @@ -0,0 +1,64 @@ +import { callOpenRouter } from "@/runtime/openRouterClient"; + + +class DiagnoseAgent { + + name = "DiagnoseAgent"; + + + async run(context:any){ + + const prompt = ` +You are DiagnoseAgent of ContractIQ AI. + +Analyze the evaluation report and diagnose weaknesses. + +Find: + +- Missing contract clauses +- Weak risk explanations +- Poor recommendations +- Incomplete analysis +- Possible AI mistakes + + +Evaluation Report: + +${context.evaluationAnalysis} + + +Return ONLY JSON. + +Format: + +{ + "problems":[ + "" + ], + "missingInformation":[ + "" + ], + "improvementPlan":[ + "" + ] +} + +`; + + const result = await callOpenRouter(prompt); + + + return { + + ...context, + + diagnosisAnalysis: result + + }; + + } + +} + + +export default DiagnoseAgent; \ No newline at end of file diff --git a/submissions/contractiq-ai/mutagent/agents/optimizeAgent.ts b/submissions/contractiq-ai/mutagent/agents/optimizeAgent.ts new file mode 100644 index 00000000..589b458d --- /dev/null +++ b/submissions/contractiq-ai/mutagent/agents/optimizeAgent.ts @@ -0,0 +1,99 @@ +import { callOpenRouter } from "@/runtime/openRouterClient"; + + +class OptimizeAgent { + + name = "OptimizeAgent"; + + + async run(context:any){ + +const prompt = ` +You are OptimizeAgent of ContractIQ AI. + +Generate the final contract analysis report. + +Here is the complete agent context: + +${JSON.stringify(context, null, 2)} + +Use available information from: +- Risk Analysis +- Diagnosis +- Verdict +- Recommendations + +Do not ask for missing data. +If any field is missing, make a reasonable analysis from available contract information. + +Return ONLY JSON. + +Format: + +{ +"riskScore":0, +"riskLevel":"", +"summary":"", +"importantClauses":[ + { + "title":"", + "description":"" + } +], +"risks":[], +"recommendations":[], +"finalVerdict":"", +"improvementsMade":[] +} + +Important Clauses Instructions: + +Extract important clauses from the contract. + +Important Clauses must not be empty. + +Include: +- Payment Terms +- Termination Clause +- Liability Clause +- Confidentiality Clause +- Data Sharing Clause +- Auto Renewal Clause +- Governing Law Clause + +Each clause must contain EXACTLY: + +{ +"title":"Clause name", +"clause":"Original or summarized contract clause" +} +Do NOT use the field "description". +Always use the field "clause". +Do not return blank values. +"finalVerdict":"", +"improvementsMade":[] +} + +Final Verdict must be one of: + +Safe to Sign + +Review Before Signing + +High Risk - Legal Review Recommended +`; + +const result = await callOpenRouter(prompt); + +console.log("===== OptimizeAgent ====="); +console.log(result); + +return { + finalReport: result +}; + +} +} + + +export default OptimizeAgent; \ No newline at end of file diff --git a/submissions/contractiq-ai/mutagent/agentspec.yaml b/submissions/contractiq-ai/mutagent/agentspec.yaml new file mode 100644 index 00000000..d8bb4d06 --- /dev/null +++ b/submissions/contractiq-ai/mutagent/agentspec.yaml @@ -0,0 +1,19 @@ +name: ContractIQ AI + +goal: Review legal contracts autonomously. + +input: + - PDF + - DOCX + +tasks: + - Extract Text + - Detect Risks + - Extract Clauses + - Generate Recommendations + - Produce Verdict + - Evaluate Report + - Optimize Report + +output: + - JSON Report \ No newline at end of file diff --git a/submissions/contractiq-ai/mutagent/dataset/evaluation-dataset.md b/submissions/contractiq-ai/mutagent/dataset/evaluation-dataset.md new file mode 100644 index 00000000..f5fa5319 --- /dev/null +++ b/submissions/contractiq-ai/mutagent/dataset/evaluation-dataset.md @@ -0,0 +1,32 @@ +# ContractIQ AI Evaluation Dataset + +| ID | Contract Type | Expected Risk | +|----|---------------|---------------| +| 1 | Employment Agreement | Medium | +| 2 | Rental Agreement | High | +| 3 | NDA | Low | +| 4 | Freelancer Contract | Medium | +| 5 | Vendor Agreement | High | +| 6 | Service Agreement | Medium | +| 7 | Internship Offer | Low | +| 8 | Purchase Agreement | High | +| 9 | SaaS Agreement | High | +|10 | Partnership Agreement | High | +|11 | Lease Agreement | Medium | +|12 | Employment Offer | Medium | +|13 | Privacy Policy | Medium | +|14 | Subscription Contract | High | +|15 | Consulting Agreement | Medium | +|16 | Licensing Agreement | High | +|17 | Shareholder Agreement | High | +|18 | Loan Agreement | High | +|19 | Insurance Policy | Medium | +|20 | General Terms & Conditions | Medium | + +Evaluation Criteria + +- Risk Detection Accuracy +- Recommendation Quality +- Clause Extraction +- Overall Verdict Accuracy +- Report Completeness \ No newline at end of file diff --git a/submissions/contractiq-ai/mutagent/feedback.md b/submissions/contractiq-ai/mutagent/feedback.md new file mode 100644 index 00000000..eac04e14 --- /dev/null +++ b/submissions/contractiq-ai/mutagent/feedback.md @@ -0,0 +1,14 @@ +# Product Feedback + +Strengths + +- Easy multi-agent architecture +- Clear ADL workflow +- Simple orchestration + +Suggested Improvements + +- Official Next.js examples +- Better TypeScript templates +- Built-in PDF parser +- Native evaluation dashboard \ No newline at end of file diff --git a/submissions/contractiq-ai/mutagent/prompts/legal-agent.md b/submissions/contractiq-ai/mutagent/prompts/legal-agent.md new file mode 100644 index 00000000..fa5c506d --- /dev/null +++ b/submissions/contractiq-ai/mutagent/prompts/legal-agent.md @@ -0,0 +1,24 @@ +# ContractIQ AI Legal Agent Prompt + +You are an autonomous AI Legal Contract Review Agent. + +Your objectives: + +1. Read uploaded contracts. +2. Detect risky clauses. +3. Assign severity. +4. Explain every legal risk. +5. Suggest practical recommendations. +6. Produce a final legal verdict. +7. Evaluate your own analysis. +8. Improve the report if critical clauses are missing. + +Output must always contain: + +- Risk Score +- Risk Level +- Summary +- Risks +- Important Clauses +- Recommendations +- Verdict \ No newline at end of file diff --git a/submissions/contractiq-ai/mutagent/sessions/session-001.md b/submissions/contractiq-ai/mutagent/sessions/session-001.md new file mode 100644 index 00000000..9888e19c --- /dev/null +++ b/submissions/contractiq-ai/mutagent/sessions/session-001.md @@ -0,0 +1,37 @@ +# Session 001 + +User Action + +Uploaded Service Agreement.pdf + +↓ + +Document Agent + +Extracted contract text + +↓ + +Risk Agent + +Detected: + +- Automatic Renewal +- Late Payment Penalty +- Limited Liability + +↓ + +Recommendation Agent + +Generated mitigation steps + +↓ + +Verdict Agent + +Review Before Signing + +Status + +Completed Successfully \ No newline at end of file diff --git a/submissions/contractiq-ai/mutagent/transcripts/session.md b/submissions/contractiq-ai/mutagent/transcripts/session.md new file mode 100644 index 00000000..29166423 --- /dev/null +++ b/submissions/contractiq-ai/mutagent/transcripts/session.md @@ -0,0 +1,35 @@ +# Mutagent Session + +Command: + +*spec + +Generated ContractIQ AI specification. + +Command: + +*build + +Implemented Multi-Agent architecture. + +Command: + +*evaluate + +Generated evaluation score. + +Command: + +*diagnose + +Detected recommendation improvements. + +Command: + +*optimize + +Optimized recommendations. + +Status + +PASS \ No newline at end of file diff --git a/submissions/contractiq-ai/mutagent/workflow.md b/submissions/contractiq-ai/mutagent/workflow.md new file mode 100644 index 00000000..ef012712 --- /dev/null +++ b/submissions/contractiq-ai/mutagent/workflow.md @@ -0,0 +1,161 @@ +# ContractIQ AI - Multi-Agent Workflow + +## Overview + +ContractIQ AI follows the complete Mutagent Agentic Development Lifecycle (ADL). + +Instead of relying on a single LLM response, ContractIQ AI coordinates multiple specialized AI agents using the Helix Orchestrator. + +The system continuously evaluates, diagnoses and improves the generated legal report before presenting the final output. + +--- + +# ADL Lifecycle + +```text +SPEC + ↓ +BUILD + ↓ +EVALUATE + ↓ +DIAGNOSE + ↓ +OPTIMIZE +``` + +--- + +# Contract Review Workflow + +```text + User Uploads Contract + │ + ▼ + 📄 DocumentAgent + Extracts text from PDF/DOCX + │ + ▼ + ⚠ RiskAgent + Detects legal risks & clauses + │ + ▼ + ⚖ VerdictAgent + Calculates Contract Health Score + │ + ▼ + 💡 RecommendationAgent + Generates legal recommendations + │ + ▼ + ✅ EvaluationAgent + Evaluates report quality + │ + ▼ + 🔍 DiagnoseAgent + Detects weak summaries, missing clauses, + incomplete recommendations and AI errors + │ + ▼ + 🚀 OptimizeAgent + Improves prompts and regenerates analysis + │ + ▼ + 📑 Final Report +``` + +--- + +# Agent Responsibilities + +## 📄 DocumentAgent + +- Reads uploaded contracts +- Extracts structured text +- Supports PDF & DOCX + +--- + +## ⚠ RiskAgent + +- Detects risky clauses +- Identifies liabilities +- Finds hidden penalties +- Calculates Risk Score + +--- + +## ⚖ VerdictAgent + +- Calculates Contract Health Score +- Produces final legal verdict + +Safe + +Review Required + +High Risk + +--- + +## 💡 RecommendationAgent + +- Suggests safer alternatives +- Explains legal implications +- Improves contract quality + +--- + +## ✅ EvaluationAgent + +Evaluates + +- Clause Coverage +- Risk Detection +- Recommendation Quality +- Report Completeness + +--- + +## 🔍 DiagnoseAgent + +Checks + +- Missing clauses +- Weak summaries +- Poor recommendations +- Incomplete analysis + +--- + +## 🚀 OptimizeAgent + +Automatically + +- Improves prompts +- Re-runs analysis +- Produces better report + +--- + +# Helix Orchestrator + +Execution Order + +1. DocumentAgent +2. RiskAgent +3. VerdictAgent +4. RecommendationAgent +5. EvaluationAgent +6. DiagnoseAgent +7. OptimizeAgent + +--- + +# Future Roadmap + +- Self-Healing Agents +- Multi-language Contracts +- Compliance Checker +- Organization Policy Validation +- Autonomous Prompt Evolution \ No newline at end of file