fix: Codex PTY launch forwards profile model as argv override

- injecte model et model_reasoning_effort du profil via -c dans argv
- remplace le modèle TUI stale en config.toml
- aligne PTY/interactif sur le comportement déjà garanti par CodexExecSession
- test unitaire codex_pty_launch_forwards_profile_model_as_config_override
This commit is contained in:
2026-08-02 18:02:00 +02:00
parent dcc7a6f216
commit 7c2bd227d2
2 changed files with 103 additions and 0 deletions

View File

@ -1254,6 +1254,49 @@ fn projection_model(profile: &AgentProfile) -> Option<&str> {
profile.model.as_deref()
}
fn is_codex_profile(profile: &AgentProfile) -> bool {
matches!(profile.structured_adapter, Some(StructuredAdapter::Codex))
|| matches!(profile.projector, Some(ProjectorKey::Codex))
|| profile
.command
.rsplit(['/', '\\'])
.next()
.unwrap_or(&profile.command)
== "codex"
}
fn append_codex_pty_model_overrides(profile: &AgentProfile, spec: &mut SpawnSpec) {
if !is_codex_profile(profile) {
return;
}
if let Some(model) = profile
.model
.as_deref()
.map(str::trim)
.filter(|model| !model.is_empty())
{
spec.args.push("-c".to_owned());
spec.args
.push(format!("model={}", toml_string_literal(model)));
}
if let Some(effort) = profile
.model_reasoning_effort
.as_deref()
.map(str::trim)
.filter(|effort| !effort.is_empty())
{
spec.args.push("-c".to_owned());
spec.args.push(format!(
"model_reasoning_effort={}",
toml_string_literal(effort)
));
}
}
fn toml_string_literal(value: &str) -> String {
serde_json::to_string(value).expect("string serialization cannot fail")
}
/// Launches an agent: resolve profile + context, prepare the invocation, apply
/// the context-injection plan, open a PTY at the resolved `cwd`, spawn the CLI.
///
@ -2036,6 +2079,12 @@ impl LaunchAgent {
}
}
// PTY/interactif Codex : le TUI conserve un état `model = ...` dans son
// CODEX_HOME isolé. Passer le modèle du profil sur l'argv garantit que le
// lancement interactif respecte l'édition IdeA, comme le chemin structuré
// le fait déjà dans `CodexExecSession`.
append_codex_pty_model_overrides(&profile, &mut spec);
// 6. Spawn the PTY at the resolved cwd; adopt its session id everywhere.
let handle = self.pty.spawn(spec.clone(), size).await?;
let session_id = handle.session_id;