@@ -24,6 +24,7 @@ from pathlib import Path
2424from typing import Any
2525
2626import render
27+ import tomllib
2728
2829TERMINAL_STATUS = ("PASS" , "FAIL" , "BLOCKED" , "NOT_RUN" , "SKIPPED" )
2930
@@ -223,6 +224,20 @@ def agent_command(
223224 raise DstackTestError (f"unsupported agent: { agent } " )
224225
225226
227+ def resolve_model (agent : str , model : str | None ) -> str | None :
228+ if model or agent != "codex" :
229+ return model
230+ config_home = Path (os .environ .get ("CODEX_HOME" , Path .home () / ".codex" ))
231+ config_path = config_home / "config.toml"
232+ if not config_path .is_file ():
233+ return None
234+ try :
235+ configured = tomllib .loads (config_path .read_text (encoding = "utf-8" )).get ("model" )
236+ except (OSError , tomllib .TOMLDecodeError ):
237+ return None
238+ return configured if isinstance (configured , str ) and configured else None
239+
240+
226241def run_case (
227242 plan : render .Plan ,
228243 case : render .CaseEntry ,
@@ -248,7 +263,8 @@ def run_case(
248263 stderr_path = result_dir / "agent-stderr.log"
249264 started_at = utc_now ()
250265 start = time .monotonic_ns ()
251- command = agent_command (agent , model , workdir , full_prompt , extra )
266+ effective_model = resolve_model (agent , model )
267+ command = agent_command (agent , effective_model , workdir , full_prompt , extra )
252268 binary = shutil .which (command [0 ])
253269 if not binary :
254270 raise DstackTestError (f"agent CLI not found: { command [0 ]} " )
@@ -272,7 +288,10 @@ def run_case(
272288 "schema_version" : "1.0" ,
273289 "run_id" : run_id ,
274290 "case_id" : case .id ,
275- "agent" : {"type" : agent , "model" : detected_model or model or "unknown" },
291+ "agent" : {
292+ "type" : agent ,
293+ "model" : detected_model or effective_model or "unknown" ,
294+ },
276295 "session" : {
277296 "format" : f"{ agent } -jsonl" ,
278297 "path" : "session.jsonl" ,
0 commit comments