diff --git a/src/ai_client.py b/src/ai_client.py index 0db21274..83603196 100644 --- a/src/ai_client.py +++ b/src/ai_client.py @@ -524,7 +524,12 @@ def _set_tool_preset_result(preset_name: Optional[str]) -> Result[None]: capturing the original exception. The legacy caller (set_tool_preset) calls this helper for the load step; on Result errors, the caller still completes (state remains partially-set; the cache invalidation runs). + + IMPORTANT: This function MODIFIES module-level globals (_active_tool_preset, + _tool_approval_modes, _agent_tools). Without 'global' declarations, the + assignments would create local variables that are discarded on return. """ + global _active_tool_preset, _tool_approval_modes, _agent_tools if not preset_name or preset_name == "None": return Result(data=None) try: