@@ -975,7 +975,9 @@ async def test_runner_merges_sandbox_instructions_and_tools() -> None:
975975 assert model .first_turn_args is not None
976976 assert model .first_turn_args ["system_instructions" ] == (
977977 f"{ get_default_sandbox_instructions ()} \n \n "
978+ "# Agent instructions\n \n "
978979 "Additional instructions.\n \n "
980+ "# Sandbox capability instructions\n \n "
979981 "Capability instructions.\n \n "
980982 f"{ runtime_agent_preparation_module ._filesystem_instructions (manifest )} "
981983 )
@@ -1055,6 +1057,7 @@ async def test_runner_uses_default_sandbox_prompt_when_instructions_missing() ->
10551057 assert model .first_turn_args is not None
10561058 expected_instructions = (
10571059 f"{ get_default_sandbox_instructions ()} \n \n "
1060+ "# Sandbox capability instructions\n \n "
10581061 "Capability instructions.\n \n "
10591062 f"{ runtime_agent_preparation_module ._filesystem_instructions (session .state .manifest )} "
10601063 )
@@ -1093,7 +1096,9 @@ def _raise_file_not_found(_package: object) -> object:
10931096 assert result .final_output == "done"
10941097 assert model .first_turn_args is not None
10951098 assert model .first_turn_args ["system_instructions" ] == (
1099+ "# Agent instructions\n \n "
10961100 "Additional instructions.\n \n "
1101+ "# Sandbox capability instructions\n \n "
10971102 "Capability instructions.\n \n "
10981103 f"{ runtime_agent_preparation_module ._filesystem_instructions (session .state .manifest )} "
10991104 )
@@ -1129,6 +1134,7 @@ def dynamic_instructions(
11291134 assert model .first_turn_args is not None
11301135 assert model .first_turn_args ["system_instructions" ] == (
11311136 f"{ get_default_sandbox_instructions ()} \n \n "
1137+ "# Sandbox capability instructions\n \n "
11321138 "Capability instructions.\n \n "
11331139 f"{ runtime_agent_preparation_module ._filesystem_instructions (session .state .manifest )} "
11341140 )
@@ -1158,7 +1164,9 @@ async def test_runner_base_instructions_override_default_sandbox_prompt() -> Non
11581164 assert model .first_turn_args is not None
11591165 assert model .first_turn_args ["system_instructions" ] == (
11601166 "Custom base instructions.\n \n "
1167+ "# Agent instructions\n \n "
11611168 "Additional instructions.\n \n "
1169+ "# Sandbox capability instructions\n \n "
11621170 "Capability instructions.\n \n "
11631171 f"{ runtime_agent_preparation_module ._filesystem_instructions (session .state .manifest )} "
11641172 )
@@ -1212,6 +1220,11 @@ async def test_runner_adds_remote_mount_policy_instructions() -> None:
12121220 ),
12131221 )
12141222 assert isinstance (re .search (expected_policy_pattern , system_instructions ), re .Match )
1223+ agent_index = system_instructions .index ("# Agent instructions" )
1224+ capability_index = system_instructions .index ("# Sandbox capability instructions" )
1225+ remote_policy_index = system_instructions .index ("# Sandbox remote mount policy" )
1226+ filesystem_index = system_instructions .index ("# Filesystem" )
1227+ assert agent_index < capability_index < remote_policy_index < filesystem_index
12151228
12161229
12171230@pytest .mark .asyncio
@@ -1619,7 +1632,9 @@ def dynamic_instructions(_ctx: RunContextWrapper[Any], current_agent: Agent[Any]
16191632 assert model .first_turn_args is not None
16201633 assert model .first_turn_args ["system_instructions" ] == (
16211634 f"{ get_default_sandbox_instructions ()} \n \n "
1635+ "# Agent instructions\n \n "
16221636 "Saw public agent.\n \n "
1637+ "# Sandbox capability instructions\n \n "
16231638 "Capability instructions.\n \n "
16241639 f"{ runtime_agent_preparation_module ._filesystem_instructions (Manifest ())} "
16251640 )
@@ -1800,7 +1815,9 @@ async def test_runner_rebuilds_sandbox_resources_for_handoff_target_agent() -> N
18001815 assert worker_model .first_turn_args is not None
18011816 assert worker_model .first_turn_args ["system_instructions" ] == (
18021817 f"{ get_default_sandbox_instructions ()} \n \n "
1818+ "# Agent instructions\n \n "
18031819 "Worker instructions.\n \n "
1820+ "# Sandbox capability instructions\n \n "
18041821 "Worker workspace\n \n "
18051822 f"{ runtime_agent_preparation_module ._filesystem_instructions (worker_manifest )} "
18061823 )
@@ -1863,7 +1880,9 @@ def approval_tool() -> str:
18631880 assert worker_model .first_turn_args is not None
18641881 assert worker_model .first_turn_args ["system_instructions" ] == (
18651882 f"{ get_default_sandbox_instructions ()} \n \n "
1883+ "# Agent instructions\n \n "
18661884 "Worker instructions.\n \n "
1885+ "# Sandbox capability instructions\n \n "
18671886 "Worker workspace\n \n "
18681887 f"{ runtime_agent_preparation_module ._filesystem_instructions (worker_manifest )} "
18691888 )
@@ -4533,7 +4552,9 @@ async def test_runner_reapplies_sandbox_prep_on_handoff() -> None:
45334552 assert worker_model .first_turn_args is not None
45344553 assert worker_model .first_turn_args ["system_instructions" ] == (
45354554 f"{ get_default_sandbox_instructions ()} \n \n "
4555+ "# Agent instructions\n \n "
45364556 "Worker instructions.\n \n "
4557+ "# Sandbox capability instructions\n \n "
45374558 "Worker capability.\n \n "
45384559 f"{ runtime_agent_preparation_module ._filesystem_instructions (session .state .manifest )} "
45394560 )
@@ -4738,13 +4759,17 @@ async def test_runner_isolates_shared_capabilities_per_run() -> None:
47384759 assert model_two .first_turn_args is not None
47394760 assert model_one .first_turn_args ["system_instructions" ] == (
47404761 f"{ get_default_sandbox_instructions ()} \n \n "
4762+ "# Agent instructions\n \n "
47414763 "Base instructions.\n \n "
4764+ "# Sandbox capability instructions\n \n "
47424765 "Session one instructions.\n \n "
47434766 f"{ runtime_agent_preparation_module ._filesystem_instructions (session_one .state .manifest )} "
47444767 )
47454768 assert model_two .first_turn_args ["system_instructions" ] == (
47464769 f"{ get_default_sandbox_instructions ()} \n \n "
4770+ "# Agent instructions\n \n "
47474771 "Base instructions.\n \n "
4772+ "# Sandbox capability instructions\n \n "
47484773 "Session two instructions.\n \n "
47494774 f"{ runtime_agent_preparation_module ._filesystem_instructions (session_two .state .manifest )} "
47504775 )
0 commit comments