Fix session visibility marks leaking across sessions#3132
Conversation
Visibility._mark_component() mutated shared component objects cached in providers, causing session-level disable/enable marks to persist after reset_visibility() and leak to other sessions. Now returns model_copy() instead of mutating in-place. Fixes #3034
WalkthroughThe 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. 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 |
Visibility._mark_component()was mutating the shared component objects cached in providers. Since all sessions receive the sameTool/Resource/Promptinstances from_list_tools(), a session-leveldisable_components()call would stampvisibility: Falsedirectly onto the shared object's.metadict. Afterreset_visibility()cleared the session rules,apply_session_transforms()would find no rules, return early — and the shared objects still carried the stale marks. This also caused marks to leak to concurrent sessions.The fix is a one-line semantic change:
_mark_componentnow returnscomponent.model_copy(update={"meta": new_meta})instead of mutating in-place. This matches the existing pattern used byNamespacetransform. Eachlist_tools()call now works with fresh copies, so session marks never persist on the provider's cached objects.Fixes #3034