Skip to content

Commit daec1b3

Browse files
committed
Prevent profile from being overridden by defaults
Previously, when loading a custom profile via --profile, its settings could be overridden by defaults from the initial Profile() instance because argparse was initialized with those defaults, and only None-valued arguments would be updated from the custom profile. This caused issues like custom model settings being reset to the default claude-3-5-sonnet-20241022. This change: - Creates a fresh Profile instance when loading custom profiles - Tracks which arguments were explicitly provided via CLI - Updates args from profile unless explicitly set via CLI This ensures profile settings take precedence over defaults while still allowing CLI arguments to override profile settings. Example: Before: Custom profile with model="gpt-4o-mini" would be overridden by default model="claude-3-5-sonnet-20241022" unless --model was explicitly set on command line. After: Custom profile settings are preserved unless explicitly overridden by command line arguments. The provider auto-detection still works as expected: - If profile sets both model and provider: uses those values - If profile sets only model: provider=None allows auto-detection
1 parent dec7faa commit daec1b3

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

interpreter/cli.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,16 @@ def parse_args():
270270
subprocess.run([opener, profile_dir])
271271
sys.exit(0)
272272

273+
# If custom profile specified, load it and update args
273274
if args["profile"] != profile.profile_path:
274-
profile.load(args["profile"])
275+
# Load the specified profile, ignoring any defaults
276+
profile = Profile.from_file(args["profile"])
277+
# Find which settings were explicitly set via command line flags
278+
cli_provided = {k for k,v in parser._option_string_actions.items()
279+
if v.dest in args and sys.argv.__contains__(k)}
280+
# Update args with profile values, preserving any CLI overrides
275281
for key, value in vars(profile).items():
276-
if key in args and args[key] is None:
282+
if key in args and key not in cli_provided:
277283
args[key] = value
278284

279285
if args["save"]:

0 commit comments

Comments
 (0)