Skip to content

Commit 7118fd4

Browse files
committed
Update doc
1 parent a71e976 commit 7118fd4

8 files changed

Lines changed: 19 additions & 20 deletions

File tree

agents/agents-features/agents-features-longterm-memory/Module.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ The agents-features-longterm-memory module adds long-term memory capabilities to
1919
| [`LongTermMemory`](src/commonMain/kotlin/ai/koog/agents/longtermmemory/feature/LongTermMemory.kt) | Agent feature with DSL config for retrieval & ingestion |
2020
| [`SearchStorage`](../../../../../../rag/rag-base/src/commonMain/kotlin/ai/koog/rag/base/storage/SearchStorage.kt) | Interface for searching memory records (defined in `rag-base`) |
2121
| [`WriteStorage`](../../../../../../rag/rag-base/src/commonMain/kotlin/ai/koog/rag/base/storage/WriteStorage.kt) | Interface for adding memory records (defined in `rag-base`) |
22-
| [`SearchStrategy`](src/commonMain/kotlin/ai/koog/agents/longtermmemory/retrieval/SearchStrategy.kt) | Converts user query into a `SearchRequest`; `SimilaritySearchStrategy` is the default implementation |
23-
| [`SearchQueryProvider`](src/commonMain/kotlin/ai/koog/agents/longtermmemory/retrieval/SearchQueryProvider.kt) | Provides the search query string from a `Prompt` for retrieval |
24-
| [`LastUserMessageQueryProvider`](src/commonMain/kotlin/ai/koog/agents/longtermmemory/retrieval/LastUserMessageQueryProvider.kt) | Default `SearchQueryProvider` that uses the last user message content |
22+
| [`SearchStrategy`](src/commonMain/kotlin/ai/koog/agents/longtermmemory/retrieval/search/SearchStrategy.kt) | Converts user query into a `SearchRequest`; `SimilaritySearchStrategy` is the default implementation |
23+
| [`SearchQueryProvider`](src/commonMain/kotlin/ai/koog/agents/longtermmemory/retrieval/search/SearchQueryProvider.kt) | Provides the search query string from a `Prompt` for retrieval |
24+
| [`LastUserMessageQueryProvider`](src/commonMain/kotlin/ai/koog/agents/longtermmemory/retrieval/search/LastUserMessageQueryProvider.kt) | Default `SearchQueryProvider` that uses the last user message content |
2525
| [`DocumentExtractor`](src/commonMain/kotlin/ai/koog/agents/longtermmemory/ingestion/extraction/DocumentExtractor.kt) | Transforms messages into `TextDocument`s for storage |
2626
| [`MessagePassingDocumentExtractor`](src/commonMain/kotlin/ai/koog/agents/longtermmemory/ingestion/extraction/MessagePassingDocumentExtractor.kt) | Default `DocumentExtractor`; filters messages by role (`User`/`Assistant` by default) |
2727
| [`PromptAugmenter`](src/commonMain/kotlin/ai/koog/agents/longtermmemory/retrieval/augmentation/PromptAugmenter.kt) | Interface for augmenting prompts with relevant context |

agents/agents-features/agents-features-longterm-memory/src/commonMain/kotlin/ai/koog/agents/longtermmemory/ingestion/extraction/DocumentExtractor.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import kotlin.jvm.JvmStatic
1010
* This is a functional interface (SAM) that defines how a list of messages
1111
* should be transformed into a list of [TextDocument]s for storage.
1212
* It provides flexibility in how messages are filtered, transformed, and
13-
* converted into memory records while maintaining type safety.
13+
* converted into [TextDocument]s while maintaining type safety.
1414
*
1515
* Pre-built implementations are available for common ingestion patterns:
1616
* - [MessagePassingDocumentExtractor] - Filters messages by role
@@ -33,7 +33,7 @@ import kotlin.jvm.JvmStatic
3333
* val customExtractor = DocumentExtractor { messages ->
3434
* messages
3535
* .filter { it.role == Message.Role.Assistant }
36-
* .map { MemoryRecord(content = summarize(it.content)) }
36+
* .map { MemoryRecord(content = it.content) }
3737
* }
3838
* ```
3939
*
@@ -42,16 +42,16 @@ import kotlin.jvm.JvmStatic
4242
* DocumentExtractor customExtractor = (messages) ->
4343
* messages.stream()
4444
* .filter(m -> m.getRole() == Message.Role.Assistant)
45-
* .map(m -> new MemoryRecord(m.getContent()))
45+
* .map(m -> new MemoryRecord(m.getContent(), null, Collections.emptyMap()))
4646
* .collect(Collectors.toList());
4747
* ```
4848
*/
4949
public fun interface DocumentExtractor {
5050
/**
51-
* Transforms a list of messages into a list of memory records for storage.
51+
* Transforms a list of messages into a list of [TextDocument]s for storage.
5252
*
53-
* @param messages The messages to transform into memory records
54-
* @return List of memory records to be stored
53+
* @param messages The messages to transform into [TextDocument]s
54+
* @return List of [TextDocument]s to be stored
5555
*/
5656
public suspend fun extract(messages: List<Message>): List<TextDocument>
5757

agents/agents-features/agents-features-longterm-memory/src/commonMain/kotlin/ai/koog/agents/longtermmemory/ingestion/extraction/MessagePassingDocumentExtractor.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import ai.koog.rag.base.TextDocument
88
* Default extractor that filters messages by role.
99
*
1010
* This extractor filters messages to only include those with roles in
11-
* [messageRolesToExtract], then converts each message's content into [MemoryRecord]s.
11+
* [messageRolesToExtract], then converts each message's content into [TextDocument]s.
1212
*
1313
* @property messageRolesToExtract The set of message roles to extract and persist.
1414
* Defaults to `setOf(Message.Role.User, Message.Role.Assistant)`.
@@ -37,7 +37,7 @@ public class MessagePassingDocumentExtractor(
3737
*/
3838
public class Builder {
3939
/**
40-
* The set of message roles to provide. Defaults to User and Assistant.
40+
* The set of message roles to extract. Defaults to User and Assistant.
4141
*/
4242
public var extractRoles: Set<Message.Role> = setOf(Message.Role.User, Message.Role.Assistant)
4343

agents/agents-features/agents-features-longterm-memory/src/commonMain/kotlin/ai/koog/agents/longtermmemory/retrieval/RetrievalSettings.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import ai.koog.rag.base.storage.search.SearchRequest
1515
* Settings controlling how memory records are retrieved and injected into prompts (RAG).
1616
*
1717
* @param storage The retrieval storage to search for relevant memory records.
18-
* @param searchQueryProvider The extractor that defines how to derive the search query from the prompt.
18+
* @param searchQueryProvider The provider that defines how to derive the search query from the prompt.
1919
* Defaults to [ai.koog.agents.longtermmemory.retrieval.search.LastUserMessageQueryProvider], which uses the last user message content.
2020
* @param searchStrategy The strategy that defines how to search the retrieval store.
2121
* @param promptAugmenter The augmenter that defines how retrieved context is inserted into the prompt.

agents/agents-features/agents-features-longterm-memory/src/commonMain/kotlin/ai/koog/agents/longtermmemory/retrieval/augmentation/SystemPromptAugmenter.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ import ai.koog.rag.base.storage.search.SearchResult
99
/**
1010
* A [PromptAugmenter] that inserts retrieved context as a system message at the beginning of the prompt.
1111
*
12-
* If an existing system message is present, the new context system message is inserted
13-
* before it, keeping each system message focused on a single concern.
12+
* The new context system message is prepended before all existing messages.
1413
* If there is no system message in the prompt, the prompt is returned unchanged.
1514
*
1615
* @param template The template for the system message. Use [PromptAugmenter.RELEVANT_CONTEXT_PLACEHOLDER] placeholder.

agents/agents-features/agents-features-longterm-memory/src/commonMain/kotlin/ai/koog/agents/longtermmemory/retrieval/search/SearchStrategy.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import kotlin.jvm.JvmStatic
88
* Search strategy for creating search requests during prompt augmentation.
99
*
1010
* This is a functional interface (SAM) that defines how a user query string
11-
* should be transformed into a [SimilaritySearchRequest] for storage.
11+
* should be transformed into a [SearchRequest] for retrieval.
1212
*
1313
* **[SimilaritySearchStrategy] is the default implementation.**
1414
* It uses vector embeddings for semantic search and works with all supported vector backends.
@@ -33,10 +33,10 @@ import kotlin.jvm.JvmStatic
3333
*/
3434
public fun interface SearchStrategy {
3535
/**
36-
* Maps a query string into a [SearchRequest] for the storage.
36+
* Maps a query string into a [SearchRequest] for retrieval.
3737
*
3838
* @param query The user's query string (typically the last user message content)
39-
* @return The similarity search request to be executed
39+
* @return The search request to be executed
4040
*/
4141
public fun create(query: String): SearchRequest
4242

agents/agents-features/agents-features-longterm-memory/src/commonMain/kotlin/ai/koog/agents/longtermmemory/storage/InMemoryRecordStorage.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import kotlin.uuid.ExperimentalUuidApi
1818
import kotlin.uuid.Uuid
1919

2020
/**
21-
* In-memory implementation of [SearchStorage]
22-
* and [WriteStorage] that stores records in a map.
21+
* In-memory implementation of [SearchStorage], [WriteStorage], [LookupStorage],
22+
* and [DeletionStorage] that stores records in a map.
2323
*
2424
* This implementation is useful for testing, development, and scenarios where persistence
2525
* is not required. All data is stored in memory and will be lost when the application stops.

docs/docs/features/long-term-memory.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ Ingestion runs once when the agent run completes: the final accumulated session
175175

176176
## Disabling Automatic Behavior
177177

178-
By default, retrieval and ingestion run automatically (before and after LLM calls, respectively). You can disable automatic behavior while still having access to the configured storage and strategies from within strategy nodes:
178+
By default, retrieval and ingestion run automatically (retrieval runs before each LLM call; ingestion runs once when the agent completes). You can disable automatic behavior while still having access to the configured storage and strategies from within strategy nodes:
179179

180180
=== "Kotlin"
181181

0 commit comments

Comments
 (0)