π The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated
ADR-073: Stub Tool Honesty & Real Predictions
Status: Accepted
Date: 2026-04-06 (updated v3.5.59)
Context: Issue #1514 (independent audit), Issues #1058, #1516, #1518, #1521, #1526, #1530, #1531, #1538, PR #1539
Decision
1. Remove fabricated metrics from token-optimizer
The TokenOptimizer class (@claude-flow/integration) contained hardcoded savings numbers:
| Before | After |
|---|---|
totalTokensSaved += 100 per cache hit |
Removed β cache hits tracked but no fabricated token count |
baseline = 1000 (hardcoded) |
queryTokenEstimate = query.length / 4 (actual content size) |
totalTokensSaved += 50 per edit |
Removed β edit count tracked, savings not fabricated |
executionMs: 352 fallback |
executionMs: 0 (honest: no optimization occurred) |
2. Make getOptimalConfig() responsive to agentCount
Previously returned identical config regardless of input. Now scales:
| Agent Count | Batch Size | Topology | Cache (MB) |
|---|---|---|---|
| 1-2 | 2 | hierarchical | 25 |
| 3-4 | 2 | hierarchical | 50 |
| 5-6 | 4 | hierarchical | 75 |
| 7-8 | 4 | hierarchical-mesh | 100 |
| 9-12 | 6 | hierarchical-mesh | 125-150 |
| 13+ | 6 | mesh | 175-200 |
Formula: batchSize = agentCount<=4?2 : agentCount<=8?4 : 6, cacheSizeMB = min(200, 25*ceil(agentCount/2))
3. Wire neural_predict to real embedding similarity
Previously: hardcoded labels ['coder', 'researcher', 'reviewer', 'tester'] with random confidence.
Now:
- If stored patterns exist: generates real embedding for input, computes cosine similarity against all stored pattern embeddings, returns top-K nearest neighbors
- If no patterns stored: returns empty array
[](no fake labels, no simulated data) - All results include
_realEmbedding(bool: ML model loaded) and_hasStoredPatterns(bool: patterns available) transparency flags
4. neural_train stores real embeddings
Training now generates real embeddings for each training data entry (via ML model or deterministic hash fallback) and stores them as searchable patterns. Accuracy is 1.0 if patterns were stored, 0 otherwise β not simulated. Cosine similarity search against these stored embeddings produces real nearest-neighbor results.
5. Fix bare model names (#1516)
All embedding model defaults now use Xenova/ prefix (e.g., Xenova/all-MiniLM-L6-v2) so @xenova/transformers can resolve them.
6. Fix intelligence data bloat (#1518, #1526)
- Deduplicate store entries by ID before building graph (v3.5.54: also persist deduped store in consolidate via
preDedupCounttracking) - Applied dedup to both v3 and root intelligence.cjs copies
- Scope
bootstrapFromMemoryFiles()to current project only (was scanning all 51+ project dirs) - Fix
tool_inputsnake_case mismatch in hook-handler
7. Deep audit Math.random() removal (v3.5.56)
agent_healthaggregate: replaced Math.random() CPU/memory/latency withnull+_notesystem_health: replaced hardcoded "healthy" + random latency with realfs.existsSync()checks timed withperformance.now()system_status: replaced hardcoded component health (0.95, 0.90, 1.0) withstatus: 'unknown'coordination_metrics: replaced Math.random() with null + real sync countsgithub-tools: all 5 tools return_stub: true, Math.random() removedneural_compressandneural_optimize: return_stub: trueperformance bottleneck/profile/optimize: return_stub: true, profile no longer sleeps 100mshooks_metrics: reads real counts from memory storehooks_pretrain: returns_stub: truehooks_intelligence-reset: actually deletes data files nowhooks_session-end: reads real task/file/agent countshooks_explain: reads real success rate from routing-outcomes.jsonhooks_transfer: returns failure instead of substituting demo dataworkflow_execute/resume: steps stay pending, don't auto-completetask-tools: fixed path mismatchagents.jsonβagents/store.jsonsession_restore: syncs to sql.js database after writing legacy JSONclaims_rebalance: executes moves whendryRun=falseconfig get: callsconfigManager.get()instead of hardcoded mapprocess monitor: uses realos.loadavg(),process.memoryUsage()process logs: reads actual log filesstatus: flashAttention/searchSpeed β'not measured'token-optimizer: removed double-increment ofeditsOptimized
8. Remaining stub cleanup (v3.5.57)
daa_agent_adapt: removed fake 50ms setTimeout delaydaa_workflow_execute: steps stay pending instead of auto-completingdaa_cognitive_pattern: replaced hardcoded analysis with real agent metricsdaa_knowledge_share: added_noteclarifying no cross-agent transferhooks_intelligence_attention: removedMath.exp(-i*0.5)fake sigmoid weights, returns empty with_stub: truewhen no backendsystem_reset+loadMetrics(): use realos.loadavg()/os.totalmem()instead of hardcoded cpu:25, memory:256/1024benchmarkCLI: honest zero fallback instead of hardcodedsearchTime: 0.5embeddingsCLI: "Skipped" instead of "Simulated"providersCLI: clarifying comment on static catalogsystem_metrics: wired up real agent/task counters from store files
9. Real implementations & AgentDB integration (v3.5.59, PR #1539)
Three performance tool stubs replaced with real implementations:
performance_bottleneck: Real CPU load (os.loadavg()), memory (process.memoryUsage()), disk I/O latency (4KB write/read probe), severity classificationperformance_profile: Real V8 profiling withprocess.cpuUsage(),performance.now(), operation hotspot detection across memory/io/cpu targetsperformance_optimize: Real before/after system snapshots, GC collection (when--expose-gc), bottleneck-informed recommendations
Two neural tool stubs replaced with real implementations:
neural_compress: Three real methods β quantize (Int8 viaquantizeInt8()from memory-initializer, 3.92x compression), prune (remove low-usage patterns), distill (merge by cosine similarity > 0.95)neural_optimize: Target-aware β speed (dedup by hash+cosine), memory (Int8 quantization), accuracy (prune zero-norm embeddings), balanced (all three)
MCP request tracking:
- New
request-tracker.tssingleton counter module tracks tool invocations in-process - Wired into
mcp-server.ts(success/error paths) system_metricsreads live counts instead of stale JSON
AgentDB integration (primary data layer with JSON fallback):
hive-mindconsensus results βhive-consensusnamespacehive-mindshared memory βhive-memorynamespacedaa_agent_createβdaa-agentsnamespacedaa_workflow_executeβdaa-workflowsnamespace- All AgentDB writes are after JSON store save, in
try/catchβ backward compatible
TypeScript fixes:
- Zero TS compilation errors for first time β added ambient type declarations for 7 optional packages
- Fixed
unknown[]casts in embeddings.ts,registry as anyin memory-bridge.ts
Test coverage:
- 28 honesty tests (source-level checks for fabrication patterns)
- 30 feature-gap tests (verify real implementations, AgentDB integration, request tracking)
Consequences
- Token optimizer reports honest numbers (will show 0 savings when agentic-flow is not installed)
neural_predictreturns real cosine similarity results when patterns stored, empty array when notneural_trainstores real embeddings, no simulated accuracy- Zero instances of
Math.random()for confidence/accuracy/metrics in shipped code - Zero instances of
setTimeout()for fake delays in shipped code - All remaining stubs marked
_stub: true; all real tools marked_real: true - Users can distinguish real ML vs hash-based embedding via
_realEmbeddingflag hooks explainmatchScore uses real keyword ratio instead of randomsystem_metricsreturns real agent/task/request counts from persistent stores and live trackerperformance_bottleneck/profile/optimizeare fully real (V8 profiling, OS metrics, disk I/O)neural_compress/optimizeare fully real (Int8 quantization, cosine similarity, pruning)- AgentDB is primary data layer for hive-mind and DAA tools with JSON store backward compat
- 58 automated tests enforce honesty invariants and real implementation requirements
Tools Status (Post-Fix)
| Category | Status | Notes |
|---|---|---|
| Memory/HNSW | Real | Vector search, persistence, embeddings |
| AgentDB | Real | Pattern store, hierarchical recall, HNSW; primary layer for hive-mind + DAA |
| Embeddings | Real | Xenova/transformers, cosine similarity |
| Neural predict | Real (with patterns) | Cosine similarity search; empty array when no patterns |
| Neural train | Real | Embeds training data, stores as searchable patterns |
| Neural compress | Real (v3.5.59) | Int8 quantize (3.92x), prune, distill (cosine > 0.95) |
| Neural optimize | Real (v3.5.59) | Target-aware: speed/memory/accuracy/balanced |
| Performance bottleneck | Real (v3.5.59) | CPU load, memory, disk I/O latency, severity classification |
| Performance profile | Real (v3.5.59) | V8 cpuUsage, memoryUsage, operation hotspots |
| Performance optimize | Real (v3.5.59) | GC collect, before/after snapshots, recommendations |
| Token optimizer | Honest metrics | No fabricated numbers |
| Agent spawn/task | Real state tracking | Store persistence via agents/store.json |
| DAA tools | Real + AgentDB (v3.5.59) | Local state + AgentDB persistence, no fake delays |
| System metrics | Real + live tracker (v3.5.59) | CPU/memory from os, agents/tasks from stores, requests from tracker |
| Hive-mind | Real + AgentDB (v3.5.59) | Vote counting + AgentDB persistence for consensus + shared memory |
| WASM agents | Stub | Echo-based, no WASM runtime |