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
let score = (results.metadatas[0].length- index) *queryScoreWeights.baseIncrement;
273
-
273
+
274
274
queryWords.forEach(queryWord=> {
275
275
constkeyword= queryWord;
276
-
constkeywordSingular=keyword.endsWith('s')
277
-
?keyword.slice(0, -1)
276
+
constkeywordSingular=keyword.endsWith('s')
277
+
?keyword.slice(0, -1)
278
278
: keyword;
279
-
279
+
280
280
if (keywordSingular.length>2) {
281
281
// Path matching - highest weight
282
-
if (sourcePathLower.includes(`/${keywordSingular}/`))
282
+
if (sourcePathLower.includes(`/${keywordSingular}/`))
283
283
score +=queryScoreWeights.sourcePathMatch; // +40
284
-
284
+
285
285
// Filename matching
286
-
if (fileName.includes(keywordSingular))
286
+
if (fileName.includes(keywordSingular))
287
287
score +=queryScoreWeights.fileNameMatch; // +30
288
-
288
+
289
289
// Class name matching
290
-
if (metadata.className?.toLowerCase().includes(keywordSingular))
290
+
if (metadata.className?.toLowerCase().includes(keywordSingular))
291
291
score +=queryScoreWeights.classNameMatch; // +20
292
-
292
+
293
293
// Content type bonuses
294
-
if (metadata.type==='guide')
294
+
if (metadata.type==='guide')
295
295
score +=queryScoreWeights.guideMatch; // +50
296
296
}
297
297
});
@@ -451,13 +451,277 @@ If the Knowledge Base is the AI's understanding of the *project*, the **Memory C
451
451
452
452
Every interaction—every prompt, thought process, and response—is captured and stored as a "memory." This is not just a chat log; it's a structured, queryable history of the agent's own work. When a new session begins, the Memory Core automatically analyzes and summarizes all previous, unsummarized sessions. This creates a high-level "recap" of past work, allowing the agent to remember what it did, what decisions it made, and why.
453
453
454
+
#### The Save-Then-Respond Protocol
455
+
456
+
At the heart of the Memory Core is the **transactional memory protocol**. Every agent interaction follows a strict three-part structure defined in the OpenAPI spec:
457
+
458
+
```yaml
459
+
AddMemoryRequest:
460
+
type: object
461
+
required:
462
+
- prompt
463
+
- thought
464
+
- response
465
+
properties:
466
+
prompt:
467
+
type: string
468
+
description: The user's verbatim prompt to the agent
469
+
thought:
470
+
type: string
471
+
description: The agent's internal reasoning process
472
+
response:
473
+
type: string
474
+
description: The agent's final, user-facing response
475
+
sessionId:
476
+
type: string
477
+
description: Session ID for grouping (auto-generated if not provided)
478
+
```
479
+
480
+
This isn't just logging—it's a **mandatory save-then-respond loop**. The agent protocol requires that before delivering any response to the user, the agent must call `add_memory` with its complete reasoning chain. This creates an honest, unfiltered record of the agent's thought process.
The key innovation here is that we embed the **entire interaction**—prompt, thought, and response—as a single vector. This means when the agent searches its memory later, it's searching not just for what it said, but for*why* it said it and what problem it was solving.
513
+
514
+
#### Autonomous Session Summarization
515
+
516
+
The real magic happens at startup. Just like the Knowledge Base server, the Memory Core is **self-maintaining**. When the server starts, it automatically discovers and summarizes any unsummarized sessions from previous work.
The quality metrics generated by the summarization process provide valuable insights:
691
+
692
+
```javascript
693
+
{
694
+
"quality": 85, // Was the session focused and productive?
695
+
"productivity": 90, // Were the goals achieved?
696
+
"impact": 75, // How significant were the changes?
697
+
"complexity": 60, // How difficult was the task?
698
+
"category": "feature", // What type of work was this?
699
+
"technologies": ["neo.mjs", "chromadb", "nodejs"]
700
+
}
701
+
```
702
+
703
+
These aren't just numbers—they enable **performance analysis over time**. Theagent (and we) can ask:
704
+
-"Show me all high-complexity sessions where productivity was low" (areas for improvement)
705
+
-"What features did I build with impact > 80?" (highlight reel)
706
+
-"Which refactoring sessions had quality < 50?" (sessions that went off-track)
707
+
454
708
This capability is critical for several reasons:
455
709
456
710
1.**Learning & Self-Correction:** By querying its own history, the agent can identify patterns in its work, recall past solutions to similar problems, and avoid repeating mistakes. It can ask itself, "How did I solve that bug last week?" and get a concrete answer from its own experience.
457
711
2.**Contextual Continuity:** An agent with memory can maintain context across days or even weeks. It can pick up a complex refactoring task exactly where it left off, without needing to be re-briefed on the entire history.
458
712
3.**Performance Analysis:** The session summaries include metrics on quality, productivity, and complexity. This allows us (and the agent itself) to analyze its performance over time, identifying areas for improvement in its own problem-solving strategies.
459
713
4.**Transactional Integrity:** The protocol for saving memories is transactional and mandatory. The agent *must* save a consolidated record of its entire turn (prompt, thought, response) before delivering its final answer. This"save-then-respond" loop, enforced by the `add_memory` tool, guarantees that no experience is ever lost, creating a rich and honest record of the entire problem-solving process.
460
714
715
+
#### The Neo.mjs Backbone
716
+
717
+
Like all three MCP servers, the Memory Core is built using the **official MCPSDK**for protocol compliance, but its internal architecture is pure **Neo.mjs**. Every service—`MemoryService`, `SessionService`, `SummaryService`, `HealthService`—is a Neo.mjs singleton that extends`Neo.core.Base`.
718
+
719
+
This demonstrates a key design principle:**Neo.mjs isn't just for browsers**. The same class system that powers complex frontend applications also provides:
720
+
- **Singleton pattern** for service management
721
+
- **Async initialization** (`initAsync()`) for startup sequences
722
+
- **Observable pattern** for event-driven architecture
723
+
- **Configuration management** via `static config`
724
+
461
725
The Memory Core is the foundation for an agent that doesn't just execute tasks, but grows, learns, and improves with every interaction. It's the key to building a partner that truly understands the long-term narrative of the project.
0 commit comments