1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414
15+ import threading
1516from pathlib import Path
1617from types import SimpleNamespace
1718from unittest .mock import Mock
@@ -294,8 +295,12 @@ def register_callback_for_user_pool_client(self, **kwargs: object) -> None:
294295def test_studio_deploy_creates_distinct_sandbox_tools_when_ids_are_omitted (
295296 monkeypatch : pytest .MonkeyPatch ,
296297) -> None :
298+ monkeypatch .delenv ("SANDBOX_CHAT_CODEX" , raising = False )
299+ monkeypatch .delenv ("SANDBOX_SKILL_CREATOR" , raising = False )
297300 created_names : list [str ] = []
298301 credential_tool_ids : list [str ] = []
302+ creation_barrier = threading .Barrier (2 )
303+ created_names_lock = threading .Lock ()
299304
300305 class _FakeCloudAgentEngine :
301306 def __init__ (self , ** _ : object ) -> None :
@@ -310,8 +315,10 @@ def deploy(self, **_: object) -> SimpleNamespace:
310315
311316 def _ensure_tool (** kwargs : object ) -> str :
312317 name = str (kwargs ["name" ])
313- created_names .append (name )
314- return f"tool-{ len (created_names )} "
318+ creation_barrier .wait (timeout = 5 )
319+ with created_names_lock :
320+ created_names .append (name )
321+ return "chat-tool" if "-chat-" in name else "skill-tool"
315322
316323 monkeypatch .setattr (
317324 "veadk.cloud.cloud_agent_engine.CloudAgentEngine" , _FakeCloudAgentEngine
@@ -351,12 +358,11 @@ def _ensure_tool(**kwargs: object) -> str:
351358
352359 assert result .exit_code == 0 , result .output
353360 assert len (created_names ) == 2
354- assert created_names [0 ] != created_names [1 ]
355- assert "chat" in created_names [0 ]
356- assert "skill" in created_names [1 ]
357- assert veadk_environments ["SANDBOX_CHAT_CODEX" ] == "tool-1"
358- assert veadk_environments ["SANDBOX_SKILL_CREATOR" ] == "tool-2"
359- assert credential_tool_ids == ["tool-1" , "tool-2" ]
361+ assert any ("chat" in name for name in created_names )
362+ assert any ("skill" in name for name in created_names )
363+ assert veadk_environments ["SANDBOX_CHAT_CODEX" ] == "chat-tool"
364+ assert veadk_environments ["SANDBOX_SKILL_CREATOR" ] == "skill-tool"
365+ assert credential_tool_ids == ["chat-tool" , "skill-tool" ]
360366
361367
362368@pytest .mark .parametrize (
0 commit comments