@@ -158,3 +158,72 @@ def test_dynaconf_and_flat_backend_values_match() -> None:
158158 food_truck_spec .env ["AUTOSKILLIT_AGENT_BACKEND__BACKEND" ]
159159 == food_truck_spec .env ["AUTOSKILLIT_AGENT_BACKEND" ]
160160 ), f"{ name } : nested and flat AGENT_BACKEND values differ in build_food_truck_cmd"
161+
162+
163+ _ALL_GUARD_BUILDERS : list [str ] = [
164+ "build_skill_session_cmd" ,
165+ "build_food_truck_cmd" ,
166+ "build_interactive_cmd" ,
167+ "build_resume_cmd" ,
168+ ]
169+
170+
171+ def _call_builder (backend : object , builder_name : str ) -> object :
172+ from autoskillit .core .types ._type_plugin_source import DirectInstall
173+
174+ if builder_name == "build_skill_session_cmd" :
175+ return backend .build_skill_session_cmd (
176+ "/autoskillit:investigate" , "/repo" , completion_marker = "DONE"
177+ )
178+ if builder_name == "build_food_truck_cmd" :
179+ return backend .build_food_truck_cmd (
180+ orchestrator_prompt = "test prompt" ,
181+ plugin_source = DirectInstall (plugin_dir = Path ("/plugins" )),
182+ cwd = "/repo" ,
183+ completion_marker = "DONE" ,
184+ )
185+ if builder_name == "build_interactive_cmd" :
186+ return backend .build_interactive_cmd ()
187+ if builder_name == "build_resume_cmd" :
188+ return backend .build_resume_cmd (resume_session_id = "test-session" , prompt = "continue" )
189+ msg = f"Unknown builder: { builder_name } "
190+ raise ValueError (msg )
191+
192+
193+ @pytest .mark .parametrize ("builder_name" , _ALL_GUARD_BUILDERS )
194+ def test_agent_backend_flat_env_var_in_all_guard_launch_builders (builder_name : str ) -> None :
195+ """AUTOSKILLIT_AGENT_BACKEND must appear in every builder's CmdSpec.env for every backend."""
196+ from autoskillit .core .types ._type_backend import CmdSpec
197+ from autoskillit .execution .backends import BACKEND_REGISTRY
198+
199+ assert BACKEND_REGISTRY , "BACKEND_REGISTRY is empty — test provides no coverage"
200+ for name , cls in BACKEND_REGISTRY .items ():
201+ backend = cls ()
202+ if builder_name == "build_resume_cmd" and not backend .capabilities .session_resume_capable :
203+ continue
204+ spec = _call_builder (backend , builder_name )
205+ assert isinstance (spec , CmdSpec ), f"{ name } : { builder_name } did not return CmdSpec"
206+ assert "AUTOSKILLIT_AGENT_BACKEND" in spec .env , (
207+ f"{ name } : AUTOSKILLIT_AGENT_BACKEND missing from { builder_name } env"
208+ )
209+
210+
211+ def test_agent_backend_flat_and_dynaconf_values_match_in_interactive_and_resume () -> None :
212+ """Nested and flat AGENT_BACKEND env vars must carry the same value in interactive and resume builders.""" # noqa: E501
213+ from autoskillit .execution .backends import BACKEND_REGISTRY
214+
215+ assert BACKEND_REGISTRY , "BACKEND_REGISTRY is empty — test provides no coverage"
216+ for name , cls in BACKEND_REGISTRY .items ():
217+ backend = cls ()
218+ interactive_spec = backend .build_interactive_cmd ()
219+ assert (
220+ interactive_spec .env ["AUTOSKILLIT_AGENT_BACKEND__BACKEND" ]
221+ == interactive_spec .env ["AUTOSKILLIT_AGENT_BACKEND" ]
222+ ), f"{ name } : nested and flat AGENT_BACKEND values differ in build_interactive_cmd"
223+ if not backend .capabilities .session_resume_capable :
224+ continue
225+ resume_spec = backend .build_resume_cmd (resume_session_id = "test-session" , prompt = "continue" )
226+ assert (
227+ resume_spec .env ["AUTOSKILLIT_AGENT_BACKEND__BACKEND" ]
228+ == resume_spec .env ["AUTOSKILLIT_AGENT_BACKEND" ]
229+ ), f"{ name } : nested and flat AGENT_BACKEND values differ in build_resume_cmd"
0 commit comments