-
Notifications
You must be signed in to change notification settings - Fork 860
feat: add memory primitive #2366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,6 +73,8 @@ import { ToolCaller } from './tool-caller.js' | |
| import type { ToolCallerProxy } from './tool-caller.js' | ||
|
|
||
| import type { z } from 'zod' | ||
| import { MemoryManager } from '../memory/memory-manager.js' | ||
| import type { MemoryManagerConfig } from '../memory/index.js' | ||
| import { SessionManager } from '../session/session-manager.js' | ||
| import { Tracer } from '../telemetry/tracer.js' | ||
| import { Meter } from '../telemetry/meter.js' | ||
|
|
@@ -198,6 +200,12 @@ export type AgentConfig = { | |
| * Session manager for saving and restoring agent sessions | ||
| */ | ||
| sessionManager?: SessionManager | ||
| /** | ||
| * Memory manager for cross-session knowledge retrieval and storage. | ||
| * Manages one or more knowledge stores and exposes search/store tools. | ||
| * Accepts a {@link MemoryManager} instance or a {@link MemoryManagerConfig} object (auto-wrapped). | ||
| */ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue: Suggestion: Document why this inconsistency exists (presumably because |
||
| memoryManager?: MemoryManager | MemoryManagerConfig | ||
| /** | ||
| * Custom trace attributes to include in all spans. | ||
| * These attributes are merged with standard attributes in telemetry spans. | ||
|
|
@@ -287,6 +295,10 @@ export class Agent implements LocalAgent, InvokableAgent { | |
| * The session manager for saving and restoring agent sessions, if configured. | ||
| */ | ||
| public readonly sessionManager?: SessionManager | undefined | ||
| /** | ||
| * The memory manager for cross-session knowledge retrieval and storage, if configured. | ||
| */ | ||
| public readonly memoryManager?: MemoryManager | undefined | ||
|
|
||
| private readonly _hooksRegistry: HookRegistryImplementation | ||
| private readonly _pluginRegistry: PluginRegistry | ||
|
|
@@ -323,6 +335,12 @@ export class Agent implements LocalAgent, InvokableAgent { | |
| this.id = config?.id ?? DEFAULT_AGENT_ID | ||
| if (config?.description !== undefined) this.description = config.description | ||
| this.sessionManager = config?.sessionManager | ||
| this.memoryManager = | ||
| config?.memoryManager instanceof MemoryManager | ||
| ? config.memoryManager | ||
| : config?.memoryManager | ||
| ? new MemoryManager(config.memoryManager) | ||
| : undefined | ||
|
|
||
| if (typeof config?.model === 'string') { | ||
| this.model = new BedrockModel({ modelId: config.model }) | ||
|
|
@@ -375,6 +393,7 @@ export class Agent implements LocalAgent, InvokableAgent { | |
| this._conversationManager, | ||
| ...retryStrategies, | ||
| ...(config?.plugins ?? []), | ||
| ...(this.memoryManager ? [this.memoryManager] : []), | ||
| ...(config?.sessionManager ? [config.sessionManager] : []), | ||
| new ModelPlugin(this.model), | ||
| ]) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.