@mastra/rag 2.6.2 → 2.6.3
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.
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-guides-context-engineering.md +2 -2
- package/dist/document/document.d.ts +18 -0
- package/dist/document/document.d.ts.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/docs/SKILL.md
CHANGED
|
@@ -178,7 +178,7 @@ await assistant.generate('Help me plan the next project milestone.', {
|
|
|
178
178
|
|
|
179
179
|
The example assumes storage is configured on the registered Mastra instance or directly on `Memory`. `lastMessages` controls how many recent messages Mastra loads from the thread. The default is 10.
|
|
180
180
|
|
|
181
|
-
Message history works well for shorter conversations where recent turns contain the context the agent needs. For long-running conversations, Mastra recommends [Observational Memory](https://mastra.ai/docs/memory/observational-memory), which keeps recent conversation available and turns older history into a dense observation log.
|
|
181
|
+
Message history works well for shorter conversations where recent turns contain the context the agent needs. Because the `lastMessages` window slides forward on every request, each turn past the limit removes the oldest message from the start of the prompt and invalidates the provider prompt cache. For long-running conversations, Mastra recommends [Observational Memory](https://mastra.ai/docs/memory/observational-memory), which keeps recent conversation available and turns older history into a dense observation log while keeping the prompt prefix stable for caching.
|
|
182
182
|
|
|
183
183
|
## Observational Memory
|
|
184
184
|
|
|
@@ -204,7 +204,7 @@ export const assistant = new Agent({
|
|
|
204
204
|
})
|
|
205
205
|
```
|
|
206
206
|
|
|
207
|
-
After messages are observed, the model receives the observation log, recent messages that haven't been observed, and a continuation reminder. The raw messages remain stored but no longer occupy the active model context.
|
|
207
|
+
After messages are observed, the model receives the observation log, recent messages that haven't been observed, and a continuation reminder. Because delayed hints may be stale by the time a buffered chunk activates, async buffered observations don't generate continuation hints (`currentTask` or `suggestedResponse`). The raw messages remain stored but no longer occupy the active model context.
|
|
208
208
|
|
|
209
209
|
Observations are added in stable chunks, which helps providers reuse the existing prompt prefix. Observational Memory can also activate buffered observations after a prompt cache is likely to expire or before the agent changes providers.
|
|
210
210
|
|
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
import type { ObservabilityContext } from '@mastra/core/observability';
|
|
2
2
|
import { Document as Chunk } from './schema/index.js';
|
|
3
3
|
import type { ChunkParams, ExtractParams, HTMLChunkOptions, RecursiveChunkOptions, CharacterChunkOptions, TokenChunkOptions, MarkdownChunkOptions, SemanticMarkdownChunkOptions, JsonChunkOptions, LatexChunkOptions, SentenceChunkOptions } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Prepares documents for retrieval with chunking and optional metadata extraction.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { MDocument } from '@mastra/rag';
|
|
10
|
+
*
|
|
11
|
+
* const document = MDocument.fromText('Text to prepare for retrieval.');
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* @see For documentation bundled with your installed package, locate
|
|
15
|
+
* `@mastra/rag/package.json` with your project's resolver or package-manager
|
|
16
|
+
* tooling, then read `dist/docs/SKILL.md` from that package root and follow its
|
|
17
|
+
* reference links. Use package-manager tools for virtual or archived packages.
|
|
18
|
+
*
|
|
19
|
+
* @see [RAG documentation](https://mastra.ai/reference/rag/overview)
|
|
20
|
+
* if packaged docs are unavailable.
|
|
21
|
+
*/
|
|
4
22
|
export declare class MDocument {
|
|
5
23
|
private chunks;
|
|
6
24
|
private type;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../src/document/document.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AASvE,OAAO,EAAE,QAAQ,IAAI,KAAK,EAAgC,MAAM,UAAU,CAAC;AAU3E,OAAO,KAAK,EACV,WAAW,EAEX,aAAa,EACb,gBAAgB,EAChB,qBAAqB,EACrB,qBAAq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