| Dimension | Shared | Only in A | Only in B | Overlap |
|---|---|---|---|---|
| Sections | 0 | 5 | 4 | 0% |
| Commands | 0 | 0 | 0 | — |
| Section tags | 0 | 2 | 2 | 0% |
What each file covers
Sections
0 shared · 5 only in A · 4 only in B- − Agents Guidelines
- − Agent Responsibilities
- − Agent Development Principles
- − Agent Architectures
- − Agent Type Definitions (`src/agent/state.ts`)
- + Memory Management Guidelines
- + Purpose of Memory
- + Implementation Details (`src/memory/`)
- + Best Practices for Memory
Commands
neither file has anySection tags
0 shared · 2 only in A · 2 only in B- − types
- − agent-behaviour
- + code-style
- + performance
Line diff
ssdeanx/langgraph-dm · .clinerules/agents.md
@@ −1 @@
1---
2glob: "**/*.ts"
3description: "Langgraph Agents Guidelines"
4---
5# Agents Guidelines
6
7## Agent Responsibilities
8
9* **Supervisor:** Acts as the central orchestrator (`src/agent/supervisor.ts`), directing the flow between specialized agents based on the current state and user intent. It should be robust in decision-making and error recovery.
10* **Specialized Agents:** Each agent (e.g., `reactAgent`, `research_agent`, `documentation_agent`) should have a clearly defined purpose and set of tools. They should focus on their specific domain, update the `AgentState` with their results, and return control to the supervisor upon completion or if an unhandled error occurs.
11* **Chat Agent (`chatNode`):** Provides general conversational responses and acts as a fallback for queries not requiring specialized agent intervention.
12* **Tool-Calling Agent (ReAct):** Uses an LLM to decide the control flow, selecting and using various tools, retaining memory, and planning multi-step actions.
13
14## Agent Development Principles
15
16* **Modularity:** Each agent should be a self-contained unit, with its own logic and potentially its own set of tools. This facilitates reusability and easier debugging.
17* **State Management:** Agents must correctly interact with and update the `AgentState` to ensure continuity and accurate context passing throughout the graph. Use `Annotation` and reducers for precise state modifications.
18* **Tool Integration:** Agents should seamlessly integrate and utilize the available tools (`src/tools/*`) to perform their tasks. Ensure proper input validation and error handling when calling tools. Consider `ToolNode` for simplified tool execution.
19* **Error Handling:** Implement agent-specific error handling to gracefully manage failures and report back to the supervisor or user.
20* **Logging:** Use the `winston` logger (`src/config/logger.ts`) for tracing agent execution, decisions, and tool calls.
21* **Control Flow:** Agents can return `Command` objects to combine state updates and dynamic routing (e.g., handoffs between agents).
22* **Human-in-the-Loop:** Design agents to support human intervention for approvals, state editing, or input collection using LangGraph's `interrupt()` function.
23
24## Agent Architectures
25
26* **Router:** LLM selects a single path from options.
27* **Tool-Calling Agent (ReAct):** Combines tool usage, memory, and planning for multi-step decision-making.
28* **Multi-Agent Systems:** Break down complex problems into smaller, independent agents collaborating via networks, supervisors, or hierarchical structures. Handoffs are crucial for communication.
29
30## Agent Type Definitions (`src/agent/state.ts`)
31
32* The `AgentType` enum defines the various types of agents supported in the system, enabling clear categorization and routing within the `StateGraph`.
33* When adding new agent types, ensure they are properly defined in `AgentType` and integrated into the `StateGraph` in `src/agent/graph.ts`.
34
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: "Langgraph Agents Guidelines"
3+description: "Langgraph Memory Management Guidelines"
44 ---
5−# Agents Guidelines
5+# Memory Management Guidelines
66
7−## Agent Responsibilities
7+## Purpose of Memory
88
9−* **Supervisor:** Acts as the central orchestrator (`src/agent/supervisor.ts`), directing the flow between specialized agents based on the current state and user intent. It should be robust in decision-making and error recovery.
10−* **Specialized Agents:** Each agent (e.g., `reactAgent`, `research_agent`, `documentation_agent`) should have a clearly defined purpose and set of tools. They should focus on their specific domain, update the `AgentState` with their results, and return control to the supervisor upon completion or if an unhandled error occurs.
11−* **Chat Agent (`chatNode`):** Provides general conversational responses and acts as a fallback for queries not requiring specialized agent intervention.
12−* **Tool-Calling Agent (ReAct):** Uses an LLM to decide the control flow, selecting and using various tools, retaining memory, and planning multi-step actions.
9+Memory in AI applications allows agents to process, store, and effectively recall information from past interactions, enabling learning and adaptation to user preferences.
1310
14−## Agent Development Principles
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.
1514
16−* **Modularity:** Each agent should be a self-contained unit, with its own logic and potentially its own set of tools. This facilitates reusability and easier debugging.
17−* **State Management:** Agents must correctly interact with and update the `AgentState` to ensure continuity and accurate context passing throughout the graph. Use `Annotation` and reducers for precise state modifications.
18−* **Tool Integration:** Agents should seamlessly integrate and utilize the available tools (`src/tools/*`) to perform their tasks. Ensure proper input validation and error handling when calling tools. Consider `ToolNode` for simplified tool execution.
19−* **Error Handling:** Implement agent-specific error handling to gracefully manage failures and report back to the supervisor or user.
20−* **Logging:** Use the `winston` logger (`src/config/logger.ts`) for tracing agent execution, decisions, and tool calls.
21−* **Control Flow:** Agents can return `Command` objects to combine state updates and dynamic routing (e.g., handoffs between agents).
22−* **Human-in-the-Loop:** Design agents to support human intervention for approvals, state editing, or input collection using LangGraph's `interrupt()` function.
15+## Implementation Details (`src/memory/`)
2316
24−## Agent Architectures
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.
2522
26−* **Router:** LLM selects a single path from options.
27−* **Tool-Calling Agent (ReAct):** Combines tool usage, memory, and planning for multi-step decision-making.
28−* **Multi-Agent Systems:** Break down complex problems into smaller, independent agents collaborating via networks, supervisors, or hierarchical structures. Handoffs are crucial for communication.
23+## Best Practices for Memory
2924
30−## Agent Type Definitions (`src/agent/state.ts`)
31−
32−* The `AgentType` enum defines the various types of agents supported in the system, enabling clear categorization and routing within the `StateGraph`.
33−* When adding new agent types, ensure they are properly defined in `AgentType` and integrated into the `StateGraph` in `src/agent/graph.ts`.
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.
3434
