Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 73d048a

Browse files
committedMar 30, 2025
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 30ec1e9 commit 73d048a

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
@@ -275,10 +275,16 @@ def parse_args():
275275
subprocess.run([opener, profile_dir])
276276
sys.exit(0)
277277

278+
# If custom profile specified, load it and update args
278279
if args["profile"] != profile.profile_path:
279-
profile.load(args["profile"])
280+
# Load the specified profile, ignoring any defaults
281+
profile = Profile.from_file(args["profile"])
282+
# Find which settings were explicitly set via command line flags
283+
cli_provided = {k for k,v in parser._option_string_actions.items()
284+
if v.dest in args and sys.argv.__contains__(k)}
285+
# Update args with profile values, preserving any CLI overrides
280286
for key, value in vars(profile).items():
281-
if key in args and args[key] is None:
287+
if key in args and key not in cli_provided:
282288
args[key] = value
283289

284290
if args["save"]:

0 commit comments

Comments
 (0)
Please sign in to comment.