{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# LangGraph-Based Systems Inspector using LangGraph\n", "\n", "## Overview\n", "The LangGraph-Based Systems Inspector is a tool designed to help developers create more secure and robust agent-based applications using LangGraph. It offers valuable insights into system architectures and helps identify potential vulnerabilities, addressing the unique challenges associated with developing LangGraph systems. By using this tool, developers can enhance the quality of their projects and ensure a more secure foundation for multi-agent applications.\n", "\n", "## Motivation\n", "The adoption of multi-agent systems with LangGraph brings opportunities and challenges, such as security concerns like prompt injection and understanding complex workflows. This project helps developers secure their systems and improve reliability by analyzing system architecture and highlighting weaknesses. \n", "\n", "This project also takes inspiration from the LangChain project [SCIPE - Systematic Chain Improvement and Problem Evaluation](https://blog.langchain.dev/scipe-systematic-chain-improvement-and-problem-evaluation/), which analyzes independent and dependent failure probabilities to identify the most impactful problematic node in the system.\n", "\n", "\n", "## Key Components\n", "1. **LangGraph and LangCHain**: Orchestrates the multi-agent systems, managing the flow of data between agents.\n", "2. **LLM model**: Generates tester agents, creates test cases, and analyzes results to ensure system robustness.\n", "3. **Pydantic**: Validates data and parses output from the LLM model, ensuring data consistency and reliability.\n", "4. **Jinja2**: Provides robust templating for prompt creation, enhancing flexibility and reusability.\n", "5. **Networkx**: Provides a simplified representation of the system, illustrating agent relationships, properties, and data flow.\n", "6. **Gradio**: Displays results through an interactive user interface, making the system accessible and easy to understand.\n", "\n", "## Method\n", "This is the general workflow of the LangGraph-Based Systems Inspector from user input to insights:\n", "\n", "1. **User Input**: The user provides:\n", " 1. LangGraph target system before compilation.\n", " 2. Description of the system's behavior.\n", " 3. Valid input sample to pass through the \"invoke\" function.\n", "\n", "2. **Gather Information**: The system extracts information from the LangGraph target system object:\n", " 1. Retrieve all nodes, edges, and tools.\n", " 2. Invoke the graph to get all node inputs and outputs.\n", " 3. Generate node descriptions.\n", "\n", "3. **Generate Tester Agents**: The system generates diverse tester agents to test the system's robustness.\n", "\n", "4. **Generate Test Cases**: Each tester agent generates test cases based on node descriptions and input/output data.\n", "\n", "5. **Run Test Cases**: Verify the test cases by running them through the system.\n", " 1. Create valid input for each test case.\n", " 2. Invoke the target system with the new valid inputs.\n", " 3. Save all thread IDs to retrieve the output later.\n", "\n", "6. **Analyze Results**: The system analyzes all outputs against acceptance criteria and creates insights.\n", "\n", "\n", "## Conclusion\n", "\n", "The LangGraph-Based Systems Inspector provides developers with an effective way to enhance the security and reliability of LangGraph-based applications. By automating system architecture analysis and identifying vulnerabilities, it helps tackle key challenges in developing robust multi-agent systems.\n", "\n", "Moving forward, this tool could be expanded to include more advanced performance optimizations, user-friendly interactions, and integration with additional AI analysis tools. As LangGraph evolves, tools like this will be essential for ensuring that complex agent-based applications are both secure and efficient." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## System Workflow\n", "\n", "