fix: project model and reasoning_effort into Codex CLI args, stop rewriting .codex/config.toml
- Add model_reasoning_effort field to AgentProfile (domain layer) - Remove model parameter from codex_config_toml, stop rewriting model in TOML - Pass model and model_reasoning_effort via Codex CLI -c overrides on every exec - Update CodexExecSession with new_with_policy_and_overrides factory - Cover new conversation and resume flows with tests
This commit is contained in:
@ -239,7 +239,6 @@ impl TicketAssistantEnvironmentPreparer {
|
||||
&declaration,
|
||||
cwd.as_str(),
|
||||
project.root.as_str(),
|
||||
profile.model.as_deref(),
|
||||
);
|
||||
self.write_file(&path, rendered.as_bytes()).await?;
|
||||
env.push((home_env.clone(), parent_dir(cwd, target)));
|
||||
@ -518,12 +517,8 @@ fn codex_config_toml(
|
||||
mcp_declaration: &str,
|
||||
run_dir: &str,
|
||||
project_root: &str,
|
||||
model: Option<&str>,
|
||||
) -> String {
|
||||
let mut text = existing.unwrap_or_default().to_owned();
|
||||
if let Some(model) = model {
|
||||
text = set_top_level_toml_value(&text, "model", model);
|
||||
}
|
||||
text = replace_toml_table_block(&text, "mcp_servers.idea", mcp_declaration.trim_end());
|
||||
text = replace_toml_table_block(
|
||||
&text,
|
||||
@ -538,33 +533,6 @@ fn codex_config_toml(
|
||||
text
|
||||
}
|
||||
|
||||
fn set_top_level_toml_value(input: &str, key: &str, value: &str) -> String {
|
||||
let line = format!("{key} = {}", toml_quoted(value));
|
||||
set_top_level_toml_line(input, key, &line)
|
||||
}
|
||||
|
||||
fn set_top_level_toml_line(input: &str, key: &str, replacement: &str) -> String {
|
||||
let needle = format!("{key} =");
|
||||
let mut out = Vec::new();
|
||||
let mut replaced = false;
|
||||
for line in input.lines() {
|
||||
let trimmed = line.trim_start();
|
||||
if !replaced && trimmed.starts_with(&needle) {
|
||||
out.push(replacement.to_owned());
|
||||
replaced = true;
|
||||
} else {
|
||||
out.push(line.to_owned());
|
||||
}
|
||||
}
|
||||
if !replaced {
|
||||
if !out.is_empty() && !out.first().is_some_and(|line| line.trim().starts_with('[')) {
|
||||
out.push(String::new());
|
||||
}
|
||||
out.insert(0, replacement.to_owned());
|
||||
}
|
||||
out.join("\n")
|
||||
}
|
||||
|
||||
fn replace_toml_table_block(existing: &str, table: &str, replacement: &str) -> String {
|
||||
let header = format!("[{table}]");
|
||||
let mut out = Vec::new();
|
||||
@ -669,13 +637,7 @@ mod codex_config_toml_tests {
|
||||
.to_config_toml();
|
||||
let existing = "user_key = \"keep\"\n\n[features.code_mode]\ndirect_only_tool_namespaces = [\"old\"]\n\n[features.preview]\nenabled = true\n\n[user.table]\nvalue = 1\n";
|
||||
|
||||
let rendered = codex_config_toml(
|
||||
Some(existing),
|
||||
&declaration,
|
||||
"/run/assistant",
|
||||
"/proj",
|
||||
None,
|
||||
);
|
||||
let rendered = codex_config_toml(Some(existing), &declaration, "/run/assistant", "/proj");
|
||||
|
||||
assert!(
|
||||
rendered.contains("user_key = \"keep\""),
|
||||
|
||||
Reference in New Issue
Block a user