htm 0.0.18 → 0.0.20
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +59 -1
- data/README.md +12 -0
- data/db/seeds.rb +1 -1
- data/docs/api/embedding-service.md +140 -110
- data/docs/api/yard/HTM/ActiveRecordConfig.md +6 -0
- data/docs/api/yard/HTM/Config.md +173 -0
- data/docs/api/yard/HTM/ConfigSection.md +28 -0
- data/docs/api/yard/HTM/Database.md +1 -1
- data/docs/api/yard/HTM/Railtie.md +2 -2
- data/docs/api/yard/HTM.md +0 -57
- data/docs/api/yard/index.csv +76 -61
- data/docs/api/yard-reference.md +2 -1
- data/docs/architecture/adrs/003-ollama-embeddings.md +45 -36
- data/docs/architecture/adrs/004-hive-mind.md +1 -1
- data/docs/architecture/adrs/008-robot-identification.md +1 -1
- data/docs/architecture/index.md +11 -9
- data/docs/architecture/overview.md +11 -7
- data/docs/assets/images/balanced-strategy-decay.svg +41 -0
- data/docs/assets/images/class-hierarchy.svg +1 -1
- data/docs/assets/images/eviction-priority.svg +43 -0
- data/docs/assets/images/exception-hierarchy.svg +2 -2
- data/docs/assets/images/hive-mind-shared-memory.svg +52 -0
- data/docs/assets/images/htm-architecture-overview.svg +3 -3
- data/docs/assets/images/htm-core-components.svg +4 -4
- data/docs/assets/images/htm-layered-architecture.svg +1 -1
- data/docs/assets/images/htm-memory-addition-flow.svg +2 -2
- data/docs/assets/images/htm-memory-recall-flow.svg +2 -2
- data/docs/assets/images/memory-topology.svg +53 -0
- data/docs/assets/images/two-tier-memory-architecture.svg +55 -0
- data/docs/development/setup.md +76 -44
- data/docs/examples/basic-usage.md +133 -0
- data/docs/examples/config-files.md +170 -0
- data/docs/examples/file-loading.md +208 -0
- data/docs/examples/index.md +116 -0
- data/docs/examples/llm-configuration.md +168 -0
- data/docs/examples/mcp-client.md +172 -0
- data/docs/examples/rails-integration.md +173 -0
- data/docs/examples/robot-groups.md +210 -0
- data/docs/examples/sinatra-integration.md +218 -0
- data/docs/examples/standalone-app.md +216 -0
- data/docs/examples/telemetry.md +224 -0
- data/docs/examples/timeframes.md +143 -0
- data/docs/getting-started/installation.md +97 -40
- data/docs/getting-started/quick-start.md +28 -11
- data/docs/guides/configuration.md +515 -0
- data/docs/guides/file-loading.md +322 -0
- data/docs/guides/getting-started.md +40 -9
- data/docs/guides/index.md +3 -3
- data/docs/guides/mcp-server.md +30 -12
- data/docs/guides/propositions.md +264 -0
- data/docs/guides/recalling-memories.md +4 -4
- data/docs/guides/search-strategies.md +3 -3
- data/docs/guides/tags.md +318 -0
- data/docs/guides/telemetry.md +229 -0
- data/docs/index.md +8 -16
- data/docs/{architecture → robots}/hive-mind.md +8 -111
- data/docs/robots/index.md +73 -0
- data/docs/{guides → robots}/multi-robot.md +3 -3
- data/docs/{guides → robots}/robot-groups.md +8 -7
- data/docs/{architecture → robots}/two-tier-memory.md +13 -149
- data/docs/robots/why-robots.md +85 -0
- data/lib/htm/config/defaults.yml +4 -4
- data/lib/htm/config.rb +2 -2
- data/lib/htm/job_adapter.rb +75 -1
- data/lib/htm/version.rb +1 -1
- data/lib/htm/workflows/remember_workflow.rb +212 -0
- data/lib/htm.rb +1 -0
- data/mkdocs.yml +33 -8
- metadata +60 -7
- data/docs/api/yard/HTM/Configuration.md +0 -240
- data/docs/telemetry.md +0 -391
|
@@ -6,64 +6,10 @@ HTM implements a sophisticated two-tier memory architecture that balances the co
|
|
|
6
6
|
|
|
7
7
|
The two-tier architecture addresses a fundamental challenge in LLM-based applications: LLMs have limited context windows but need to maintain awareness across long conversations spanning days, weeks, or months.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
<!-- Title -->
|
|
11
|
-
<text x="400" y="30" text-anchor="middle" fill="#E0E0E0" font-size="18" font-weight="bold">Two-Tier Memory Architecture</text>
|
|
12
|
-
|
|
13
|
-
<!-- Working Memory (Hot Tier) -->
|
|
14
|
-
<rect x="50" y="80" width="300" height="180" fill="rgba(33, 150, 243, 0.2)" stroke="#2196F3" stroke-width="3" rx="5"/>
|
|
15
|
-
<text x="200" y="110" text-anchor="middle" fill="#E0E0E0" font-size="16" font-weight="bold">Working Memory (Hot)</text>
|
|
16
|
-
<text x="80" y="140" fill="#B0B0B0" font-size="12">Capacity: Token-limited (128K)</text>
|
|
17
|
-
<text x="80" y="160" fill="#B0B0B0" font-size="12">Storage: In-memory Ruby Hash</text>
|
|
18
|
-
<text x="80" y="180" fill="#B0B0B0" font-size="12">Speed: O(1) lookups</text>
|
|
19
|
-
<text x="80" y="200" fill="#B0B0B0" font-size="12">Lifetime: Process lifetime</text>
|
|
20
|
-
<text x="80" y="220" fill="#B0B0B0" font-size="12">Eviction: Importance + Recency</text>
|
|
21
|
-
<text x="80" y="240" fill="#4CAF50" font-size="12" font-weight="bold">Fast, Token-Aware, Volatile</text>
|
|
22
|
-
|
|
23
|
-
<!-- Long-Term Memory (Cold Tier) -->
|
|
24
|
-
<rect x="450" y="80" width="300" height="180" fill="rgba(156, 39, 176, 0.2)" stroke="#9C27B0" stroke-width="3" rx="5"/>
|
|
25
|
-
<text x="600" y="110" text-anchor="middle" fill="#E0E0E0" font-size="16" font-weight="bold">Long-Term Memory (Cold)</text>
|
|
26
|
-
<text x="480" y="140" fill="#B0B0B0" font-size="12">Capacity: Unlimited</text>
|
|
27
|
-
<text x="480" y="160" fill="#B0B0B0" font-size="12">Storage: PostgreSQL + TimescaleDB</text>
|
|
28
|
-
<text x="480" y="180" fill="#B0B0B0" font-size="12">Speed: O(log n) with indexes</text>
|
|
29
|
-
<text x="480" y="200" fill="#B0B0B0" font-size="12">Lifetime: Permanent</text>
|
|
30
|
-
<text x="480" y="220" fill="#B0B0B0" font-size="12">Retrieval: RAG (semantic + temporal)</text>
|
|
31
|
-
<text x="480" y="240" fill="#4CAF50" font-size="12" font-weight="bold">Durable, Searchable, Persistent</text>
|
|
32
|
-
|
|
33
|
-
<!-- Data Flow: Add Memory -->
|
|
34
|
-
<path d="M 200 280 L 200 320 L 400 320 L 400 280" stroke="#4CAF50" stroke-width="3" fill="none" marker-end="url(#arrow-green)"/>
|
|
35
|
-
<text x="300" y="310" text-anchor="middle" fill="#4CAF50" font-size="12" font-weight="bold">Add Memory</text>
|
|
36
|
-
<text x="300" y="330" text-anchor="middle" fill="#B0B0B0" font-size="10">(Stored in both tiers)</text>
|
|
37
|
-
|
|
38
|
-
<!-- Data Flow: Eviction -->
|
|
39
|
-
<path d="M 350 360 L 600 360" stroke="#FF9800" stroke-width="3" marker-end="url(#arrow-orange)"/>
|
|
40
|
-
<text x="475" y="350" text-anchor="middle" fill="#FF9800" font-size="12" font-weight="bold">Eviction</text>
|
|
41
|
-
<text x="475" y="380" text-anchor="middle" fill="#B0B0B0" font-size="10">(Token limit → move to LTM only)</text>
|
|
42
|
-
|
|
43
|
-
<!-- Data Flow: Recall -->
|
|
44
|
-
<path d="M 600 400 L 200 400" stroke="#9C27B0" stroke-width="3" marker-end="url(#arrow-purple)"/>
|
|
45
|
-
<text x="400" y="390" text-anchor="middle" fill="#9C27B0" font-size="12" font-weight="bold">Recall</text>
|
|
46
|
-
<text x="400" y="420" text-anchor="middle" fill="#B0B0B0" font-size="10">(RAG search → load back to WM)</text>
|
|
47
|
-
|
|
48
|
-
<!-- Never Forget Note -->
|
|
49
|
-
<rect x="150" y="450" width="500" height="40" fill="rgba(76, 175, 80, 0.1)" stroke="#4CAF50" stroke-width="1" rx="3"/>
|
|
50
|
-
<text x="400" y="475" text-anchor="middle" fill="#4CAF50" font-size="13" font-weight="bold">Never Forget: Evicted memories stay in LTM forever (explicit deletion only)</text>
|
|
51
|
-
|
|
52
|
-
<defs>
|
|
53
|
-
<marker id="arrow-green" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto">
|
|
54
|
-
<polygon points="0 0, 10 3, 0 6" fill="#4CAF50"/>
|
|
55
|
-
</marker>
|
|
56
|
-
<marker id="arrow-orange" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto">
|
|
57
|
-
<polygon points="0 0, 10 3, 0 6" fill="#FF9800"/>
|
|
58
|
-
</marker>
|
|
59
|
-
<marker id="arrow-purple" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto">
|
|
60
|
-
<polygon points="0 0, 10 3, 0 6" fill="#9C27B0"/>
|
|
61
|
-
</marker>
|
|
62
|
-
</defs>
|
|
63
|
-
</svg>
|
|
9
|
+

|
|
64
10
|
|
|
65
11
|
!!! info "Related ADR"
|
|
66
|
-
See [ADR-002: Two-Tier Memory Architecture](adrs/002-two-tier-memory.md) for the complete architectural decision record.
|
|
12
|
+
See [ADR-002: Two-Tier Memory Architecture](../architecture/adrs/002-two-tier-memory.md) for the complete architectural decision record.
|
|
67
13
|
|
|
68
14
|
## Working Memory (Hot Tier)
|
|
69
15
|
|
|
@@ -209,55 +155,13 @@ Nodes are evicted in this order:
|
|
|
209
155
|
3. **High importance, old** (e.g., importance: 9.0, age: 5 days)
|
|
210
156
|
4. **High importance, recent** (e.g., importance: 9.0, age: 1 hour) ← **Kept longest**
|
|
211
157
|
|
|
212
|
-
|
|
213
|
-
<!-- Title -->
|
|
214
|
-
<text x="400" y="30" text-anchor="middle" fill="#E0E0E0" font-size="16" font-weight="bold">Eviction Priority (Lower → Higher retention)</text>
|
|
215
|
-
|
|
216
|
-
<!-- Priority bars -->
|
|
217
|
-
<rect x="50" y="80" width="150" height="50" fill="rgba(244, 67, 54, 0.6)" stroke="#F44336" stroke-width="2" rx="3"/>
|
|
218
|
-
<text x="125" y="110" text-anchor="middle" fill="#E0E0E0" font-size="12" font-weight="bold">Tier 1: Evict First</text>
|
|
219
|
-
|
|
220
|
-
<rect x="220" y="80" width="150" height="50" fill="rgba(255, 152, 0, 0.6)" stroke="#FF9800" stroke-width="2" rx="3"/>
|
|
221
|
-
<text x="295" y="110" text-anchor="middle" fill="#E0E0E0" font-size="12" font-weight="bold">Tier 2</text>
|
|
222
|
-
|
|
223
|
-
<rect x="390" y="80" width="150" height="50" fill="rgba(255, 193, 7, 0.6)" stroke="#FFC107" stroke-width="2" rx="3"/>
|
|
224
|
-
<text x="465" y="110" text-anchor="middle" fill="#E0E0E0" font-size="12" font-weight="bold">Tier 3</text>
|
|
225
|
-
|
|
226
|
-
<rect x="560" y="80" width="150" height="50" fill="rgba(76, 175, 80, 0.6)" stroke="#4CAF50" stroke-width="2" rx="3"/>
|
|
227
|
-
<text x="635" y="110" text-anchor="middle" fill="#E0E0E0" font-size="12" font-weight="bold">Tier 4: Keep Longest</text>
|
|
228
|
-
|
|
229
|
-
<!-- Details -->
|
|
230
|
-
<text x="125" y="160" text-anchor="middle" fill="#B0B0B0" font-size="11">Importance: 1.0</text>
|
|
231
|
-
<text x="125" y="180" text-anchor="middle" fill="#B0B0B0" font-size="11">Age: 5 days</text>
|
|
232
|
-
<text x="125" y="200" text-anchor="middle" fill="#F44336" font-size="10" font-weight="bold">Low value, stale</text>
|
|
233
|
-
|
|
234
|
-
<text x="295" y="160" text-anchor="middle" fill="#B0B0B0" font-size="11">Importance: 1.0</text>
|
|
235
|
-
<text x="295" y="180" text-anchor="middle" fill="#B0B0B0" font-size="11">Age: 1 hour</text>
|
|
236
|
-
<text x="295" y="200" text-anchor="middle" fill="#FF9800" font-size="10" font-weight="bold">Low value, recent</text>
|
|
237
|
-
|
|
238
|
-
<text x="465" y="160" text-anchor="middle" fill="#B0B0B0" font-size="11">Importance: 9.0</text>
|
|
239
|
-
<text x="465" y="180" text-anchor="middle" fill="#B0B0B0" font-size="11">Age: 5 days</text>
|
|
240
|
-
<text x="465" y="200" text-anchor="middle" fill="#FFC107" font-size="10" font-weight="bold">High value, older</text>
|
|
241
|
-
|
|
242
|
-
<text x="635" y="160" text-anchor="middle" fill="#B0B0B0" font-size="11">Importance: 9.0</text>
|
|
243
|
-
<text x="635" y="180" text-anchor="middle" fill="#B0B0B0" font-size="11">Age: 1 hour</text>
|
|
244
|
-
<text x="635" y="200" text-anchor="middle" fill="#4CAF50" font-size="10" font-weight="bold">High value, fresh</text>
|
|
245
|
-
|
|
246
|
-
<!-- Example scenario -->
|
|
247
|
-
<text x="50" y="250" fill="#E0E0E0" font-size="13" font-weight="bold">Example Eviction Scenario:</text>
|
|
248
|
-
<text x="50" y="280" fill="#B0B0B0" font-size="11">Working Memory: 127,500 / 128,000 tokens (99% full)</text>
|
|
249
|
-
<text x="50" y="300" fill="#B0B0B0" font-size="11">New memory to add: 5,000 tokens</text>
|
|
250
|
-
<text x="50" y="320" fill="#B0B0B0" font-size="11">Need to free: 4,500 tokens</text>
|
|
251
|
-
|
|
252
|
-
<text x="50" y="350" fill="#4CAF50" font-size="11">Eviction: Remove Tier 1 and Tier 2 nodes until 4,500+ tokens freed</text>
|
|
253
|
-
<text x="50" y="370" fill="#4CAF50" font-size="11">Result: Tier 3 and Tier 4 nodes preserved (high importance)</text>
|
|
254
|
-
</svg>
|
|
158
|
+

|
|
255
159
|
|
|
256
160
|
!!! warning "Importance Matters"
|
|
257
161
|
**Assign meaningful importance scores!** Low-importance memories (1.0-3.0) will be evicted first. Use higher scores (7.0-10.0) for critical information like architectural decisions, user preferences, and long-term facts.
|
|
258
162
|
|
|
259
163
|
!!! info "Related ADR"
|
|
260
|
-
See [ADR-007: Working Memory Eviction Strategy](adrs/007-eviction-strategy.md) for detailed rationale and alternatives considered.
|
|
164
|
+
See [ADR-007: Working Memory Eviction Strategy](../architecture/adrs/007-eviction-strategy.md) for detailed rationale and alternatives considered.
|
|
261
165
|
|
|
262
166
|
### Context Assembly Strategies
|
|
263
167
|
|
|
@@ -352,50 +256,10 @@ context = htm.create_context(strategy: :balanced)
|
|
|
352
256
|
# Recent debugging context + important architectural decisions
|
|
353
257
|
```
|
|
354
258
|
|
|
355
|
-
|
|
356
|
-
<!-- Title -->
|
|
357
|
-
<text x="400" y="30" text-anchor="middle" fill="#E0E0E0" font-size="16" font-weight="bold">Balanced Strategy: Importance Decay Over Time</text>
|
|
358
|
-
|
|
359
|
-
<!-- Axes -->
|
|
360
|
-
<line x1="100" y1="350" x2="700" y2="350" stroke="#808080" stroke-width="2"/>
|
|
361
|
-
<line x1="100" y1="350" x2="100" y2="80" stroke="#808080" stroke-width="2"/>
|
|
362
|
-
|
|
363
|
-
<!-- X-axis labels -->
|
|
364
|
-
<text x="100" y="375" text-anchor="middle" fill="#B0B0B0" font-size="11">0h</text>
|
|
365
|
-
<text x="250" y="375" text-anchor="middle" fill="#B0B0B0" font-size="11">1h</text>
|
|
366
|
-
<text x="400" y="375" text-anchor="middle" fill="#B0B0B0" font-size="11">3h</text>
|
|
367
|
-
<text x="550" y="375" text-anchor="middle" fill="#B0B0B0" font-size="11">6h</text>
|
|
368
|
-
<text x="700" y="375" text-anchor="middle" fill="#B0B0B0" font-size="11">24h</text>
|
|
369
|
-
<text x="400" y="395" text-anchor="middle" fill="#E0E0E0" font-size="12" font-weight="bold">Time Since Added (hours)</text>
|
|
370
|
-
|
|
371
|
-
<!-- Y-axis labels -->
|
|
372
|
-
<text x="85" y="355" text-anchor="end" fill="#B0B0B0" font-size="11">0</text>
|
|
373
|
-
<text x="85" y="280" text-anchor="end" fill="#B0B0B0" font-size="11">3</text>
|
|
374
|
-
<text x="85" y="205" text-anchor="end" fill="#B0B0B0" font-size="11">6</text>
|
|
375
|
-
<text x="85" y="130" text-anchor="end" fill="#B0B0B0" font-size="11">9</text>
|
|
376
|
-
<text x="85" y="85" text-anchor="end" fill="#B0B0B0" font-size="11">10</text>
|
|
377
|
-
<text x="40" y="220" text-anchor="middle" fill="#E0E0E0" font-size="12" font-weight="bold" transform="rotate(-90 40 220)">Effective Score</text>
|
|
378
|
-
|
|
379
|
-
<!-- Decay curves for different importance levels -->
|
|
380
|
-
<!-- Importance 10.0 -->
|
|
381
|
-
<path d="M 100 80 Q 250 105 400 155 T 700 320" stroke="#4CAF50" stroke-width="3" fill="none"/>
|
|
382
|
-
<text x="710" y="320" fill="#4CAF50" font-size="11" font-weight="bold">Imp: 10.0</text>
|
|
383
|
-
|
|
384
|
-
<!-- Importance 5.0 -->
|
|
385
|
-
<path d="M 100 205 Q 250 230 400 255 T 700 335" stroke="#2196F3" stroke-width="3" fill="none"/>
|
|
386
|
-
<text x="710" y="335" fill="#2196F3" font-size="11" font-weight="bold">Imp: 5.0</text>
|
|
387
|
-
|
|
388
|
-
<!-- Importance 1.0 -->
|
|
389
|
-
<path d="M 100 330 Q 250 340 400 345 T 700 348" stroke="#FF9800" stroke-width="3" fill="none"/>
|
|
390
|
-
<text x="710" y="348" fill="#FF9800" font-size="11" font-weight="bold">Imp: 1.0</text>
|
|
391
|
-
|
|
392
|
-
<!-- Key insight -->
|
|
393
|
-
<rect x="150" y="50" width="500" height="25" fill="rgba(76, 175, 80, 0.1)" stroke="#4CAF50" stroke-width="1" rx="3"/>
|
|
394
|
-
<text x="400" y="68" text-anchor="middle" fill="#4CAF50" font-size="12">High-importance memories retain value longer, but recency still matters</text>
|
|
395
|
-
</svg>
|
|
259
|
+

|
|
396
260
|
|
|
397
261
|
!!! info "Related ADR"
|
|
398
|
-
See [ADR-006: Context Assembly Strategies](adrs/006-context-assembly.md) for detailed strategy analysis.
|
|
262
|
+
See [ADR-006: Context Assembly Strategies](../architecture/adrs/006-context-assembly.md) for detailed strategy analysis.
|
|
399
263
|
|
|
400
264
|
### Performance Characteristics
|
|
401
265
|
|
|
@@ -474,7 +338,7 @@ CREATE INDEX idx_nodes_value_gin ON nodes
|
|
|
474
338
|
- Retention policies for data lifecycle
|
|
475
339
|
|
|
476
340
|
!!! info "Related ADR"
|
|
477
|
-
See [ADR-001: Use PostgreSQL with TimescaleDB for Storage](adrs/001-postgresql-timescaledb.md) for complete rationale.
|
|
341
|
+
See [ADR-001: Use PostgreSQL with TimescaleDB for Storage](../architecture/adrs/001-postgresql-timescaledb.md) for complete rationale.
|
|
478
342
|
|
|
479
343
|
### Long-Term Memory Operations
|
|
480
344
|
|
|
@@ -560,7 +424,7 @@ end
|
|
|
560
424
|
```
|
|
561
425
|
|
|
562
426
|
!!! info "Related ADR"
|
|
563
|
-
See [ADR-005: RAG-Based Retrieval with Hybrid Search](adrs/005-rag-retrieval.md) for search strategy details.
|
|
427
|
+
See [ADR-005: RAG-Based Retrieval with Hybrid Search](../architecture/adrs/005-rag-retrieval.md) for search strategy details.
|
|
564
428
|
|
|
565
429
|
### RAG-Based Retrieval
|
|
566
430
|
|
|
@@ -831,9 +695,9 @@ LIMIT 20;
|
|
|
831
695
|
|
|
832
696
|
## Related Documentation
|
|
833
697
|
|
|
834
|
-
- [Architecture Index](index.md) - System overview and component summary
|
|
835
|
-
- [Architecture Overview](overview.md) - Detailed architecture and data flows
|
|
698
|
+
- [Architecture Index](../architecture/index.md) - System overview and component summary
|
|
699
|
+
- [Architecture Overview](../architecture/overview.md) - Detailed architecture and data flows
|
|
836
700
|
- [Hive Mind Architecture](hive-mind.md) - Multi-robot shared memory
|
|
837
|
-
- [ADR-002: Two-Tier Memory Architecture](adrs/002-two-tier-memory.md)
|
|
838
|
-
- [ADR-006: Context Assembly Strategies](adrs/006-context-assembly.md)
|
|
839
|
-
- [ADR-007: Working Memory Eviction Strategy](adrs/007-eviction-strategy.md)
|
|
701
|
+
- [ADR-002: Two-Tier Memory Architecture](../architecture/adrs/002-two-tier-memory.md)
|
|
702
|
+
- [ADR-006: Context Assembly Strategies](../architecture/adrs/006-context-assembly.md)
|
|
703
|
+
- [ADR-007: Working Memory Eviction Strategy](../architecture/adrs/007-eviction-strategy.md)
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# Why "Robots" Instead of "Agents"?
|
|
2
|
+
|
|
3
|
+
> "What's in a name? That which we call a rose
|
|
4
|
+
> By any other name would smell as sweet."
|
|
5
|
+
> — Shakespeare, *Romeo and Juliet*
|
|
6
|
+
|
|
7
|
+
Shakespeare argues names are arbitrary. In software, we respectfully disagree—names shape expectations and understanding. The words we choose frame how we think about systems, what we expect from them, and how we architect their capabilities.
|
|
8
|
+
|
|
9
|
+
HTM uses **robots** rather than the fashionable "agents" deliberately and thoughtfully.
|
|
10
|
+
|
|
11
|
+
## The Problem with "Agent"
|
|
12
|
+
|
|
13
|
+
The term "agent" carries philosophical baggage it cannot support:
|
|
14
|
+
|
|
15
|
+
- **Semantic overload**: User agents, software agents, real estate agents, secret agents, FBI agents, travel agents. The word means everything and therefore nothing. When you say "AI agent," what mental model does your listener construct?
|
|
16
|
+
|
|
17
|
+
- **False autonomy**: "Agent" implies genuine decision-making, independent action, perhaps even free will. These systems follow instructions. They predict the next token. They don't have *agency* in any meaningful philosophical sense. Calling them agents sets expectations the technology cannot meet.
|
|
18
|
+
|
|
19
|
+
- **The hype cycle problem**: "AI Agent" and "Agentic AI" became buzzwords in 2023-2024, often meaning nothing more than "LLM with a prompt and a while loop." We prefer terminology that will age gracefully rather than become an embarrassing artifact of a particular moment's enthusiasm.
|
|
20
|
+
|
|
21
|
+
- **Implementation reality**: Look under the hood of popular "agent" frameworks. You'll often find a system prompt, a for-loop, and some JSON parsing. Calling that an "agent" is marketing, not engineering.
|
|
22
|
+
|
|
23
|
+
## The Case for "Robot"
|
|
24
|
+
|
|
25
|
+
"Robot" has heritage, honesty, and heart:
|
|
26
|
+
|
|
27
|
+
- **Rich literary tradition**: The word comes from Karel Čapek's 1920 play *R.U.R.* (Rossum's Universal Robots), derived from Czech *robota*, meaning forced labor or drudgery. Isaac Asimov gave us the Three Laws of Robotics and decades of thoughtful exploration of robot ethics, identity, and purpose. There's a century of serious thinking about what robots are and how they should behave. "Agent" has no comparable intellectual foundation.
|
|
28
|
+
|
|
29
|
+
- **Honest about the relationship**: Robots work for us. They're tireless, reliable, and purpose-built. They don't pretend to have goals independent of their creators. This honesty about the master-worker relationship is healthier than the ambiguity of "agent."
|
|
30
|
+
|
|
31
|
+
- **Cultural resonance**: Robots are endearing. R2-D2. Wall-E. Bender. Data. The Iron Giant. Baymax. We've spent a century telling stories about robots, developing affection for them, and exploring their place alongside humanity. "Agent" has no such cultural weight—it's the language of bureaucracy and espionage.
|
|
32
|
+
|
|
33
|
+
- **Technical precision**: In HTM, each robot has an identity (`robot_id`), a name, and a history of contributions. Robots are registered in a table. They're tracked. They're *things* with identity and persistence. "Agent" suggests ephemerality; "robot" suggests durability.
|
|
34
|
+
|
|
35
|
+
## Robots in the Hive Mind
|
|
36
|
+
|
|
37
|
+
HTM's architecture reinforces the robot metaphor in a specific way: **all robots share a common long-term memory**.
|
|
38
|
+
|
|
39
|
+
This is the *hive mind* pattern. Individual robots have their own working memory—their own immediate context and focus—but they draw from and contribute to a shared pool of knowledge. Like worker bees serving a hive, each robot is both individual and part of something larger.
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
┌─────────────────────────────────────────────────────┐
|
|
43
|
+
│ Shared Long-Term Memory │
|
|
44
|
+
│ (The Hive Mind / Collective) │
|
|
45
|
+
│ │
|
|
46
|
+
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
|
|
47
|
+
│ │ Memory │ │ Memory │ │ Memory │ ... │
|
|
48
|
+
│ └─────────┘ └─────────┘ └─────────┘ │
|
|
49
|
+
└─────────────────────────────────────────────────────┘
|
|
50
|
+
▲ ▲ ▲
|
|
51
|
+
│ │ │
|
|
52
|
+
┌────┴────┐ ┌────┴────┐ ┌────┴────┐
|
|
53
|
+
│ Robot A │ │ Robot B │ │ Robot C │
|
|
54
|
+
│ │ │ │ │ │
|
|
55
|
+
│ Working │ │ Working │ │ Working │
|
|
56
|
+
│ Memory │ │ Memory │ │ Memory │
|
|
57
|
+
└─────────┘ └─────────┘ └─────────┘
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
This architecture maps naturally to the robot metaphor:
|
|
61
|
+
|
|
62
|
+
- **Robots are workers**: They execute tasks, store memories, recall information
|
|
63
|
+
- **Robots are individuals**: Each has its own name, identity, and working context
|
|
64
|
+
- **Robots are collective**: They share knowledge, learn from each other's experiences
|
|
65
|
+
- **Robots are persistent**: They're registered, tracked, and their contributions are attributed
|
|
66
|
+
|
|
67
|
+
"Agent" suggests independence and autonomy. "Robot" suggests collaboration and purpose. HTM's robots work together, building collective intelligence. That's what the terminology should convey.
|
|
68
|
+
|
|
69
|
+
## Robots Never Forget
|
|
70
|
+
|
|
71
|
+
HTM follows a **never-forget philosophy** (see [ADR-009](../architecture/adrs/009-never-forget.md)). Memories are never truly deleted—only soft-deleted, always recoverable. This aligns with the robot metaphor:
|
|
72
|
+
|
|
73
|
+
A good robot doesn't lose your data. A good robot remembers what you told it, years later if necessary. A good robot is *reliable* in a way that ephemeral "agents" are not.
|
|
74
|
+
|
|
75
|
+
When you tell an HTM robot something important, it stores that information in the collective memory. Other robots can access it. Future robots can learn from it. The knowledge persists, attributed to the robot that first contributed it.
|
|
76
|
+
|
|
77
|
+
This is robot memory done right: durable, shared, and faithful.
|
|
78
|
+
|
|
79
|
+
## Honest Terminology, Clear Thinking
|
|
80
|
+
|
|
81
|
+
Language shapes thought. When we call these systems "agents," we prime ourselves to expect agency—goals, autonomy, perhaps even consciousness. When we call them "robots," we remind ourselves what they actually are: sophisticated tools, tireless workers, faithful servants of the instructions we give them.
|
|
82
|
+
|
|
83
|
+
HTM helps robots do their job better: remember perfectly, recall intelligently, share knowledge generously, and serve reliably. That's not agency. That's good engineering.
|
|
84
|
+
|
|
85
|
+
These are robots. Let's call them what they are.
|
data/lib/htm/config/defaults.yml
CHANGED
|
@@ -112,7 +112,7 @@ defaults:
|
|
|
112
112
|
provider: ollama
|
|
113
113
|
model: gemma3:latest
|
|
114
114
|
timeout: 180
|
|
115
|
-
enabled:
|
|
115
|
+
enabled: true
|
|
116
116
|
|
|
117
117
|
system_prompt: |
|
|
118
118
|
You are an atomic fact extraction system. Your goal is maximum decomposition.
|
|
@@ -167,14 +167,14 @@ defaults:
|
|
|
167
167
|
# Access: HTM.config.job.backend
|
|
168
168
|
# ---------------------------------------------------------------------------
|
|
169
169
|
job:
|
|
170
|
-
backend:
|
|
170
|
+
backend: fiber
|
|
171
171
|
|
|
172
172
|
# ---------------------------------------------------------------------------
|
|
173
173
|
# General Settings
|
|
174
174
|
# Access: HTM.config.week_start, HTM.config.connection_timeout, etc.
|
|
175
175
|
# ---------------------------------------------------------------------------
|
|
176
176
|
week_start: sunday
|
|
177
|
-
connection_timeout:
|
|
177
|
+
connection_timeout: 60
|
|
178
178
|
telemetry_enabled: false
|
|
179
179
|
log_level: info
|
|
180
180
|
|
|
@@ -197,7 +197,7 @@ defaults:
|
|
|
197
197
|
azure:
|
|
198
198
|
api_key: ~
|
|
199
199
|
endpoint: ~
|
|
200
|
-
api_version:
|
|
200
|
+
api_version: "2024-02-01"
|
|
201
201
|
|
|
202
202
|
ollama:
|
|
203
203
|
url: http://localhost:11434
|
data/lib/htm/config.rb
CHANGED
|
@@ -221,7 +221,7 @@ class HTM
|
|
|
221
221
|
huggingface openrouter bedrock deepseek
|
|
222
222
|
].freeze
|
|
223
223
|
|
|
224
|
-
SUPPORTED_JOB_BACKENDS = %i[active_job sidekiq inline thread].freeze
|
|
224
|
+
SUPPORTED_JOB_BACKENDS = %i[active_job sidekiq inline thread fiber].freeze
|
|
225
225
|
SUPPORTED_WEEK_STARTS = %i[sunday monday].freeze
|
|
226
226
|
|
|
227
227
|
# Default embedding dimensions by provider
|
|
@@ -714,7 +714,7 @@ class HTM
|
|
|
714
714
|
return :active_job if defined?(ActiveJob)
|
|
715
715
|
return :sidekiq if defined?(Sidekiq)
|
|
716
716
|
|
|
717
|
-
:
|
|
717
|
+
:fiber
|
|
718
718
|
end
|
|
719
719
|
|
|
720
720
|
def build_default_logger
|
data/lib/htm/job_adapter.rb
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'async'
|
|
4
|
+
require 'async/barrier'
|
|
5
|
+
|
|
3
6
|
class HTM
|
|
4
7
|
# Job adapter for pluggable background job backends
|
|
5
8
|
#
|
|
@@ -11,6 +14,7 @@ class HTM
|
|
|
11
14
|
# - :sidekiq - Direct Sidekiq integration (recommended for Sinatra apps)
|
|
12
15
|
# - :inline - Synchronous execution (recommended for CLI and tests)
|
|
13
16
|
# - :thread - Background thread (legacy, for standalone apps)
|
|
17
|
+
# - :fiber - Fiber-based concurrency using async gem (recommended for I/O-bound jobs)
|
|
14
18
|
#
|
|
15
19
|
# @example Configure job backend
|
|
16
20
|
# HTM.configure do |config|
|
|
@@ -44,8 +48,10 @@ class HTM
|
|
|
44
48
|
enqueue_inline(job_class, **params)
|
|
45
49
|
when :thread
|
|
46
50
|
enqueue_thread(job_class, **params)
|
|
51
|
+
when :fiber
|
|
52
|
+
enqueue_fiber(job_class, **params)
|
|
47
53
|
else
|
|
48
|
-
raise HTM::Error, "Unknown job backend: #{backend}. Supported backends: :active_job, :sidekiq, :inline, :thread"
|
|
54
|
+
raise HTM::Error, "Unknown job backend: #{backend}. Supported backends: :active_job, :sidekiq, :inline, :thread, :fiber"
|
|
49
55
|
end
|
|
50
56
|
end
|
|
51
57
|
|
|
@@ -98,6 +104,74 @@ class HTM
|
|
|
98
104
|
HTM.logger.error "Failed to start thread for #{job_class.name}: #{e.message}"
|
|
99
105
|
end
|
|
100
106
|
|
|
107
|
+
# Execute job using async gem (fiber-based concurrency)
|
|
108
|
+
# Non-blocking for I/O-bound operations like LLM API calls
|
|
109
|
+
def enqueue_fiber(job_class, **params)
|
|
110
|
+
Async do
|
|
111
|
+
begin
|
|
112
|
+
job_class.perform(**params)
|
|
113
|
+
rescue StandardError => e
|
|
114
|
+
HTM.logger.error "Fiber job #{job_class.name} failed: #{e.class.name} - #{e.message}"
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
rescue StandardError => e
|
|
118
|
+
HTM.logger.error "Failed to start fiber for #{job_class.name}: #{e.message}"
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
public
|
|
122
|
+
|
|
123
|
+
# Execute multiple jobs in parallel using fibers
|
|
124
|
+
# Best for I/O-bound jobs like LLM API calls
|
|
125
|
+
#
|
|
126
|
+
# @param jobs [Array<Array>] Array of [job_class, params] pairs
|
|
127
|
+
# @return [void]
|
|
128
|
+
#
|
|
129
|
+
# @example Run embedding and tags jobs in parallel
|
|
130
|
+
# JobAdapter.enqueue_parallel([
|
|
131
|
+
# [GenerateEmbeddingJob, { node_id: 123 }],
|
|
132
|
+
# [GenerateTagsJob, { node_id: 123 }]
|
|
133
|
+
# ])
|
|
134
|
+
#
|
|
135
|
+
def enqueue_parallel(jobs)
|
|
136
|
+
return if jobs.empty?
|
|
137
|
+
|
|
138
|
+
backend = HTM.configuration.job_backend
|
|
139
|
+
|
|
140
|
+
case backend
|
|
141
|
+
when :fiber
|
|
142
|
+
enqueue_parallel_fiber(jobs)
|
|
143
|
+
when :inline
|
|
144
|
+
# Run sequentially for inline backend
|
|
145
|
+
jobs.each { |job_class, params| enqueue_inline(job_class, **params) }
|
|
146
|
+
else
|
|
147
|
+
# For other backends, enqueue each job separately
|
|
148
|
+
jobs.each { |job_class, params| enqueue(job_class, **params) }
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
private
|
|
153
|
+
|
|
154
|
+
# Execute multiple jobs in parallel using async fibers
|
|
155
|
+
def enqueue_parallel_fiber(jobs)
|
|
156
|
+
Async do |task|
|
|
157
|
+
barrier = Async::Barrier.new
|
|
158
|
+
|
|
159
|
+
jobs.each do |job_class, params|
|
|
160
|
+
barrier.async do
|
|
161
|
+
begin
|
|
162
|
+
job_class.perform(**params)
|
|
163
|
+
rescue StandardError => e
|
|
164
|
+
HTM.logger.error "Parallel fiber job #{job_class.name} failed: #{e.class.name} - #{e.message}"
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
barrier.wait
|
|
170
|
+
end
|
|
171
|
+
rescue StandardError => e
|
|
172
|
+
HTM.logger.error "Failed to start parallel fibers: #{e.message}"
|
|
173
|
+
end
|
|
174
|
+
|
|
101
175
|
# Convert HTM job class to ActiveJob class
|
|
102
176
|
def to_active_job_class(job_class)
|
|
103
177
|
# If it's already an ActiveJob, return it
|
data/lib/htm/version.rb
CHANGED