@@ -18,8 +18,6 @@ defmodule Codex.Runtime.Exec.Profile do
1818 args =
1919 [ "exec" , "--json" ]
2020 |> Shared . maybe_add_pair ( "--profile" , Keyword . get ( opts , :cli_profile ) )
21- |> Shared . maybe_add_flag ( "--oss" , oss_enabled? ( opts ) )
22- |> Shared . maybe_add_pair ( "--local-provider" , local_provider_value ( opts ) )
2321 |> Shared . maybe_add_flag ( "--full-auto" , Keyword . get ( opts , :full_auto ) )
2422 |> Shared . maybe_add_flag (
2523 "--dangerously-bypass-approvals-and-sandbox" ,
@@ -32,12 +30,12 @@ defmodule Codex.Runtime.Exec.Profile do
3230 |> Shared . maybe_add_pair ( "--cd" , Keyword . get ( opts , :working_directory ) )
3331 |> Shared . maybe_add_repeat ( "--add-dir" , Keyword . get ( opts , :additional_directories , [ ] ) )
3432 |> Shared . maybe_add_flag ( "--skip-git-repo-check" , Keyword . get ( opts , :skip_git_repo_check ) )
33+ |> Shared . maybe_add_repeat ( "--config" , config_values ( opts ) )
3534 |> Kernel . ++ ( normalize_string_list ( Keyword . get ( opts , :subcommand_args , [ ] ) ) )
3635 |> Shared . maybe_add_pair ( "--continuation-token" , Keyword . get ( opts , :continuation_token ) )
3736 |> Shared . maybe_add_pair ( "--cancellation-token" , Keyword . get ( opts , :cancellation_token ) )
3837 |> Shared . maybe_add_repeat ( "--image" , Keyword . get ( opts , :images , [ ] ) )
3938 |> maybe_add_output_schema ( Keyword . get ( opts , :output_schema ) )
40- |> Shared . maybe_add_repeat ( "--config" , config_values ( opts ) )
4139 |> maybe_add_prompt ( Keyword . get ( opts , :prompt ) )
4240
4341 { :ok ,
@@ -87,12 +85,11 @@ defmodule Codex.Runtime.Exec.Profile do
8785 defp normalize_string_list ( _values ) , do: [ ]
8886
8987 defp model_value ( opts ) do
90- Keyword . get ( opts , :model ) || model_payload_value ( opts , :resolved_model )
91- end
92-
93- defp oss_enabled? ( opts ) do
94- payload_backend = model_payload_value ( opts , :provider_backend )
95- payload_backend in [ :oss , "oss" ] || Keyword . get ( opts , :oss ) == true
88+ if local_provider_value ( opts ) do
89+ nil
90+ else
91+ Keyword . get ( opts , :model ) || model_payload_value ( opts , :resolved_model )
92+ end
9693 end
9794
9895 defp local_provider_value ( opts ) do
@@ -107,10 +104,25 @@ defmodule Codex.Runtime.Exec.Profile do
107104 |> List . wrap ( )
108105 |> Enum . filter ( & ( is_binary ( & 1 ) and & 1 != "" ) )
109106
110- ( Keyword . get ( opts , :config_values , [ ] ) ++ payload_values )
107+ ( local_model_provider_config_values ( opts ) ++
108+ Keyword . get ( opts , :config_values , [ ] ) ++
109+ payload_values )
111110 |> Enum . uniq ( )
112111 end
113112
113+ defp local_model_provider_config_values ( opts ) do
114+ model = Keyword . get ( opts , :model ) || model_payload_value ( opts , :resolved_model )
115+
116+ case { local_provider_value ( opts ) , model } do
117+ { provider , model }
118+ when is_binary ( provider ) and provider != "" and is_binary ( model ) and model != "" ->
119+ [ ~s( model_provider="#{ provider } ") , ~s( model="#{ model } ") ]
120+
121+ _other ->
122+ [ ]
123+ end
124+ end
125+
114126 defp model_payload_backend_metadata ( opts ) do
115127 opts
116128 |> Keyword . get ( :model_payload , % { } )
0 commit comments