File size: 6,571 Bytes
99b8067
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
# ATLES Scratchpad - Quick Start Guide

## What is it?

The Scratchpad System gives ATLES an internal "thinking workspace" where it can draft, critique, and revise responses before sending them to you. You only see the final polished response, not the messy drafts.

## Setup (30 seconds)

### 1. Enable Scratchpad

Already done! Scratchpad is enabled by default in ATLES.

### 2. Verify Configuration

Check `config/scratchpad_config.yaml`:

```yaml
scratchpad:
  enabled: true  # βœ“ Thinking enabled
  mode: "every_response"  # Always think before responding
```

## Usage

### Basic Usage

```python
from atles import create_thinking_constitutional_client

# Create client
client = create_thinking_constitutional_client()

# Ask a question - ATLES will think internally before responding
response = client.generate("llama3.2", "Explain quantum computing")

# You see only the polished final response
print(response)
```

### What Happens Internally

```
Your Question β†’ Draft β†’ Critique β†’ Revise β†’ Final Response β†’ You
                  ↓        ↓         ↓          ↓
              [All saved in scratchpad for analysis]
```

### Mark User Corrections

When you correct ATLES, mark it so the system can learn:

```python
# ATLES gave wrong answer
response = client.generate("llama3.2", "What's 2+2?")
# User says "No, it's 4"

# Mark the correction
client.mark_user_correction("user_correction")
```

## Configuration

### Thinking Modes

Edit `config/scratchpad_config.yaml`:

```yaml
scratchpad:
  mode: "every_response"  # Options:
    # - "every_response" (always think)
    # - "complex_only" (skip simple questions)
    # - "manual" (only when triggered)
```

### Thinking Depth

```yaml
thinking:
  max_revisions: 2  # How many times to revise (0-3)
  critique_enabled: true  # Self-critique before sending
  self_check_enabled: true  # Final quality check
```

### Speed vs Quality

**For Speed:**
```yaml
mode: "complex_only"  # Skip simple questions
thinking:
  max_revisions: 1  # Less revision
  critique_enabled: false  # Skip critique
```

**For Quality:**
```yaml
mode: "every_response"  # Always think
thinking:
  max_revisions: 2  # More revision
  critique_enabled: true  # Enable critique
```

## Monitoring

### Session Stats

```python
# Get stats about current session
stats = client.get_thinking_stats()

print(f"Thoughts: {stats['num_thoughts']}")
print(f"Key thoughts: {stats['key_thoughts']}")
print(f"Avg response time: {stats['avg_response_time']:.2f}s")
```

### Archive Stats

```python
from atles import ScratchpadArchiver

archiver = ScratchpadArchiver()
stats = archiver.get_archive_stats()

print(f"Total sessions: {stats['total_sessions']}")
print(f"Key thoughts: {stats['total_key_thoughts']}")
```

## File Locations

### Active Session
```
atles_memory/scratchpad/active/session_YYYYMMDD_HHMMSS.jsonl
```
Current session's internal thoughts.

### Archives
```
atles_memory/scratchpad/archive/YYYY-MM-DD/
β”œβ”€β”€ session_001.jsonl     # Archived thoughts
β”œβ”€β”€ key_thoughts.jsonl    # Important patterns
└── summary.txt           # Human-readable summary
```

### Logs
```
atles_memory/scratchpad/scratchpad.log
```

## Common Tasks

### Disable Thinking Temporarily

```python
# In config
scratchpad:
  enabled: false
```

Or use the lightweight client instead:

```python
from atles import create_lightweight_constitutional_client
client = create_lightweight_constitutional_client()
```

### View Today's Key Thoughts

```bash
# On Windows
type atles_memory\scratchpad\archive\2025-11-07\summary.txt

# On Linux/Mac
cat atles_memory/scratchpad/archive/2025-11-07/summary.txt
```

### Archive Yesterday's Sessions

```python
from atles import ScratchpadArchiver

archiver = ScratchpadArchiver()
stats = archiver.archive_daily()  # Archives yesterday

print(f"Archived {stats['sessions_archived']} sessions")
print(f"Found {stats['key_thoughts']} key thoughts")
```

### Clean Up Old Archives

```yaml
# In config
archival:
  keep_days: 30  # Keep last 30 days (or less to save space)
```

## Troubleshooting

### "Too slow!"

**Option 1:** Skip simple questions
```yaml
mode: "complex_only"
```

**Option 2:** Reduce revisions
```yaml
thinking:
  max_revisions: 1  # Down from 2
```

**Option 3:** Disable temporarily
```yaml
enabled: false
```

### "Not seeing improvement"

**Enable full thinking:**
```yaml
mode: "every_response"
thinking:
  max_revisions: 2
  critique_enabled: true
  self_check_enabled: true
```

### "Taking up too much space"

**Reduce retention:**
```yaml
archival:
  keep_days: 7  # Down from 30
```

## Best Practices

### βœ… DO

- Leave thinking enabled for better quality
- Mark user corrections so system can learn
- Review key thoughts periodically for insights
- Adjust `max_revisions` based on your needs

### ❌ DON'T

- Disable thinking for important questions
- Ignore user corrections (mark them!)
- Let archives grow unbounded (set `keep_days`)
- Expect instant responses (thinking takes 2-4 seconds)

## Quick Reference

| Task | Command |
|------|---------|
| Create thinking client | `create_thinking_constitutional_client()` |
| Generate with thinking | `client.generate(model, prompt)` |
| Mark correction | `client.mark_user_correction()` |
| Get stats | `client.get_thinking_stats()` |
| Archive sessions | `ScratchpadArchiver().archive_daily()` |
| Enable thinking | Set `enabled: true` in config |
| Disable thinking | Set `enabled: false` in config |

## Example Session

```python
from atles import create_thinking_constitutional_client

# Initialize
client = create_thinking_constitutional_client()

# Ask questions - ATLES thinks before responding
q1 = client.generate("llama3.2", "What is AI?")
print(f"Answer: {q1}\n")

q2 = client.generate("llama3.2", "Explain neural networks")
print(f"Answer: {q2}\n")

# If user corrects an answer
client.mark_user_correction("user_correction")

# View stats
stats = client.get_thinking_stats()
print(f"\nSession Stats:")
print(f"- Thoughts: {stats['num_thoughts']}")
print(f"- Key thoughts: {stats['key_thoughts']}")
print(f"- Avg time: {stats['avg_response_time']:.2f}s")
```

## Next Steps

- Read full documentation: `docs/SCRATCHPAD_SYSTEM.md`
- Customize configuration: `config/scratchpad_config.yaml`
- Review archived thoughts: `atles_memory/scratchpad/archive/`
- Monitor performance: Check `scratchpad.log`

## Support

For detailed information, see:
- **Full Docs:** `docs/SCRATCHPAD_SYSTEM.md`
- **Config:** `config/scratchpad_config.yaml`
- **Logs:** `atles_memory/scratchpad/scratchpad.log`