| Dimension | Shared | Only in A | Only in B | Overlap |
|---|---|---|---|---|
| Sections | 0 | 7 | 4 | 0% |
| Commands | 0 | 0 | 0 | — |
| Section tags | 0 | 1 | 2 | 0% |
What each file covers
Sections
0 shared · 7 only in A · 4 only in B- − LangGraph.js
- − Overview
- − Core Concepts
- − Key Features
- − Development Practices
- − Deployment
- − Relevant Files in this Project
- + Memory Management Guidelines
- + Purpose of Memory
- + Implementation Details (`src/memory/`)
- + Best Practices for Memory
Commands
neither file has anySection tags
0 shared · 1 only in A · 2 only in B- − architecture
- + code-style
- + performance
Line diff
ssdeanx/langgraph-dm · .clinerules/langgraphjs.md
@@ −1 @@
1---
2glob: "**/*.ts"
3description: "Langgraphjs Architecture"
4---
5# LangGraph.js
6
7## Overview
8
9LangGraph.js is a powerful library for building stateful, multi-actor AI applications with Large Language Models (LLMs). It allows you to model complex agent workflows as graphs, where nodes represent individual steps or agents and edges define the flow of information and control.
10
11## Core Concepts
12
13* **StateGraph:** The primary class for defining graph-based workflows. It manages the shared state that is passed between nodes.
14* **Nodes:** Functions or runnable components that perform specific tasks and update the graph's state.
15* **Edges:** Define transitions between nodes, which can be unconditional or conditional based on the current state.
16* **State:** A shared data structure (`AgentState`) that represents the current context of the application, updated by nodes and passed along edges.
17* **Checkpoints:** Snapshots of the graph's state saved at various points, enabling persistence, debugging, and human-in-the-loop interactions.
18* **Subgraphs:** The ability to embed one graph as a node within another, promoting modularity and hierarchical design.
19* **Command Primitive:** A mechanism for combining state updates and dynamic control flow within a single node.
20* **Streaming:** First-class support for streaming intermediate results and LLM tokens, enhancing user experience.
21* **Human-in-the-Loop (HIL):** Features like `interrupt()` and breakpoints allow human intervention for approvals, state editing, and dynamic input.
22
23## Key Features
24
25* **Controllability:** Fine-grained control over the application's flow through explicit node and edge definitions.
26* **Persistence:** Built-in mechanisms for saving and restoring graph state, supporting long-running conversations and fault tolerance.
27* **Modularity:** Encourages breaking down complex problems into smaller, reusable components (nodes and subgraphs).
28* **Tool Integration:** Seamlessly integrates with LangChain tools, allowing agents to interact with external systems.
29* **Observability:** Integrates with LangSmith for tracing, debugging, and monitoring of LLM applications.
30
31## Development Practices
32
33* **TypeScript:** Strongly typed development for improved code quality and maintainability.
34* **Testing:** Encourages comprehensive unit and integration testing of nodes, agents, and overall graph workflows.
35* **Error Handling:** Robust error handling for tool calls and model invocations.
36
37## Deployment
38
39LangGraph.js applications can be deployed in various ways, including self-hosted solutions or through the LangGraph Platform (Cloud, BYOC). The LangGraph CLI and SDK provide tools for building, running, and interacting with deployed applications.
40
41## Relevant Files in this Project
42
43* `src/agent/graph.ts`: Defines the main `StateGraph` and its nodes/edges, orchestrating the agent workflow.
44* `src/agent/state.ts`: Defines the `AgentState` interface and `AgentAnnotation` for managing the application's state.
45* `src/agent/supervisor.ts`: Implements the supervisor agent for routing between specialized agents.
46* `src/agent/react_agent.ts`: Implements the ReAct (Reasoning and Acting) agent.
47* `src/memory/`: Contains implementations for memory management, including MongoDB integration for checkpoints and vector stores.
48* `src/tools/`: Houses various tools used by the agents (e.g., `calculator`, `document_processing`, `exa`, `github`, `local_git`, `tavily`, `web_scraping`).
49* `package.json`: Lists LangGraph and LangChain related dependencies.
50
ssdeanx/langgraph-dm · .clinerules/memory.md
@@ +1 @@
1---
2glob: "**/*.ts"
3description: "Langgraph Memory Management Guidelines"
4---
5# Memory Management Guidelines
6
7## Purpose of Memory
8
9Memory in AI applications allows agents to process, store, and effectively recall information from past interactions, enabling learning and adaptation to user preferences.
10
11* **Short-term Memory (Thread-scoped):** Persists conversational turns (`messages`) within a single session for context and continuity. Managed as part of the agent's state.
12* **Long-term Memory (Cross-thread):** Retains information across different conversations or users. Stored in custom namespaces via the `Store` interface.
13* **Checkpointing:** Saves snapshots of the graph state at every "super-step" for continuity, debugging, and fault tolerance.
14
15## Implementation Details (`src/memory/`)
16
17* **MongoDB Integration:** MongoDB is the primary backend for memory persistence, including chat history, vector stores, and checkpoints.
18* **`MongoDBSaver` (`@langchain/langgraph-checkpoint-mongodb`):** Used for LangGraph checkpointing, ensuring graph state can be saved and reloaded.
19* **`MongoDBStore`:** Provides a generic key-value store interface over MongoDB for various data types, supporting long-term memory.
20* **`MongoDBChatMessageHistory`:** Manages the storage and retrieval of chat messages in MongoDB.
21* **`MongoDBAtlasVectorSearch`:** Integrates with MongoDB Atlas Vector Search for efficient semantic search over embeddings. Uses Google embeddings.
22
23## Best Practices for Memory
24
25* **Session Management:** Ensure unique `sessionId`s are used for different conversations to maintain isolated contexts.
26* **Environment Variables:** `MONGODB_ATLAS_URI` must be set for database connection.
27* **Vector Indexing:** Ensure vector search indexes are properly created and maintained for efficient vector lookups (e.g., `vector_index` in `src/memory/storage.ts`). Note that Google embeddings are typically 768 dimensions.
28* **Data Consistency:** Be mindful of data consistency when updating and retrieving memory components.
29* **Scalability:** Consider the implications of memory storage on scalability for large-scale deployments.
30* **Managing Conversation History:** Implement strategies to manage long conversation histories (e.g., trimming, summarizing) to prevent context window overflow and reduce costs. The `MessagesAnnotation` with `messagesStateReducer` is crucial for handling message updates and deletions.
31* **Memory Store Usage:** Use the `Store` interface for cross-thread persistence. Define clear namespaces and keys for organizing memories. Implement semantic search for natural language retrieval.
32* **Writing Memories:** Decide whether to write memories "on the hot path" (real-time, potentially impacting latency) or "in the background" (as a separate task).
33* **Memory Representation:** Consider how memories are presented to the LLM (e.g., as updated instructions, few-shot examples) to optimize its performance.
34
@@ −1 +1 @@
11 ---
22 glob: "**/*.ts"
3−description: "Langgraphjs Architecture"
3+description: "Langgraph Memory Management Guidelines"
44 ---
5−# LangGraph.js
5+# Memory Management Guidelines
66
7−## Overview
7+## Purpose of Memory
88
9−LangGraph.js is a powerful library for building stateful, multi-actor AI applications with Large Language Models (LLMs). It allows you to model complex agent workflows as graphs, where nodes represent individual steps or agents and edges define the flow of information and control.
9+Memory in AI applications allows agents to process, store, and effectively recall information from past interactions, enabling learning and adaptation to user preferences.
1010
11−## Core Concepts
11+* **Short-term Memory (Thread-scoped):** Persists conversational turns (`messages`) within a single session for context and continuity. Managed as part of the agent's state.
12+* **Long-term Memory (Cross-thread):** Retains information across different conversations or users. Stored in custom namespaces via the `Store` interface.
13+* **Checkpointing:** Saves snapshots of the graph state at every "super-step" for continuity, debugging, and fault tolerance.
1214
13−* **StateGraph:** The primary class for defining graph-based workflows. It manages the shared state that is passed between nodes.
14−* **Nodes:** Functions or runnable components that perform specific tasks and update the graph's state.
15−* **Edges:** Define transitions between nodes, which can be unconditional or conditional based on the current state.
16−* **State:** A shared data structure (`AgentState`) that represents the current context of the application, updated by nodes and passed along edges.
17−* **Checkpoints:** Snapshots of the graph's state saved at various points, enabling persistence, debugging, and human-in-the-loop interactions.
18−* **Subgraphs:** The ability to embed one graph as a node within another, promoting modularity and hierarchical design.
19−* **Command Primitive:** A mechanism for combining state updates and dynamic control flow within a single node.
20−* **Streaming:** First-class support for streaming intermediate results and LLM tokens, enhancing user experience.
21−* **Human-in-the-Loop (HIL):** Features like `interrupt()` and breakpoints allow human intervention for approvals, state editing, and dynamic input.
15+## Implementation Details (`src/memory/`)
2216
23−## Key Features
17+* **MongoDB Integration:** MongoDB is the primary backend for memory persistence, including chat history, vector stores, and checkpoints.
18+* **`MongoDBSaver` (`@langchain/langgraph-checkpoint-mongodb`):** Used for LangGraph checkpointing, ensuring graph state can be saved and reloaded.
19+* **`MongoDBStore`:** Provides a generic key-value store interface over MongoDB for various data types, supporting long-term memory.
20+* **`MongoDBChatMessageHistory`:** Manages the storage and retrieval of chat messages in MongoDB.
21+* **`MongoDBAtlasVectorSearch`:** Integrates with MongoDB Atlas Vector Search for efficient semantic search over embeddings. Uses Google embeddings.
2422
25−* **Controllability:** Fine-grained control over the application's flow through explicit node and edge definitions.
26−* **Persistence:** Built-in mechanisms for saving and restoring graph state, supporting long-running conversations and fault tolerance.
27−* **Modularity:** Encourages breaking down complex problems into smaller, reusable components (nodes and subgraphs).
28−* **Tool Integration:** Seamlessly integrates with LangChain tools, allowing agents to interact with external systems.
29−* **Observability:** Integrates with LangSmith for tracing, debugging, and monitoring of LLM applications.
23+## Best Practices for Memory
3024
31−## Development Practices
32−
33−* **TypeScript:** Strongly typed development for improved code quality and maintainability.
34−* **Testing:** Encourages comprehensive unit and integration testing of nodes, agents, and overall graph workflows.
35−* **Error Handling:** Robust error handling for tool calls and model invocations.
36−
37−## Deployment
38−
39−LangGraph.js applications can be deployed in various ways, including self-hosted solutions or through the LangGraph Platform (Cloud, BYOC). The LangGraph CLI and SDK provide tools for building, running, and interacting with deployed applications.
40−
41−## Relevant Files in this Project
42−
43−* `src/agent/graph.ts`: Defines the main `StateGraph` and its nodes/edges, orchestrating the agent workflow.
44−* `src/agent/state.ts`: Defines the `AgentState` interface and `AgentAnnotation` for managing the application's state.
45−* `src/agent/supervisor.ts`: Implements the supervisor agent for routing between specialized agents.
46−* `src/agent/react_agent.ts`: Implements the ReAct (Reasoning and Acting) agent.
47−* `src/memory/`: Contains implementations for memory management, including MongoDB integration for checkpoints and vector stores.
48−* `src/tools/`: Houses various tools used by the agents (e.g., `calculator`, `document_processing`, `exa`, `github`, `local_git`, `tavily`, `web_scraping`).
49−* `package.json`: Lists LangGraph and LangChain related dependencies.
25+* **Session Management:** Ensure unique `sessionId`s are used for different conversations to maintain isolated contexts.
26+* **Environment Variables:** `MONGODB_ATLAS_URI` must be set for database connection.
27+* **Vector Indexing:** Ensure vector search indexes are properly created and maintained for efficient vector lookups (e.g., `vector_index` in `src/memory/storage.ts`). Note that Google embeddings are typically 768 dimensions.
28+* **Data Consistency:** Be mindful of data consistency when updating and retrieving memory components.
29+* **Scalability:** Consider the implications of memory storage on scalability for large-scale deployments.
30+* **Managing Conversation History:** Implement strategies to manage long conversation histories (e.g., trimming, summarizing) to prevent context window overflow and reduce costs. The `MessagesAnnotation` with `messagesStateReducer` is crucial for handling message updates and deletions.
31+* **Memory Store Usage:** Use the `Store` interface for cross-thread persistence. Define clear namespaces and keys for organizing memories. Implement semantic search for natural language retrieval.
32+* **Writing Memories:** Decide whether to write memories "on the hot path" (real-time, potentially impacting latency) or "in the background" (as a separate task).
33+* **Memory Representation:** Consider how memories are presented to the LLM (e.g., as updated instructions, few-shot examples) to optimize its performance.
5034
