Run the active profile's pinned args
generate_compose now inserts profile.args between the prompt flag and the
per-run CLI trailing args, so selecting a profile applies its flags while
`ramekin -- ...` can still override them.
Assisted-by: Claude Opus 4.8 via pi
diff --git a/src/main.rs b/src/main.rs
index 8be7372..ade424b 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -764,6 +764,7 @@ impl Ramekin {
config::Agent::Pi => "--append-system-prompt",
config::Agent::Claude => "--append-system-prompt-file",
},
+ profile_args: &self.config.profile.args,
agent_args,
});
let compose_file = session_dir.join("compose.yml");
@@ -1024,6 +1025,9 @@ struct ComposeParams<'a> {
/// of its own.
entrypoint: &'a str,
prompt_flag: &'a str,
+ /// CLI flags the active profile pins for the agent binary. Placed before
+ /// the per-run trailing args so a `ramekin -- ...` flag still wins.
+ profile_args: &'a [String],
agent_args: &'a [String],
}
@@ -1038,6 +1042,7 @@ fn generate_compose(params: ComposeParams) -> String {
working_dir,
entrypoint,
prompt_flag,
+ profile_args,
agent_args,
} = params;
@@ -1063,9 +1068,10 @@ fn generate_compose(params: ComposeParams) -> String {
.collect();
// Always pass the prompt flag for the ramekin container context.
- // User-supplied agent args come last so they can override.
+ // Profile args come next; user-supplied CLI args come last so they win.
let command: Vec<String> = [prompt_flag.to_string(), PROMPT_TARGET.to_string()]
.into_iter()
+ .chain(profile_args.iter().cloned())
.chain(agent_args.iter().cloned())
.collect();
@@ -1118,10 +1124,29 @@ mod tests {
working_dir: "/workspace/x-1",
entrypoint: "pi",
prompt_flag: "--append-system-prompt",
+ profile_args: &[],
agent_args: &[],
}
}
+ #[test]
+ fn generate_compose_places_profile_args_before_cli_args() {
+ let profile_args = vec!["--provider".to_string(), "amazon-bedrock".to_string()];
+ let cli_args = vec!["--model".to_string(), "override".to_string()];
+ let mut params = compose_params(&[], &[]);
+ params.profile_args = &profile_args;
+ params.agent_args = &cli_args;
+ let yaml = generate_compose(params);
+
+ let prompt = yaml.find(PROMPT_TARGET).expect("prompt target missing");
+ let provider = yaml.find("amazon-bedrock").expect("profile arg missing");
+ let model = yaml.find("override").expect("cli arg missing");
+ assert!(
+ prompt < provider && provider < model,
+ "expected prompt < profile arg < cli arg, got {yaml}"
+ );
+ }
+
#[test]
fn generate_compose_long_form_binds() {
let mount = config::ResolvedMount {