@@ -161,7 +161,8 @@ public CodexCliResult exec(CodexCli.ExecOptions opts) {
161161 * empty or unparseable.
162162 */
163163 public List <CodexEvent > execAndParse (String prompt ) {
164- CodexCliResult result = exec (prompt );
164+ CodexCli .ExecOptions opts = defaultOptions (prompt ).json (true );
165+ CodexCliResult result = cli .exec (opts );
165166 return parseJsonlOutput (result .getStdout ());
166167 }
167168
@@ -296,7 +297,7 @@ public CodexCliResult execWithDisable(String prompt, String... features) {
296297 * @return the raw CLI invocation result; never {@code null}.
297298 */
298299 public CodexCliResult startSession () {
299- return cli .startInteractive ();
300+ return cli .startInteractive (defaultGlobalOptions (), null );
300301 }
301302
302303 /**
@@ -306,7 +307,7 @@ public CodexCliResult startSession() {
306307 * @return the raw CLI invocation result; never {@code null}.
307308 */
308309 public CodexCliResult startSession (String prompt ) {
309- return cli .startInteractive (prompt );
310+ return cli .startInteractive (defaultGlobalOptions (), prompt );
310311 }
311312
312313 /**
@@ -1122,7 +1123,7 @@ public CodexCliResult execute(String... args) {
11221123 * @return a fresh options instance; never {@code null}.
11231124 */
11241125 private CodexCli .ExecOptions defaultOptions (String prompt ) {
1125- CodexCli .ExecOptions opts = new CodexCli .ExecOptions (prompt ).json (true );
1126+ CodexCli .ExecOptions opts = new CodexCli .ExecOptions (prompt ).json (config . isJsonOutput () );
11261127 if (config .getDefaultModel () != null ) opts .model (config .getDefaultModel ());
11271128 if (config .getDefaultSandbox () != null ) opts .sandbox (config .getDefaultSandbox ());
11281129 if (config .getDefaultApprovalPolicy () != null ) opts .approvalPolicy (config .getDefaultApprovalPolicy ());
@@ -1146,6 +1147,33 @@ private CodexCli.ExecOptions defaultOptions(String prompt) {
11461147 return opts ;
11471148 }
11481149
1150+ /**
1151+ * Builds global options for the default interactive-session entry points.
1152+ *
1153+ * @return a fresh global-options instance populated from client defaults.
1154+ */
1155+ private CodexCli .GlobalOptions defaultGlobalOptions () {
1156+ CodexCli .GlobalOptions opts = new CodexCli .GlobalOptions ();
1157+ if (config .getDefaultModel () != null ) opts .model (config .getDefaultModel ());
1158+ if (config .getDefaultSandbox () != null ) opts .sandbox (config .getDefaultSandbox ());
1159+ if (config .getDefaultApprovalPolicy () != null ) opts .approvalPolicy (config .getDefaultApprovalPolicy ());
1160+ if (config .getDefaultProfile () != null ) opts .profile (config .getDefaultProfile ());
1161+ if (config .getWorkingDir () != null ) opts .workingDir (config .getWorkingDir ());
1162+ if (config .getAddDir () != null ) opts .addDir (config .getAddDir ());
1163+ if (config .isOssProvider ()) opts .oss (true );
1164+ if (config .getLocalProvider () != null ) opts .localProvider (config .getLocalProvider ());
1165+ if (config .isSearch ()) opts .search (true );
1166+ if (config .getImage () != null ) opts .image (config .getImage ());
1167+ if (config .getConfigOverrides () != null ) opts .configOverrides (config .getConfigOverrides ());
1168+ if (config .isDangerouslyBypassApprovalsAndSandbox ()) opts .dangerouslyBypassApprovalsAndSandbox (true );
1169+ if (config .isDangerouslyBypassHookTrust ()) opts .dangerouslyBypassHookTrust (true );
1170+ if (config .isStrictConfig ()) opts .strictConfig (true );
1171+ if (config .getEnable () != null ) opts .enable (config .getEnable ());
1172+ if (config .getDisable () != null ) opts .disable (config .getDisable ());
1173+ if (config .isNoAltScreen ()) opts .noAltScreen (true );
1174+ return opts ;
1175+ }
1176+
11491177 /**
11501178 * Decodes a JSON-Lines blob into a list of {@link CodexEvent}s.
11511179 *
0 commit comments