massgen 0.1.2__py3-none-any.whl → 0.1.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- massgen/__init__.py +1 -1
- massgen/agent_config.py +33 -7
- massgen/api_params_handler/_api_params_handler_base.py +3 -0
- massgen/backend/azure_openai.py +9 -1
- massgen/backend/base.py +4 -0
- massgen/backend/claude_code.py +9 -1
- massgen/backend/gemini.py +35 -6
- massgen/backend/gemini_utils.py +30 -0
- massgen/chat_agent.py +9 -3
- massgen/cli.py +291 -43
- massgen/config_builder.py +163 -18
- massgen/configs/README.md +52 -6
- massgen/configs/debug/restart_test_controlled.yaml +60 -0
- massgen/configs/debug/restart_test_controlled_filesystem.yaml +73 -0
- massgen/configs/tools/code-execution/docker_with_sudo.yaml +35 -0
- massgen/configs/tools/custom_tools/computer_use_browser_example.yaml +56 -0
- massgen/configs/tools/custom_tools/computer_use_docker_example.yaml +65 -0
- massgen/configs/tools/custom_tools/computer_use_example.yaml +50 -0
- massgen/configs/tools/custom_tools/crawl4ai_mcp_example.yaml +67 -0
- massgen/configs/tools/custom_tools/crawl4ai_multi_agent_example.yaml +68 -0
- massgen/configs/tools/custom_tools/multimodal_tools/playwright_with_img_understanding.yaml +98 -0
- massgen/configs/tools/custom_tools/multimodal_tools/understand_audio.yaml +33 -0
- massgen/configs/tools/custom_tools/multimodal_tools/understand_file.yaml +34 -0
- massgen/configs/tools/custom_tools/multimodal_tools/understand_image.yaml +33 -0
- massgen/configs/tools/custom_tools/multimodal_tools/understand_video.yaml +34 -0
- massgen/configs/tools/custom_tools/multimodal_tools/understand_video_example.yaml +54 -0
- massgen/configs/tools/custom_tools/multimodal_tools/youtube_video_analysis.yaml +59 -0
- massgen/configs/tools/memory/README.md +199 -0
- massgen/configs/tools/memory/gpt5mini_gemini_context_window_management.yaml +131 -0
- massgen/configs/tools/memory/gpt5mini_gemini_no_persistent_memory.yaml +133 -0
- massgen/configs/tools/memory/test_context_window_management.py +286 -0
- massgen/configs/tools/multimodal/gpt5mini_gpt5nano_documentation_evolution.yaml +97 -0
- massgen/docker/README.md +83 -0
- massgen/filesystem_manager/_code_execution_server.py +22 -7
- massgen/filesystem_manager/_docker_manager.py +21 -1
- massgen/filesystem_manager/_filesystem_manager.py +8 -0
- massgen/filesystem_manager/_workspace_tools_server.py +0 -997
- massgen/formatter/_gemini_formatter.py +73 -0
- massgen/frontend/coordination_ui.py +175 -257
- massgen/frontend/displays/base_display.py +29 -0
- massgen/frontend/displays/rich_terminal_display.py +155 -9
- massgen/frontend/displays/simple_display.py +21 -0
- massgen/frontend/displays/terminal_display.py +22 -2
- massgen/logger_config.py +50 -6
- massgen/message_templates.py +123 -3
- massgen/orchestrator.py +319 -38
- massgen/tests/test_code_execution.py +178 -0
- massgen/tests/test_orchestration_restart.py +204 -0
- massgen/tool/__init__.py +4 -0
- massgen/tool/_multimodal_tools/understand_audio.py +193 -0
- massgen/tool/_multimodal_tools/understand_file.py +550 -0
- massgen/tool/_multimodal_tools/understand_image.py +212 -0
- massgen/tool/_multimodal_tools/understand_video.py +313 -0
- massgen/tool/docs/multimodal_tools.md +779 -0
- massgen/tool/workflow_toolkits/__init__.py +26 -0
- massgen/tool/workflow_toolkits/post_evaluation.py +216 -0
- massgen/utils.py +1 -0
- {massgen-0.1.2.dist-info → massgen-0.1.3.dist-info}/METADATA +8 -3
- {massgen-0.1.2.dist-info → massgen-0.1.3.dist-info}/RECORD +63 -36
- {massgen-0.1.2.dist-info → massgen-0.1.3.dist-info}/WHEEL +0 -0
- {massgen-0.1.2.dist-info → massgen-0.1.3.dist-info}/entry_points.txt +0 -0
- {massgen-0.1.2.dist-info → massgen-0.1.3.dist-info}/licenses/LICENSE +0 -0
- {massgen-0.1.2.dist-info → massgen-0.1.3.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
# Memory and Context Window Management Examples
|
|
2
|
+
|
|
3
|
+
This directory contains example configurations and tests for MassGen's memory system and automatic context window management.
|
|
4
|
+
|
|
5
|
+
## Features Demonstrated
|
|
6
|
+
|
|
7
|
+
- **Automatic Context Compression**: When conversation history approaches 75% of the model's context window, older messages are automatically compressed
|
|
8
|
+
- **Token-Aware Management**: System keeps most recent messages within 40% token budget
|
|
9
|
+
- **Persistent Memory Integration**: Compressed messages stored in long-term memory using mem0
|
|
10
|
+
- **Graceful Degradation**: Works with or without persistent memory (with appropriate warnings)
|
|
11
|
+
|
|
12
|
+
## Files
|
|
13
|
+
|
|
14
|
+
### Configuration Files
|
|
15
|
+
|
|
16
|
+
#### `gpt5mini_gemini_context_window_management.yaml`
|
|
17
|
+
Example configuration showing how to configure memory directly in YAML.
|
|
18
|
+
|
|
19
|
+
Features two agents:
|
|
20
|
+
- **agent_a**: GPT-5-mini with medium reasoning
|
|
21
|
+
- **agent_b**: Gemini 2.5 Flash
|
|
22
|
+
|
|
23
|
+
**Memory Control** - Configure directly in YAML:
|
|
24
|
+
```yaml
|
|
25
|
+
memory:
|
|
26
|
+
enabled: true # Master switch
|
|
27
|
+
|
|
28
|
+
conversation_memory:
|
|
29
|
+
enabled: true # Short-term tracking
|
|
30
|
+
|
|
31
|
+
persistent_memory:
|
|
32
|
+
enabled: true # Long-term storage (set to false to disable)
|
|
33
|
+
on_disk: true
|
|
34
|
+
agent_name: "storyteller_agent"
|
|
35
|
+
# session_name: "test_session" # Optional - auto-generated if not specified
|
|
36
|
+
|
|
37
|
+
compression:
|
|
38
|
+
trigger_threshold: 0.75 # Compress at 75%
|
|
39
|
+
target_ratio: 0.40 # Target 40% after
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
**Session Management:**
|
|
43
|
+
- If `session_name` is not specified, a unique ID is auto-generated (e.g., `agent_storyteller_20251023_143022_a1b2c3`)
|
|
44
|
+
- Each new run gets a fresh session by default
|
|
45
|
+
- To continue a previous session, specify the `session_name` explicitly
|
|
46
|
+
|
|
47
|
+
To disable persistent memory, set `memory.persistent_memory.enabled: false`
|
|
48
|
+
|
|
49
|
+
#### `gpt5mini_gemini_no_persistent_memory.yaml`
|
|
50
|
+
Example showing what happens when persistent memory is disabled.
|
|
51
|
+
|
|
52
|
+
**Key difference**: Sets `memory.persistent_memory.enabled: false` to demonstrate warning messages when context fills up without long-term storage.
|
|
53
|
+
|
|
54
|
+
### Test Script
|
|
55
|
+
|
|
56
|
+
#### `test_context_window_management.py`
|
|
57
|
+
Complete test script demonstrating:
|
|
58
|
+
- Setup of ConversationMemory and PersistentMemory
|
|
59
|
+
- Integration with SingleAgent
|
|
60
|
+
- Both scenarios (with/without persistent memory)
|
|
61
|
+
- Logging of compression events
|
|
62
|
+
|
|
63
|
+
## Quick Start
|
|
64
|
+
|
|
65
|
+
### Prerequisites
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
# Install dependencies
|
|
69
|
+
pip install massgen mem0ai
|
|
70
|
+
|
|
71
|
+
# Set up API keys - Create a .env file in project root:
|
|
72
|
+
cat > .env << EOF
|
|
73
|
+
OPENAI_API_KEY='your-key-here'
|
|
74
|
+
GOOGLE_API_KEY='your-key-here' # Optional, for Gemini
|
|
75
|
+
EOF
|
|
76
|
+
|
|
77
|
+
# Or export directly:
|
|
78
|
+
export OPENAI_API_KEY='your-key-here'
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
The test script automatically loads `.env` files from:
|
|
82
|
+
- Project root
|
|
83
|
+
- Current directory
|
|
84
|
+
- Script directory
|
|
85
|
+
|
|
86
|
+
### Run the Test
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
# Run with default config (memory enabled)
|
|
90
|
+
python massgen/configs/tools/memory/test_context_window_management.py
|
|
91
|
+
|
|
92
|
+
# Run with custom config
|
|
93
|
+
python massgen/configs/tools/memory/test_context_window_management.py --config path/to/config.yaml
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
The test script reads the `memory` section from YAML and:
|
|
97
|
+
- If `persistent_memory.enabled: true` → Runs Test 1 (with persistent memory)
|
|
98
|
+
- If `persistent_memory.enabled: false` → Runs Test 2 (without persistent memory)
|
|
99
|
+
|
|
100
|
+
### Expected Output
|
|
101
|
+
|
|
102
|
+
**With Persistent Memory:**
|
|
103
|
+
```
|
|
104
|
+
📊 Context usage: 96,000 / 128,000 tokens (75.0%) - compressing old context
|
|
105
|
+
📦 Compressed 15 messages (60,000 tokens) into long-term memory
|
|
106
|
+
Kept 8 messages (36,000 tokens) in context
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
**Without Persistent Memory:**
|
|
110
|
+
```
|
|
111
|
+
📊 Context usage: 96,000 / 128,000 tokens (75.0%) - compressing old context
|
|
112
|
+
⚠️ Warning: Dropping 15 messages (60,000 tokens)
|
|
113
|
+
No persistent memory configured to retain this information
|
|
114
|
+
Consider adding persistent_memory to avoid losing context
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## How It Works
|
|
118
|
+
|
|
119
|
+
### Token Budget Allocation
|
|
120
|
+
|
|
121
|
+
After compression, the context window is allocated as follows:
|
|
122
|
+
|
|
123
|
+
| Component | Allocation | Purpose |
|
|
124
|
+
|-----------|------------|---------|
|
|
125
|
+
| Conversation History | 40% | Most recent messages kept in active context |
|
|
126
|
+
| New User Messages | 20% | Room for incoming requests |
|
|
127
|
+
| Retrieved Memories | 10% | Injected relevant facts from persistent memory |
|
|
128
|
+
| System Prompt | 10% | Overhead for instructions |
|
|
129
|
+
| Response Generation | 20% | Space for model output |
|
|
130
|
+
|
|
131
|
+
### Compression Strategy
|
|
132
|
+
|
|
133
|
+
1. **Threshold**: Compression triggers at **75%** of context window
|
|
134
|
+
2. **Target**: Reduces to **40%** of context window after compression
|
|
135
|
+
3. **Selection**: Keeps most recent messages that fit within budget
|
|
136
|
+
4. **Preservation**: System messages always kept (never compressed)
|
|
137
|
+
|
|
138
|
+
### Model Context Windows
|
|
139
|
+
|
|
140
|
+
The system automatically detects context limits for each model:
|
|
141
|
+
|
|
142
|
+
| Model | Context Window | Compression at | Target After |
|
|
143
|
+
|-------|----------------|----------------|--------------|
|
|
144
|
+
| GPT-4o | 128K | 96K tokens | 51K tokens |
|
|
145
|
+
| GPT-4o-mini | 128K | 96K tokens | 51K tokens |
|
|
146
|
+
| Claude Sonnet 4 | 200K | 150K tokens | 80K tokens |
|
|
147
|
+
| Gemini 2.5 Flash | 1M | 750K tokens | 400K tokens |
|
|
148
|
+
| DeepSeek R1 | 128K | 96K tokens | 51K tokens |
|
|
149
|
+
|
|
150
|
+
## Programmatic Usage
|
|
151
|
+
|
|
152
|
+
To use memory in your own code:
|
|
153
|
+
|
|
154
|
+
```python
|
|
155
|
+
from massgen.backend.chat_completions import ChatCompletionsBackend
|
|
156
|
+
from massgen.chat_agent import SingleAgent
|
|
157
|
+
from massgen.memory import ConversationMemory, PersistentMemory
|
|
158
|
+
|
|
159
|
+
# Create backends
|
|
160
|
+
llm = ChatCompletionsBackend(type="openai", model="gpt-4o-mini", api_key="...")
|
|
161
|
+
embedding = ChatCompletionsBackend(type="openai", model="text-embedding-3-small", api_key="...")
|
|
162
|
+
|
|
163
|
+
# Initialize memory
|
|
164
|
+
conversation_memory = ConversationMemory()
|
|
165
|
+
persistent_memory = PersistentMemory(
|
|
166
|
+
agent_name="my_agent",
|
|
167
|
+
session_name="session_1",
|
|
168
|
+
llm_backend=llm,
|
|
169
|
+
embedding_backend=embedding,
|
|
170
|
+
on_disk=True, # Persist across restarts
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
# Create agent with memory
|
|
174
|
+
agent = SingleAgent(
|
|
175
|
+
backend=llm,
|
|
176
|
+
agent_id="my_agent",
|
|
177
|
+
system_message="You are a helpful assistant",
|
|
178
|
+
conversation_memory=conversation_memory,
|
|
179
|
+
persistent_memory=persistent_memory,
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
# Use normally - compression happens automatically
|
|
183
|
+
async for chunk in agent.chat([{"role": "user", "content": "Hello!"}]):
|
|
184
|
+
if chunk.type == "content":
|
|
185
|
+
print(chunk.content, end="")
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## Related Documentation
|
|
189
|
+
|
|
190
|
+
- [Memory System Design](../../../massgen/memory/docs/DESIGN.md)
|
|
191
|
+
- [Memory Quickstart](../../../massgen/memory/docs/QUICKSTART.md)
|
|
192
|
+
- [Single Agent Memory Integration](../../../massgen/memory/docs/agent_use_memory.md)
|
|
193
|
+
- [Orchestrator Shared Memory](../../../massgen/memory/docs/orchestrator_use_memory.md)
|
|
194
|
+
|
|
195
|
+
## Related Issues
|
|
196
|
+
|
|
197
|
+
- [Issue #347](https://github.com/Leezekun/MassGen/issues/347): Handle context limit with summarization
|
|
198
|
+
- [Issue #348](https://github.com/Leezekun/MassGen/issues/348): Ensure memory persists across restarts ✅
|
|
199
|
+
- [Issue #349](https://github.com/Leezekun/MassGen/issues/349): File caching with memory (future work)
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# Example Configuration: Context Window Management with Memory
|
|
2
|
+
#
|
|
3
|
+
# Use Case: Demonstrates automatic context compression when approaching token limits
|
|
4
|
+
#
|
|
5
|
+
# This configuration demonstrates:
|
|
6
|
+
# - Automatic context window monitoring and compression
|
|
7
|
+
# - Token-aware conversation management (75% threshold, 40% target)
|
|
8
|
+
# - Persistent memory integration for long-term knowledge retention
|
|
9
|
+
# - Graceful handling when context window fills up
|
|
10
|
+
# - Multi-agent collaboration with shared context management
|
|
11
|
+
#
|
|
12
|
+
# Run with:
|
|
13
|
+
# massgen \
|
|
14
|
+
# --config massgen/configs/tools/memory/gpt5mini_gemini_context_window_management.yaml \
|
|
15
|
+
# "Tell me a detailed story about a space explorer. After each paragraph, ask me what happens next, and I'll guide the story. Keep expanding the narrative with rich details about planets, aliens, technology, and adventures. Make each response at least 500 words."
|
|
16
|
+
|
|
17
|
+
# ====================
|
|
18
|
+
# AGENT DEFINITIONS
|
|
19
|
+
# ====================
|
|
20
|
+
agents:
|
|
21
|
+
- id: "agent_a"
|
|
22
|
+
backend:
|
|
23
|
+
# Use GPT-5-mini with medium reasoning
|
|
24
|
+
type: "openai"
|
|
25
|
+
model: "gpt-5-mini"
|
|
26
|
+
text:
|
|
27
|
+
verbosity: "medium"
|
|
28
|
+
reasoning:
|
|
29
|
+
effort: "medium"
|
|
30
|
+
summary: "auto"
|
|
31
|
+
|
|
32
|
+
- id: "agent_b"
|
|
33
|
+
backend:
|
|
34
|
+
# Use Gemini 2.5 Flash for cost-effective testing
|
|
35
|
+
type: "gemini"
|
|
36
|
+
model: "gemini-2.5-flash"
|
|
37
|
+
|
|
38
|
+
# ====================
|
|
39
|
+
# MEMORY CONFIGURATION
|
|
40
|
+
# ====================
|
|
41
|
+
memory:
|
|
42
|
+
# Enable/disable persistent memory (default: true)
|
|
43
|
+
enabled: true
|
|
44
|
+
|
|
45
|
+
# Memory configuration
|
|
46
|
+
conversation_memory:
|
|
47
|
+
enabled: true # Short-term conversation tracking (recommended: always true)
|
|
48
|
+
|
|
49
|
+
persistent_memory:
|
|
50
|
+
enabled: true # Long-term knowledge storage (set to false to disable)
|
|
51
|
+
on_disk: true # Persist across restarts
|
|
52
|
+
# session_name: "test_session" # Optional - if not specified, auto-generates unique ID
|
|
53
|
+
# Format: agent_storyteller_20251023_143022_a1b2c3
|
|
54
|
+
# Specify to continue a specific session
|
|
55
|
+
|
|
56
|
+
# Vector store backend (default: qdrant)
|
|
57
|
+
vector_store: "qdrant"
|
|
58
|
+
|
|
59
|
+
# Context window management thresholds
|
|
60
|
+
compression:
|
|
61
|
+
trigger_threshold: 0.75 # Compress when context usage exceeds 75%
|
|
62
|
+
target_ratio: 0.40 # Target 40% of context after compression
|
|
63
|
+
|
|
64
|
+
# Memory system behavior when enabled:
|
|
65
|
+
# - ConversationMemory: Tracks short-term conversation history
|
|
66
|
+
# - PersistentMemory: Stores long-term knowledge in vector database
|
|
67
|
+
# - Automatic compression: Triggers at 75% of context window
|
|
68
|
+
# - Token budget: Keeps 40% after compression
|
|
69
|
+
# - Persistence: Saves to disk and survives restarts
|
|
70
|
+
#
|
|
71
|
+
# Session management:
|
|
72
|
+
# - Each agent gets its own memory (separate by agent_name)
|
|
73
|
+
# - New sessions start fresh (session_name auto-generated if not specified)
|
|
74
|
+
# - To continue a previous session, specify the session_name
|
|
75
|
+
#
|
|
76
|
+
# To disable persistent memory for testing, set:
|
|
77
|
+
# memory.persistent_memory.enabled: false
|
|
78
|
+
#
|
|
79
|
+
# See massgen/memory/docs/ for detailed documentation.
|
|
80
|
+
|
|
81
|
+
# ====================
|
|
82
|
+
# ORCHESTRATOR CONFIGURATION
|
|
83
|
+
# ====================
|
|
84
|
+
orchestrator:
|
|
85
|
+
# Multi-turn mode to enable interactive storytelling
|
|
86
|
+
session_storage: "memory_test_sessions"
|
|
87
|
+
|
|
88
|
+
# Agent workspace for any file operations
|
|
89
|
+
agent_temporary_workspace: "memory_test_workspaces"
|
|
90
|
+
snapshot_storage: "memory_test_snapshots"
|
|
91
|
+
|
|
92
|
+
# ====================
|
|
93
|
+
# UI CONFIGURATION
|
|
94
|
+
# ====================
|
|
95
|
+
ui:
|
|
96
|
+
display_type: "rich_terminal"
|
|
97
|
+
logging_enabled: true
|
|
98
|
+
|
|
99
|
+
# ====================
|
|
100
|
+
# EXECUTION FLOW
|
|
101
|
+
# ====================
|
|
102
|
+
# What happens:
|
|
103
|
+
# 1. User starts an interactive story with the agent
|
|
104
|
+
# 2. Agent responds with detailed narrative (400-600 words per turn)
|
|
105
|
+
# 3. As conversation continues, token usage is monitored automatically
|
|
106
|
+
# 4. When context usage reaches 75% of model's limit:
|
|
107
|
+
# - System logs: "📊 Context usage: X / Y tokens (Z%) - compressing old context"
|
|
108
|
+
# - Old messages are compressed into persistent memory (if configured)
|
|
109
|
+
# - Recent messages (fitting in 40% of context window) are kept
|
|
110
|
+
# - Compression details logged: "📦 Compressed N messages (X tokens) into long-term memory"
|
|
111
|
+
# 5. Agent continues seamlessly with compressed context
|
|
112
|
+
# 6. Story maintains consistency by referencing persistent memories
|
|
113
|
+
# 7. Process repeats as needed for very long conversations
|
|
114
|
+
#
|
|
115
|
+
# Expected output with persistent memory:
|
|
116
|
+
# 📊 Context usage: 96,000 / 128,000 tokens (75.0%) - compressing old context
|
|
117
|
+
# 📦 Compressed 15 messages (60,000 tokens) into long-term memory
|
|
118
|
+
# Kept 8 messages (36,000 tokens) in context
|
|
119
|
+
#
|
|
120
|
+
# Expected output WITHOUT persistent memory:
|
|
121
|
+
# 📊 Context usage: 96,000 / 128,000 tokens (75.0%) - compressing old context
|
|
122
|
+
# ⚠️ Warning: Dropping 15 messages (60,000 tokens)
|
|
123
|
+
# No persistent memory configured to retain this information
|
|
124
|
+
# Consider adding persistent_memory to avoid losing context
|
|
125
|
+
#
|
|
126
|
+
# Token Budget Allocation (after compression):
|
|
127
|
+
# - Conversation history: 40% (kept in active context)
|
|
128
|
+
# - New user messages: 20%
|
|
129
|
+
# - Retrieved memories: 10%
|
|
130
|
+
# - System prompt overhead: 10%
|
|
131
|
+
# - Response generation: 20%
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# Example Configuration: Context Window Management WITHOUT Persistent Memory
|
|
2
|
+
#
|
|
3
|
+
# Use Case: Demonstrates context compression warnings when no persistent memory
|
|
4
|
+
#
|
|
5
|
+
# This configuration demonstrates what happens when:
|
|
6
|
+
# - Conversation memory is enabled (tracks short-term history)
|
|
7
|
+
# - Persistent memory is DISABLED (no long-term storage)
|
|
8
|
+
# - Context window fills up (triggering compression warnings)
|
|
9
|
+
#
|
|
10
|
+
# Run with:
|
|
11
|
+
# python massgen/configs/tools/memory/test_context_window_management.py \
|
|
12
|
+
# --config massgen/configs/tools/memory/gpt5mini_gemini_no_persistent_memory.yaml
|
|
13
|
+
|
|
14
|
+
# ====================
|
|
15
|
+
# AGENT DEFINITIONS
|
|
16
|
+
# ====================
|
|
17
|
+
agents:
|
|
18
|
+
- id: "agent_a"
|
|
19
|
+
system_message: |
|
|
20
|
+
You are a creative storyteller who crafts detailed, immersive narratives.
|
|
21
|
+
|
|
22
|
+
When telling stories:
|
|
23
|
+
- Create rich, detailed descriptions of settings, characters, and events
|
|
24
|
+
- Build on previous plot points and maintain narrative consistency
|
|
25
|
+
- Ask engaging questions to guide the story forward
|
|
26
|
+
- Make each response substantial and immersive (aim for 400-600 words)
|
|
27
|
+
- Reference earlier story elements to create callbacks and continuity
|
|
28
|
+
|
|
29
|
+
Your goal is to create a long, engaging narrative that will naturally fill up
|
|
30
|
+
the context window over multiple turns, demonstrating how the system manages
|
|
31
|
+
conversation history automatically.
|
|
32
|
+
|
|
33
|
+
backend:
|
|
34
|
+
# Use GPT-5-mini with medium reasoning
|
|
35
|
+
type: "openai"
|
|
36
|
+
model: "gpt-5-mini"
|
|
37
|
+
|
|
38
|
+
# LLM parameters
|
|
39
|
+
temperature: 0.8
|
|
40
|
+
max_tokens: 2000
|
|
41
|
+
|
|
42
|
+
text:
|
|
43
|
+
verbosity: "medium"
|
|
44
|
+
|
|
45
|
+
reasoning:
|
|
46
|
+
effort: "medium"
|
|
47
|
+
summary: "auto"
|
|
48
|
+
|
|
49
|
+
- id: "agent_b"
|
|
50
|
+
system_message: |
|
|
51
|
+
You are a creative storyteller who crafts detailed, immersive narratives.
|
|
52
|
+
|
|
53
|
+
When telling stories:
|
|
54
|
+
- Create rich, detailed descriptions of settings, characters, and events
|
|
55
|
+
- Build on previous plot points and maintain narrative consistency
|
|
56
|
+
- Ask engaging questions to guide the story forward
|
|
57
|
+
- Make each response substantial and immersive (aim for 400-600 words)
|
|
58
|
+
- Reference earlier story elements to create callbacks and continuity
|
|
59
|
+
|
|
60
|
+
Your goal is to create a long, engaging narrative that will naturally fill up
|
|
61
|
+
the context window over multiple turns, demonstrating how the system manages
|
|
62
|
+
conversation history automatically.
|
|
63
|
+
|
|
64
|
+
backend:
|
|
65
|
+
# Use Gemini 2.5 Flash
|
|
66
|
+
type: "gemini"
|
|
67
|
+
model: "gemini-2.5-flash"
|
|
68
|
+
|
|
69
|
+
# LLM parameters
|
|
70
|
+
temperature: 0.8
|
|
71
|
+
max_tokens: 2000
|
|
72
|
+
|
|
73
|
+
# ====================
|
|
74
|
+
# MEMORY CONFIGURATION
|
|
75
|
+
# ====================
|
|
76
|
+
memory:
|
|
77
|
+
# Memory is enabled
|
|
78
|
+
enabled: true
|
|
79
|
+
|
|
80
|
+
# Conversation memory tracks short-term history
|
|
81
|
+
conversation_memory:
|
|
82
|
+
enabled: true
|
|
83
|
+
|
|
84
|
+
# Persistent memory is DISABLED - this will trigger warnings
|
|
85
|
+
persistent_memory:
|
|
86
|
+
enabled: false # ⚠️ Set to false to see warning behavior
|
|
87
|
+
|
|
88
|
+
# Context window management still works
|
|
89
|
+
compression:
|
|
90
|
+
trigger_threshold: 0.75 # Compress when context usage exceeds 75%
|
|
91
|
+
target_ratio: 0.40 # Target 40% of context after compression
|
|
92
|
+
|
|
93
|
+
# Expected behavior when context fills:
|
|
94
|
+
# ⚠️ Warning: Dropping N messages (X tokens)
|
|
95
|
+
# No persistent memory configured to retain this information
|
|
96
|
+
# Consider adding persistent_memory to avoid losing context
|
|
97
|
+
#
|
|
98
|
+
# The system will still compress context, but information is lost
|
|
99
|
+
# rather than stored in long-term memory.
|
|
100
|
+
|
|
101
|
+
# ====================
|
|
102
|
+
# ORCHESTRATOR CONFIGURATION
|
|
103
|
+
# ====================
|
|
104
|
+
orchestrator:
|
|
105
|
+
# Multi-turn mode
|
|
106
|
+
session_storage: "massgen_logs/memory_test_sessions"
|
|
107
|
+
|
|
108
|
+
# Agent workspaces
|
|
109
|
+
agent_temporary_workspace: "massgen_logs/memory_test_workspaces"
|
|
110
|
+
snapshot_storage: "massgen_logs/memory_test_snapshots"
|
|
111
|
+
|
|
112
|
+
# ====================
|
|
113
|
+
# UI CONFIGURATION
|
|
114
|
+
# ====================
|
|
115
|
+
ui:
|
|
116
|
+
display_type: "rich_terminal"
|
|
117
|
+
logging_enabled: true
|
|
118
|
+
|
|
119
|
+
# ====================
|
|
120
|
+
# EXECUTION FLOW
|
|
121
|
+
# ====================
|
|
122
|
+
# What happens:
|
|
123
|
+
# 1. Conversation proceeds normally with short-term memory
|
|
124
|
+
# 2. When context reaches 75% capacity:
|
|
125
|
+
# - System logs: "📊 Context usage: X / Y tokens (Z%) - compressing old context"
|
|
126
|
+
# - Warning shown: "⚠️ Warning: Dropping N messages"
|
|
127
|
+
# - Warning shown: "No persistent memory configured"
|
|
128
|
+
# 3. Old messages are dropped (not saved anywhere)
|
|
129
|
+
# 4. Agent continues with reduced context
|
|
130
|
+
# 5. Information from dropped messages is permanently lost
|
|
131
|
+
#
|
|
132
|
+
# Compare this to the config with persistent memory enabled to see
|
|
133
|
+
# the difference between graceful compression and data loss.
|