Repository navigation
fix(memory): Keep memory write tools in every Turn and disable them by visibility - #2953
Merged
Merged
Conversation
…y visibility Since #2684 the memory plugin returned createMemory and archiveMemory only for Sources with public visibility. The tool list then changed between Turns of one Conversation, which rewrote the cached prompt. Plugin tools can now set disabledReason. The memory plugin returns the same four tools in every Turn and disables the write tools for Sources without public visibility. Co-Authored-By: Thomas Jiang <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
12 screenshot changes — 12 changed · 0 added · 0 removed Review screenshots in Frameshift Show 6 more changed screenshots |
Co-Authored-By: Thomas Jiang <[email protected]>
thomasjiangcy
approved these changes
Nov 9, 2026
23 tasks done
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since #2684, the memory plugin returns
createMemoryandarchiveMemoryonly for Sources with public visibility. Event, child-agent, automation, timer, and other Turns have no visibility, so they get only the read tools. Plugin tools are deferred, but thecodemodetool description lists the script tools, so the native tool list changes between Turns of one Conversation. The provider caches tools before system and messages, so each flip rewrites the whole cached history. Estimate from a 53-conversation prod sample: about 20% of cache-write tokens since 0.278.The fix uses core's existing
disabledReason.PluginToolDefinitionnow has the same optional field, andgetPluginToolsalready passes plugin definitions through unchanged. The memory plugin returns the same four tools in every Turn. For a Source without public visibility, it setsdisabledReasonon the two write tools. Core then lists them as disabled in the Turn context and rejects their calls before hooks, action review, and execution, for direct,executeTool, andcodemodecalls. Neither thecodemodedescription nor thesearchToolscatalog readsdisabledReason, so they render the same for enabled and disabled tools. Write behavior for public Sources does not change.I did not use a check inside
execute. It would skip the Turn-context listing and run hooks and review first.Tests:
codemodedescription, is byte-identical. It also checks that an event-TurncreateMemorycall throughexecuteToolfails with the disabled message and writes nothing.codemodescript call too.via @thomasjiangcy.
--
View Session [Sentry]