You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
style SN fill:#bbdefb,stroke:#1565c0,stroke-width:1px
70
+
```
71
+
35
72
## 2.4.2 Core Component Relationships
36
73
37
74
-**ChatObject**: The main interaction point that manages a single conversation
@@ -40,31 +77,60 @@ graph TB
40
77
-**Tools Manager**: Extends the agent's capabilities with external functions
41
78
-**Memory Model**: Maintains conversation context and history
42
79
-**Agent Core**: The central processing unit coordinating all components
80
+
-**SessionsManager**: Manages multiple isolated sessions, each as an independent conversation context
81
+
-**Session (Conversation Context)**: Stores all relevant information for a specific user or specific conversation, including memory model, tools, configurations, etc.
43
82
44
-
## 2.4.3 Data Flow Explanation
83
+
## 2.4.3 Agent Loop and Session Isolation Mechanism
45
84
46
85
```mermaid
47
86
sequenceDiagram
48
-
User->>CO: Send input message
49
-
CO->>Config: Check configuration
50
-
CO->>Events: Trigger input events
51
-
CO->>Agent: Initialize processing
52
-
Agent->>Memory: Load conversation context
53
-
Agent->>Tools: Check for required tools
54
-
Agent->>LLM: Format and send request
87
+
participant User1 as User1
88
+
participant User2 as User2
89
+
participant SM as SessionsManager
90
+
participant S1 as Session 1<br/>(Conversation Context 1)
91
+
participant S2 as Session 2<br/>(Conversation Context 2)
92
+
participant Agent as Agent Core
93
+
participant LLM as LLM Provider
94
+
95
+
Note over User1,LLM: Agent Loop Begins
96
+
User1->>SM: Request to create Session 1
97
+
User2->>SM: Request to create Session 2
98
+
SM-->>User1: Return Session ID 1
99
+
SM-->>User2: Return Session ID 2
100
+
101
+
Note over User1,User2: Each user interacts in their respective conversation context
102
+
103
+
User1->>S1: Send message to Session 1
104
+
S1->>S1: Initialize ChatObject
105
+
S1->>Agent: Start Agent Loop to process request
106
+
107
+
User2->>S2: Send message to Session 2
108
+
S2->>S2: Initialize ChatObject
109
+
S2->>Agent: Start Agent Loop to process request
110
+
111
+
par Parallel Processing of Two Conversation Contexts
112
+
Agent->>S1: Process in Session 1 Context
113
+
Agent->>S2: Process in Session 2 Context
114
+
115
+
Agent->>S1: Update Session 1 Memory Model
116
+
Agent->>S2: Update Session 2 Memory Model
117
+
end
118
+
119
+
Agent->>LLM: Send request (from Session 1)
55
120
LLM-->>Agent: Return response
56
-
Agent->>Memory: Update conversation state
57
-
Agent->>Events: Trigger output events
58
-
CO-->>User: Stream response
121
+
Agent-->>S1: Update Session 1 State
122
+
S1-->>User1: Stream response
123
+
124
+
Agent->>LLM: Send request (from Session 2)
125
+
LLM-->>Agent: Return response
126
+
Agent-->>S2: Update Session 2 State
127
+
S2-->>User2: Stream response
128
+
129
+
Note over User1,LLM: Each conversation context maintains independent history and state
59
130
```
60
131
61
-
1. User input enters through a ChatObject
62
-
2. Configuration determines processing behavior
63
-
3. The input triggers various events in the Events System
64
-
4. Agent Core loads the conversation context from Memory Model
65
-
5. Agent Core checks if any tools need to be called based on the input
66
-
6. The processed input is sent to the LLM Provider
67
-
7. The response from LLM is handled by Agent Core
68
-
8. Memory Model is updated with the new conversation state
69
-
9. Output events may intercept and modify the final response
70
-
10. The response is streamed back to the user via ChatObject
132
+
1.**Session as Conversation Context**: Each Session represents an independent conversation context, storing all relevant information for a specific user or specific conversation
133
+
2.**Global Data Container**: SessionsManager manages all active conversation contexts, providing global resource sharing
134
+
3.**Agent Loop**: Inside each conversation context, the Agent Core executes the complete processing loop
135
+
4.**Context Isolation**: Data between different conversation contexts is completely isolated, ensuring conversation histories don't mix
136
+
5.**Global Resource Sharing**: Each conversation context can access resources from the Global container, but maintains its own independent state
0 commit comments