Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions .changeset/runtime-memory-envelope.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
"@voltagent/core": patch
"@voltagent/server-core": patch
"@voltagent/resumable-streams": patch
Comment on lines +2 to +4
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Use a minor bump for the new options.memory API.

This changeset adds a new supported public configuration shape across all three packages. That is backward-compatible feature work, so shipping it as patch understates the semver impact.

Suggested change
-"@voltagent/core": patch
-"@voltagent/server-core": patch
-"@voltagent/resumable-streams": patch
+"@voltagent/core": minor
+"@voltagent/server-core": minor
+"@voltagent/resumable-streams": minor
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"@voltagent/core": patch
"@voltagent/server-core": patch
"@voltagent/resumable-streams": patch
"@voltagent/core": minor
"@voltagent/server-core": minor
"@voltagent/resumable-streams": minor
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.changeset/runtime-memory-envelope.md around lines 2 - 4, The changeset
currently marks three packages ("@voltagent/core", "@voltagent/server-core",
"@voltagent/resumable-streams") as "patch" but it introduces a new public
configuration option (options.memory), so update the changeset to use "minor"
instead of "patch" for those three package entries; open the
.changeset/runtime-memory-envelope.md content and replace each "patch" value
with "minor" so the semver bump correctly reflects a backward-compatible feature
addition.

---

feat: add runtime memory envelope (`options.memory`) and deprecate legacy top-level memory fields

### What's New

- Added a preferred per-call memory envelope:
- `options.memory.conversationId` for conversation-scoped memory
- `options.memory.userId` for user-scoped memory
- `options.memory.options` for memory behavior overrides (`contextLimit`, `semanticMemory`, `conversationPersistence`)
- Kept legacy top-level fields for backward compatibility:
- `options.conversationId`, `options.userId`, `options.contextLimit`, `options.semanticMemory`, `options.conversationPersistence`
- Legacy fields are now marked deprecated in type/docs, and envelope values are preferred when both are provided.

### Usage Examples

Legacy (still supported, deprecated):

```ts
await agent.generateText("Hello", {
userId: "user-123",
conversationId: "conv-123",
contextLimit: 20,
semanticMemory: {
enabled: true,
semanticLimit: 5,
},
conversationPersistence: {
mode: "step",
debounceMs: 150,
},
});
```

Preferred (new `memory` envelope):

```ts
await agent.generateText("Hello", {
memory: {
userId: "user-123",
conversationId: "conv-123",
options: {
contextLimit: 20,
semanticMemory: {
enabled: true,
semanticLimit: 5,
},
conversationPersistence: {
mode: "step",
debounceMs: 150,
},
},
},
});
```

### Server and Resumable Stream Alignment

- `@voltagent/server-core` now accepts/documents the `options.memory` envelope in request schemas.
- Resumable stream identity resolution now reads `conversationId`/`userId` from `options.memory` first and falls back to legacy fields.
- Added tests for:
- parsing `options.memory` in server schemas
- resolving resumable stream keys from `options.memory`
31 changes: 28 additions & 3 deletions packages/core/src/agent/agent.spec-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,14 +412,38 @@ describe("Agent Type System", () => {
describe("Options Type Tests", () => {
it("should distinguish PublicGenerateOptions from InternalGenerateOptions", () => {
const publicOptions: PublicGenerateOptions = {
conversationId: "123",
userId: "user-123",
contextLimit: 1000,
memory: {
conversationId: "123",
userId: "user-123",
options: {
contextLimit: 1000,
semanticMemory: {
enabled: true,
semanticLimit: 3,
},
conversationPersistence: {
mode: "step",
},
},
},
maxSteps: 5,
signal: new AbortSignal(),
context: new Map(),
};

const legacyOptions: PublicGenerateOptions = {
conversationId: "legacy-conversation",
userId: "legacy-user",
contextLimit: 250,
semanticMemory: {
enabled: true,
semanticThreshold: 0.75,
},
conversationPersistence: {
mode: "finish",
},
};

const internalOptions: InternalGenerateOptions = {
...publicOptions,
parentAgentId: "parent-123",
Expand All @@ -432,6 +456,7 @@ describe("Agent Type System", () => {
publicOptions.operationContext;

expectTypeOf(publicOptions).toMatchTypeOf<PublicGenerateOptions>();
expectTypeOf(legacyOptions).toMatchTypeOf<PublicGenerateOptions>();
expectTypeOf(internalOptions).toMatchTypeOf<InternalGenerateOptions>();
});

Expand Down
Loading