feat: add read-only runtime memory mode#1141
Conversation
🦋 Changeset detectedLatest commit: 3b31084 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This comment has been minimized.
This comment has been minimized.
📝 WalkthroughWalkthroughIntroduces per-call memory read-only mode via Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Deploying voltagent with
|
| Latest commit: |
3b31084
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://81ef0b84.voltagent.pages.dev |
| Branch Preview URL: | https://feat-memory-readonly-mode.voltagent.pages.dev |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/core/src/agent/agent.ts (1)
1327-1361:⚠️ Potential issue | 🟠 MajorDon't return a writable feedback handle from read-only calls.
Both text paths now suppress conversation persistence, but the returned
feedbackhandle still closes overthis.markFeedbackProvided(...), which writes metadata back to memory. That re-opens a write path after a read-only call, and it can also point at message IDs that were never persisted. Please either suppress the handle for read-only requests or make itsmarkFeedbackProvidedcallback a no-op.Also applies to: 1549-1568
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/core/src/agent/agent.ts` around lines 1327 - 1361, The feedback handle currently closes over this.markFeedbackProvided and can re-open writes for read-only requests; modify the creation of feedbackValue (the call to createFeedbackHandleHelper) so that when persistence is suppressed (e.g., shouldPersistMemory is false or the request is a read-only path where persist was deferred), you either return null for feedbackValue or pass a no-op markFeedbackProvided and a resolveMessageId that returns null; specifically update the block that builds feedbackValue (which references feedbackMetadata, createFeedbackHandleHelper, resolveMessageId => findFeedbackMessageIdHelper, and markFeedbackProvided) to short-circuit for read-only cases or replace markFeedbackProvided with a no-op closure and resolveMessageId with a safe null-returning function.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@packages/core/src/agent/agent.ts`:
- Around line 1327-1361: The feedback handle currently closes over
this.markFeedbackProvided and can re-open writes for read-only requests; modify
the creation of feedbackValue (the call to createFeedbackHandleHelper) so that
when persistence is suppressed (e.g., shouldPersistMemory is false or the
request is a read-only path where persist was deferred), you either return null
for feedbackValue or pass a no-op markFeedbackProvided and a resolveMessageId
that returns null; specifically update the block that builds feedbackValue
(which references feedbackMetadata, createFeedbackHandleHelper, resolveMessageId
=> findFeedbackMessageIdHelper, and markFeedbackProvided) to short-circuit for
read-only cases or replace markFeedbackProvided with a no-op closure and
resolveMessageId with a safe null-returning function.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: cbc79d97-470f-4678-94f9-e958a699b305
📒 Files selected for processing (14)
.changeset/read-only-memory-mode.mdpackages/core/src/agent/agent.spec-d.tspackages/core/src/agent/agent.spec.tspackages/core/src/agent/agent.tspackages/core/src/agent/types.tspackages/core/src/memory/manager/memory-manager.tspackages/server-core/src/schemas/agent.schemas.spec.tspackages/server-core/src/schemas/agent.schemas.tspackages/server-core/src/utils/options.tswebsite/docs/agents/memory/overview.mdwebsite/docs/agents/memory/working-memory.mdwebsite/docs/api/api-reference.mdwebsite/docs/api/endpoints/agents.mdwebsite/docs/ui/ai-sdk-integration.md
PR Checklist
Please check if your PR fulfills the following requirements:
Bugs / Features
What is the current behavior?
Runtime memory always persists new messages/steps when memory is enabled, and working memory tools always include write operations.
What is the new behavior?
When
memory.options.readOnly: trueis provided for a call:update_working_memory,clear_working_memory), whileget_working_memoryremains available.memory.options.readOnly.fixes (issue)
N/A
Notes for reviewers
@voltagent/coreand@voltagent/server-core.pnpm --filter @voltagent/core exec vitest run src/agent/agent.spec.tspnpm --filter @voltagent/server-core exec vitest run src/schemas/agent.schemas.spec.tspnpm --filter @voltagent/core typecheckpnpm --filter @voltagent/server-core typecheckSummary by cubic
Add a per-call read-only memory mode so agents can read context without persisting any new state. Enable via memory.options.readOnly and disable working memory write tools for that request.
Written for commit 3b31084. Summary will update on new commits.
Summary by CodeRabbit
Release Notes
New Features
memory.options.readOnlyflag for per-call controlDocumentation