🪲 BUG-#21: Fix workspace jail global mutable state - #33
Merged
Conversation
FernandoCelmer
commented
Aug 15, 2026
FernandoCelmer
left a comment
Member
Author
There was a problem hiding this comment.
The global mutable state elimination is sound. Removing _enabled/set_workspace_enabled and replacing them with per-instance workspace flags threads correctly through Config, build_tools, and every tool class. Backward-compat module-level DEFAULT_TOOLS/READ_ONLY_TOOLS via __getattr__ is a clean bridge. One issue found below.
Config.__init__ called build_tools(workspace) unconditionally to get read_only_tools for DelegateTool, even when a caller passed a custom tools list and delegation was off — instantiating every built-in tool just to discard the result. Now build_tools() for the read-only subset only runs when delegation=True actually needs it.
Merged
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.
Description
Eliminates global mutable workspace jail state (issue #21). Replaces the module-level
_enabledflag andset_workspace_enabled()with per-instanceworkspace: boolconstructor arguments on every filesystem/search tool. Introducesbuild_tools(workspace)factory intools/__init__.pyso eachConfiginstance gets its own correctly-scoped tool set. Module-levelDEFAULT_TOOLS/READ_ONLY_TOOLSare kept for backward compatibility via lazy__getattr__.Motivation and Context
Closes #21. Two
Configinstances with differentworkspace=settings (or tests running in sequence) would race — whichever initialized last silently won for every tool in the process.Types of changes
Checklist