mirror of
https://github.com/openai/codex.git
synced 2026-11-24 23:20:47 +00:00
Support model and reasoning effort overrides in remote exec (#63462)
## Why `codex exec --remote` rejected model and reasoning effort overrides, so callers had to configure those settings on the app server. ## What changed Accept `--model`, `-c model=...`, and `-c model_reasoning_effort=...` when starting or resuming a remote thread. As in local exec, `--model` takes precedence over `-c model=...`. Explicit overrides update the remote thread for the current and subsequent turns. Omitted settings retain the thread's current values or use the server defaults for a new thread. ## Testing Add CLI integration coverage for fresh and resumed threads, override precedence, and inheritance across turns. Check that invalid or unrelated overrides fail before connecting. GitOrigin-RevId: 9bd18b65978962cf6f325feee1056d130e9e6b91
This commit is contained in:
@@ -20,7 +20,10 @@ fn exec_help_documents_cyber_access_program() {
|
||||
.join("\n");
|
||||
insta::assert_snapshot!(remote_help.trim(), @r"
|
||||
--remote <ADDR>
|
||||
Connect to an existing app server
|
||||
Connect to an existing app server. Explicit --model and -c
|
||||
model_reasoning_effort overrides update the remote thread for this
|
||||
turn and subsequent turns; omitted settings are inherited from the
|
||||
server
|
||||
");
|
||||
let program_help = help
|
||||
.to_string()
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
//! Shared real app-server and mock-inference fixture for remote CLI tests.
|
||||
|
||||
use anyhow::Result;
|
||||
use app_test_support::MockResponsesConfig;
|
||||
use app_test_support::TestAppServer;
|
||||
use app_test_support::create_final_assistant_message_sse_response;
|
||||
use codex_app_server_client::DEFAULT_IN_PROCESS_CHANNEL_CAPACITY;
|
||||
use codex_app_server_client::RemoteAppServerClient;
|
||||
use codex_app_server_client::RemoteAppServerConnectArgs;
|
||||
use codex_app_server_client::RemoteAppServerEndpoint;
|
||||
use codex_app_server_protocol::ClientRequest;
|
||||
use codex_app_server_protocol::RequestId;
|
||||
use codex_app_server_protocol::ThreadStartParams;
|
||||
use codex_app_server_protocol::ThreadStartResponse;
|
||||
use core_test_support::responses;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use std::time::Duration;
|
||||
use tempfile::TempDir;
|
||||
use tokio::process::Command;
|
||||
use tokio::time::timeout;
|
||||
use wiremock::Mock;
|
||||
use wiremock::MockGuard;
|
||||
use wiremock::MockServer;
|
||||
use wiremock::matchers::method;
|
||||
use wiremock::matchers::path;
|
||||
|
||||
pub struct RemoteExecFixture {
|
||||
pub endpoint: String,
|
||||
pub caller_home: TempDir,
|
||||
pub requests: MockGuard,
|
||||
codex: PathBuf,
|
||||
_server: TestAppServer,
|
||||
_model: MockServer,
|
||||
}
|
||||
|
||||
impl RemoteExecFixture {
|
||||
pub async fn start(
|
||||
codex: &Path,
|
||||
server_home: &Path,
|
||||
response: &str,
|
||||
expected_requests: u64,
|
||||
configure: impl FnOnce(MockResponsesConfig) -> MockResponsesConfig,
|
||||
env_overrides: &[(&str, Option<&str>)],
|
||||
) -> Result<(Self, RemoteAppServerClient, String)> {
|
||||
let model = responses::start_mock_server().await;
|
||||
let requests = Mock::given(method("POST"))
|
||||
.and(path("/v1/responses"))
|
||||
.respond_with(responses::sse_response(
|
||||
create_final_assistant_message_sse_response(response)?,
|
||||
))
|
||||
.expect(expected_requests)
|
||||
.mount_as_scoped(&model)
|
||||
.await;
|
||||
configure(
|
||||
MockResponsesConfig::new(&model.uri())
|
||||
.with_root_config("features.plugins = false\nanalytics.enabled = false"),
|
||||
)
|
||||
.write(server_home)?;
|
||||
let server = TestAppServer::builder()
|
||||
.with_program(codex)
|
||||
.with_codex_home(server_home)
|
||||
.with_plugin_startup_tasks()
|
||||
.without_managed_config()
|
||||
.with_args(&["app-server", "--listen", "unix://"])
|
||||
.with_env_overrides(env_overrides)
|
||||
.build()
|
||||
.await?;
|
||||
let socket_path = codex_app_server::app_server_control_socket_path(server_home)?;
|
||||
timeout(Duration::from_secs(30), async {
|
||||
while !socket_path.as_path().try_exists()? {
|
||||
tokio::time::sleep(Duration::from_millis(10)).await;
|
||||
}
|
||||
anyhow::Ok(())
|
||||
})
|
||||
.await??;
|
||||
let endpoint = format!("unix://{}", socket_path.as_path().display());
|
||||
let app = RemoteAppServerClient::connect(RemoteAppServerConnectArgs {
|
||||
required_human_approval: false,
|
||||
endpoint: RemoteAppServerEndpoint::UnixSocket { socket_path },
|
||||
client_name: "remote-cli-e2e-test".to_string(),
|
||||
client_version: "0.1.0".to_string(),
|
||||
experimental_api: true,
|
||||
mcp_server_openai_form_elicitation: false,
|
||||
opt_out_notification_methods: Vec::new(),
|
||||
channel_capacity: DEFAULT_IN_PROCESS_CHANNEL_CAPACITY,
|
||||
})
|
||||
.await?;
|
||||
let started: ThreadStartResponse = app
|
||||
.request_typed(ClientRequest::ThreadStart {
|
||||
request_id: RequestId::Integer(1),
|
||||
params: ThreadStartParams::default(),
|
||||
})
|
||||
.await?;
|
||||
Ok((
|
||||
Self {
|
||||
endpoint,
|
||||
caller_home: TempDir::new()?,
|
||||
requests,
|
||||
codex: codex.to_path_buf(),
|
||||
_server: server,
|
||||
_model: model,
|
||||
},
|
||||
app,
|
||||
started.thread.id,
|
||||
))
|
||||
}
|
||||
|
||||
pub fn caller_command(&self) -> Command {
|
||||
let mut command = Command::new(&self.codex);
|
||||
command
|
||||
.env("CODEX_HOME", self.caller_home.path())
|
||||
.current_dir(self.caller_home.path())
|
||||
.kill_on_drop(true);
|
||||
command
|
||||
}
|
||||
}
|
||||
+20
-71
@@ -1,3 +1,7 @@
|
||||
#[cfg(unix)]
|
||||
#[path = "common/remote_exec.rs"]
|
||||
mod remote_exec_support;
|
||||
|
||||
use std::path::Path;
|
||||
use std::process::Output;
|
||||
|
||||
@@ -263,14 +267,7 @@ async fn run_remote_queue_command(response: QueueResponse) -> Result<(Output, Va
|
||||
async fn remote_session_commands_with_workload_identity_use_server_auth() -> Result<()> {
|
||||
use std::time::Duration;
|
||||
|
||||
use app_test_support::MockResponsesConfig;
|
||||
use app_test_support::TestAppServer;
|
||||
use app_test_support::create_final_assistant_message_sse_response;
|
||||
use codex_app_server_client::AppServerEvent;
|
||||
use codex_app_server_client::DEFAULT_IN_PROCESS_CHANNEL_CAPACITY;
|
||||
use codex_app_server_client::RemoteAppServerClient;
|
||||
use codex_app_server_client::RemoteAppServerConnectArgs;
|
||||
use codex_app_server_client::RemoteAppServerEndpoint;
|
||||
use codex_app_server_protocol::ClientRequest;
|
||||
use codex_app_server_protocol::RequestId;
|
||||
use codex_app_server_protocol::ServerNotification;
|
||||
@@ -282,78 +279,32 @@ async fn remote_session_commands_with_workload_identity_use_server_auth() -> Res
|
||||
use codex_app_server_protocol::ThreadReadResponse;
|
||||
use codex_app_server_protocol::ThreadSetNameParams;
|
||||
use codex_app_server_protocol::ThreadSetNameResponse;
|
||||
use codex_app_server_protocol::ThreadStartParams;
|
||||
use codex_app_server_protocol::ThreadStartResponse;
|
||||
use codex_app_server_protocol::ThreadStatus;
|
||||
use codex_app_server_protocol::TurnStatus;
|
||||
use codex_protocol::shell_environment::OPENAI_FEDERATION_RULE_ID_ENV_VAR;
|
||||
use codex_protocol::shell_environment::OPENAI_IDENTITY_TOKEN_FILE_ENV_VAR;
|
||||
use core_test_support::responses;
|
||||
use tokio::process::Command;
|
||||
use tokio::time::timeout;
|
||||
use wiremock::Mock;
|
||||
use wiremock::matchers::method;
|
||||
use wiremock::matchers::path;
|
||||
|
||||
let codex_home = socket_test_home()?;
|
||||
let codex = codex_utils_cargo_bin::cargo_bin("codex")?;
|
||||
let model = responses::start_mock_server().await;
|
||||
let model_requests = Mock::given(method("POST"))
|
||||
.and(path("/v1/responses"))
|
||||
.respond_with(responses::sse_response(
|
||||
create_final_assistant_message_sse_response("queued message consumed")?,
|
||||
))
|
||||
.expect(4)
|
||||
.mount_as_scoped(&model)
|
||||
.await;
|
||||
MockResponsesConfig::new(&model.uri())
|
||||
.with_root_config("features.plugins = false\nanalytics.enabled = false")
|
||||
.with_provider_config("env_key = \"CODEX_QUEUE_SERVER_API_KEY\"")
|
||||
.write(codex_home.path())?;
|
||||
let _server = TestAppServer::builder()
|
||||
.with_program(&codex)
|
||||
.with_codex_home(codex_home.path())
|
||||
.with_plugin_startup_tasks()
|
||||
.without_managed_config()
|
||||
.with_args(&["app-server", "--listen", "unix://"])
|
||||
.with_env_overrides(&[
|
||||
let (fixture, mut app, thread_id) = remote_exec_support::RemoteExecFixture::start(
|
||||
&codex,
|
||||
codex_home.path(),
|
||||
"queued message consumed",
|
||||
/*expected_requests*/ 4,
|
||||
|config| config.with_provider_config("env_key = \"CODEX_QUEUE_SERVER_API_KEY\""),
|
||||
&[
|
||||
("OPENAI_API_KEY", None),
|
||||
("CODEX_API_KEY", None),
|
||||
("CODEX_ACCESS_TOKEN", None),
|
||||
(OPENAI_FEDERATION_RULE_ID_ENV_VAR, None),
|
||||
(OPENAI_IDENTITY_TOKEN_FILE_ENV_VAR, None),
|
||||
("CODEX_QUEUE_SERVER_API_KEY", Some("server-only-test-key")),
|
||||
])
|
||||
.build()
|
||||
.await?;
|
||||
let socket_path = codex_app_server::app_server_control_socket_path(codex_home.path())?;
|
||||
timeout(Duration::from_secs(30), async {
|
||||
while !socket_path.as_path().try_exists()? {
|
||||
tokio::time::sleep(Duration::from_millis(10)).await;
|
||||
}
|
||||
Ok::<_, anyhow::Error>(())
|
||||
})
|
||||
.await??;
|
||||
|
||||
let endpoint = format!("unix://{}", socket_path.as_path().display());
|
||||
let mut app = RemoteAppServerClient::connect(RemoteAppServerConnectArgs {
|
||||
required_human_approval: false,
|
||||
endpoint: RemoteAppServerEndpoint::UnixSocket { socket_path },
|
||||
client_name: "queue-e2e-test".to_string(),
|
||||
client_version: "0.1.0".to_string(),
|
||||
experimental_api: true,
|
||||
mcp_server_openai_form_elicitation: false,
|
||||
opt_out_notification_methods: Vec::new(),
|
||||
channel_capacity: DEFAULT_IN_PROCESS_CHANNEL_CAPACITY,
|
||||
})
|
||||
],
|
||||
)
|
||||
.await?;
|
||||
let started: ThreadStartResponse = app
|
||||
.request_typed(ClientRequest::ThreadStart {
|
||||
request_id: RequestId::Integer(1),
|
||||
params: ThreadStartParams::default(),
|
||||
})
|
||||
.await?;
|
||||
let thread_id = started.thread.id;
|
||||
let endpoint = &fixture.endpoint;
|
||||
let message = "synthetic WIF queue end-to-end message";
|
||||
let output = timeout(
|
||||
Duration::from_secs(30),
|
||||
@@ -401,7 +352,7 @@ async fn remote_session_commands_with_workload_identity_use_server_auth() -> Res
|
||||
.await?;
|
||||
assert!(queue.data.is_empty());
|
||||
|
||||
let requests = model_requests.received_requests().await;
|
||||
let requests = fixture.requests.received_requests().await;
|
||||
let request = requests
|
||||
.first()
|
||||
.context("queued message did not reach the model")?;
|
||||
@@ -417,7 +368,6 @@ async fn remote_session_commands_with_workload_identity_use_server_auth() -> Res
|
||||
let metadata: Value = serde_json::from_str(request.headers["x-codex-turn-metadata"].to_str()?)?;
|
||||
assert_eq!(metadata["turn_trigger"], "queue");
|
||||
|
||||
let exec_home = TempDir::new()?;
|
||||
for args in [
|
||||
vec!["exec", "--remote", &endpoint, "--json", "new task"],
|
||||
vec![
|
||||
@@ -429,10 +379,9 @@ async fn remote_session_commands_with_workload_identity_use_server_auth() -> Res
|
||||
"continue task",
|
||||
],
|
||||
] {
|
||||
let output = Command::new(&codex)
|
||||
.env("CODEX_HOME", exec_home.path())
|
||||
let output = fixture
|
||||
.caller_command()
|
||||
.env_remove("CODEX_QUEUE_SERVER_API_KEY")
|
||||
.current_dir(exec_home.path())
|
||||
.args(args)
|
||||
.output()
|
||||
.await?;
|
||||
@@ -495,7 +444,7 @@ async fn remote_session_commands_with_workload_identity_use_server_auth() -> Res
|
||||
)
|
||||
.env_remove("CODEX_QUEUE_SERVER_API_KEY")
|
||||
.kill_on_drop(true)
|
||||
.args(["--remote", &endpoint]);
|
||||
.args(["--remote", endpoint]);
|
||||
command
|
||||
};
|
||||
let output = timeout(
|
||||
@@ -590,10 +539,10 @@ async fn remote_session_commands_with_workload_identity_use_server_auth() -> Res
|
||||
);
|
||||
timeout(
|
||||
Duration::from_secs(30),
|
||||
model_requests.wait_until_satisfied(),
|
||||
fixture.requests.wait_until_satisfied(),
|
||||
)
|
||||
.await?;
|
||||
let requests = model_requests.received_requests().await;
|
||||
let requests = fixture.requests.received_requests().await;
|
||||
assert!(
|
||||
requests[3].body_json::<Value>()?["input"]
|
||||
.to_string()
|
||||
|
||||
@@ -0,0 +1,245 @@
|
||||
//! Exercise remote exec overrides through the CLI, a real app server, and mock inference.
|
||||
#![cfg(unix)]
|
||||
|
||||
#[path = "common/remote_exec.rs"]
|
||||
mod remote_exec_support;
|
||||
|
||||
use remote_exec_support::RemoteExecFixture;
|
||||
|
||||
use anyhow::Context;
|
||||
use anyhow::Result;
|
||||
use codex_app_server_client::AppServerEvent;
|
||||
use codex_app_server_protocol::ClientRequest;
|
||||
use codex_app_server_protocol::RequestId;
|
||||
use codex_app_server_protocol::ServerNotification;
|
||||
use codex_app_server_protocol::ThreadReadParams;
|
||||
use codex_app_server_protocol::ThreadReadResponse;
|
||||
use codex_app_server_protocol::TurnStartParams;
|
||||
use codex_app_server_protocol::TurnStartResponse;
|
||||
use codex_app_server_protocol::UserInput;
|
||||
use pretty_assertions::assert_eq;
|
||||
use serde_json::Value;
|
||||
use serde_json::json;
|
||||
use std::time::Duration;
|
||||
use tempfile::TempDir;
|
||||
use tokio::time::timeout;
|
||||
|
||||
#[tokio::test]
|
||||
async fn remote_exec_forwards_model_and_effort_and_preserves_omitted_settings() -> Result<()> {
|
||||
// Keep the control socket below macOS's Unix socket path limit.
|
||||
let server_home = tempfile::tempdir_in("/tmp")?;
|
||||
let codex = codex_utils_cargo_bin::cargo_bin("codex")?;
|
||||
let mut catalog = codex_models_manager::bundled_models_response()?;
|
||||
let template = catalog
|
||||
.models
|
||||
.first()
|
||||
.context("empty bundled catalog")?
|
||||
.clone();
|
||||
catalog.models = ["gpt-5.1", "gpt-5.2"]
|
||||
.into_iter()
|
||||
.map(|slug| {
|
||||
let mut model = template.clone();
|
||||
model.slug = slug.to_string();
|
||||
model.model_messages = Some(codex_protocol::openai_models::ModelMessages {
|
||||
instructions_template: Some(format!("Base instructions for {slug}")),
|
||||
..Default::default()
|
||||
});
|
||||
model
|
||||
})
|
||||
.collect();
|
||||
let catalog_path = server_home.path().join("models.json");
|
||||
std::fs::write(&catalog_path, serde_json::to_vec(&catalog)?)?;
|
||||
let catalog_config = format!(
|
||||
"model_catalog_json = {}",
|
||||
serde_json::to_string(&catalog_path)?
|
||||
);
|
||||
let (fixture, mut app, thread_id) = RemoteExecFixture::start(
|
||||
&codex,
|
||||
server_home.path(),
|
||||
"remote override completed",
|
||||
/*expected_requests*/ 7,
|
||||
|config| {
|
||||
config
|
||||
.with_model("gpt-5.1")
|
||||
.with_root_config(&catalog_config)
|
||||
.with_root_config("model_reasoning_effort = 'low'")
|
||||
},
|
||||
&[],
|
||||
)
|
||||
.await?;
|
||||
// Client config must not replace the server's credentials or thread settings.
|
||||
std::fs::write(
|
||||
fixture.caller_home.path().join("config.toml"),
|
||||
"model = 'client-model'\nmodel_reasoning_effort = 'minimal'\n",
|
||||
)?;
|
||||
// A new thread's rollout is persisted lazily on its first turn. Seed a
|
||||
// completed interactive turn before another client resumes the shared thread.
|
||||
let _: TurnStartResponse = app
|
||||
.request_typed(ClientRequest::TurnStart {
|
||||
request_id: RequestId::Integer(2),
|
||||
params: TurnStartParams {
|
||||
thread_id: thread_id.clone(),
|
||||
input: vec![UserInput::Text {
|
||||
text: "seed the shared conversation".to_string(),
|
||||
text_elements: Vec::new(),
|
||||
}],
|
||||
..Default::default()
|
||||
},
|
||||
})
|
||||
.await?;
|
||||
timeout(Duration::from_secs(30), async {
|
||||
while let Some(event) = app.next_event().await {
|
||||
if let AppServerEvent::ServerNotification(notification) = event
|
||||
&& let ServerNotification::TurnCompleted(_) = *notification
|
||||
{
|
||||
return anyhow::Ok(());
|
||||
}
|
||||
}
|
||||
anyhow::bail!("app server disconnected before the initial turn completed")
|
||||
})
|
||||
.await??;
|
||||
|
||||
let cases: &[(&[&str], &str, &str)] = &[
|
||||
(&[], "gpt-5.1", "low"),
|
||||
(
|
||||
&["--model", "gpt-5.2", "-c", "model_reasoning_effort=high"],
|
||||
"gpt-5.2",
|
||||
"high",
|
||||
),
|
||||
(&[], "gpt-5.2", "high"),
|
||||
(
|
||||
&["-c", "model_reasoning_effort=medium"],
|
||||
"gpt-5.2",
|
||||
"medium",
|
||||
),
|
||||
(&["-c", "model='gpt-5.1'"], "gpt-5.1", "medium"),
|
||||
(
|
||||
&[
|
||||
"-c",
|
||||
"model='gpt-5.1'",
|
||||
"--model",
|
||||
"gpt-5.2",
|
||||
"-c",
|
||||
"model_reasoning_effort=low",
|
||||
"-c",
|
||||
"model_reasoning_effort='high'",
|
||||
],
|
||||
"gpt-5.2",
|
||||
"high",
|
||||
),
|
||||
];
|
||||
for (index, &(overrides, expected_model, expected_effort)) in cases.iter().enumerate() {
|
||||
let mut command = fixture.caller_command();
|
||||
command.arg("exec");
|
||||
// Also cover creating a fresh thread, not just resuming a loaded one.
|
||||
let resume = index + 1 < cases.len();
|
||||
if resume {
|
||||
command.args(["resume", &thread_id]);
|
||||
}
|
||||
let output = timeout(
|
||||
Duration::from_secs(30),
|
||||
command
|
||||
.args(["--remote", &fixture.endpoint, "--json"])
|
||||
.args(overrides)
|
||||
.arg(format!("remote override case {index}"))
|
||||
.output(),
|
||||
)
|
||||
.await??;
|
||||
assert!(
|
||||
output.status.success(),
|
||||
"{}",
|
||||
String::from_utf8_lossy(&output.stderr)
|
||||
);
|
||||
let events = String::from_utf8(output.stdout)?
|
||||
.lines()
|
||||
.map(serde_json::from_str::<Value>)
|
||||
.collect::<serde_json::Result<Vec<_>>>()?;
|
||||
if resume {
|
||||
assert_eq!(events[0]["thread_id"], thread_id);
|
||||
} else {
|
||||
assert_ne!(events[0]["thread_id"], thread_id);
|
||||
let fresh: ThreadReadResponse = app
|
||||
.request_typed(ClientRequest::ThreadRead {
|
||||
request_id: RequestId::Integer(4),
|
||||
params: ThreadReadParams {
|
||||
thread_id: events[0]["thread_id"]
|
||||
.as_str()
|
||||
.context("missing thread id")?
|
||||
.to_string(),
|
||||
include_turns: false,
|
||||
},
|
||||
})
|
||||
.await?;
|
||||
let rollout =
|
||||
std::fs::read_to_string(fresh.thread.path.context("missing rollout path")?)?;
|
||||
let metadata: Value =
|
||||
serde_json::from_str(rollout.lines().next().context("empty rollout")?)?;
|
||||
assert_eq!(
|
||||
metadata["payload"]["base_instructions"]["text"],
|
||||
format!("Base instructions for {expected_model}")
|
||||
);
|
||||
}
|
||||
assert!(events.iter().any(|event| event["type"] == "turn.completed"));
|
||||
assert!(
|
||||
events
|
||||
.iter()
|
||||
.any(|event| event["item"]["text"] == "remote override completed")
|
||||
);
|
||||
let captured = fixture.requests.received_requests().await;
|
||||
assert_eq!(captured.len(), index + 2);
|
||||
let body: Value = captured
|
||||
.last()
|
||||
.context("missing inference request")?
|
||||
.body_json()?;
|
||||
assert_eq!(
|
||||
json!({"model": body["model"], "effort": body["reasoning"]["effort"]}),
|
||||
json!({"model": expected_model, "effort": expected_effort})
|
||||
);
|
||||
}
|
||||
let shared: ThreadReadResponse = app
|
||||
.request_typed(ClientRequest::ThreadRead {
|
||||
request_id: RequestId::Integer(3),
|
||||
params: ThreadReadParams {
|
||||
thread_id,
|
||||
include_turns: true,
|
||||
},
|
||||
})
|
||||
.await?;
|
||||
assert_eq!(shared.thread.turns.len(), 6);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn remote_exec_rejects_invalid_or_unrelated_overrides_before_connecting() -> Result<()> {
|
||||
let home = TempDir::new()?;
|
||||
for (config, expected) in [
|
||||
("model=42", "invalid model override"),
|
||||
(
|
||||
"model_reasoning_effort=42",
|
||||
"invalid model_reasoning_effort override",
|
||||
),
|
||||
(
|
||||
"approval_policy='never'",
|
||||
"does not support config override `approval_policy`",
|
||||
),
|
||||
] {
|
||||
let output = std::process::Command::new(codex_utils_cargo_bin::cargo_bin("codex")?)
|
||||
.env("CODEX_HOME", home.path())
|
||||
.args([
|
||||
"exec",
|
||||
"--remote",
|
||||
"ws://127.0.0.1:1",
|
||||
"-c",
|
||||
config,
|
||||
"hello",
|
||||
])
|
||||
.output()?;
|
||||
assert!(!output.status.success());
|
||||
assert!(
|
||||
String::from_utf8_lossy(&output.stderr).contains(expected),
|
||||
"{}",
|
||||
String::from_utf8_lossy(&output.stderr)
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -18,6 +18,8 @@ pub struct Cli {
|
||||
pub command: Option<Command>,
|
||||
|
||||
/// Connect to an existing app server.
|
||||
/// Explicit --model and -c model_reasoning_effort overrides update the remote thread
|
||||
/// for this turn and subsequent turns; omitted settings are inherited from the server.
|
||||
#[arg(
|
||||
id = "exec_remote",
|
||||
long = "remote",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
//! Execute a noninteractive turn on an existing app server, using its configuration and credentials.
|
||||
|
||||
use super::*;
|
||||
use anyhow::Context;
|
||||
use codex_app_server_client::RemoteAppServerClient;
|
||||
use codex_app_server_client::RemoteAppServerConnectArgs;
|
||||
use codex_app_server_client::RemoteAppServerEndpoint;
|
||||
@@ -15,9 +16,7 @@ pub(super) async fn run(cli: Cli, endpoint: RemoteAppServerEndpoint) -> anyhow::
|
||||
&& cli.thread_source.is_none()
|
||||
&& cli.cyber_access_program.is_none()
|
||||
&& cli.output_schema.is_none()
|
||||
&& cli.config_overrides.raw_overrides.is_empty()
|
||||
&& cli.images.is_empty()
|
||||
&& cli.model.is_none()
|
||||
&& !cli.oss
|
||||
&& cli.oss_provider.is_none()
|
||||
&& cli.config_profile_v2.is_none()
|
||||
@@ -28,8 +27,37 @@ pub(super) async fn run(cli: Cli, endpoint: RemoteAppServerEndpoint) -> anyhow::
|
||||
&& cli.cwd.is_none()
|
||||
&& !cli.worktree
|
||||
&& cli.add_dir.is_empty(),
|
||||
"--remote currently supports only prompt, resume by UUID, and output options; configure the agent on the server"
|
||||
"--remote supports prompt, resume by UUID, model, reasoning effort, and output options; configure other agent settings on the server"
|
||||
);
|
||||
let mut model = None;
|
||||
let mut effort = None;
|
||||
for (key, value) in cli
|
||||
.config_overrides
|
||||
.parse_overrides()
|
||||
.map_err(anyhow::Error::msg)?
|
||||
{
|
||||
match key.as_str() {
|
||||
"model" => {
|
||||
model = Some(
|
||||
serde_json::from_value::<String>(serde_json::to_value(value)?)
|
||||
.context("invalid model override: expected a string")?,
|
||||
);
|
||||
}
|
||||
"model_reasoning_effort" => {
|
||||
effort = Some(
|
||||
serde_json::from_value::<codex_protocol::openai_models::ReasoningEffort>(
|
||||
serde_json::to_value(value)?,
|
||||
)
|
||||
.context("invalid model_reasoning_effort override")?,
|
||||
);
|
||||
}
|
||||
_ => anyhow::bail!(
|
||||
"--remote does not support config override `{key}`; configure it on the server"
|
||||
),
|
||||
}
|
||||
}
|
||||
// Match local exec precedence: --model wins over -c model=... .
|
||||
let model = cli.model.clone().or(model);
|
||||
let (session_id, prompt) = match cli.command {
|
||||
None => (None, resolve_root_prompt(cli.prompt)),
|
||||
Some(ExecCommand::Resume(args)) => {
|
||||
@@ -95,6 +123,7 @@ pub(super) async fn run(cli: Cli, endpoint: RemoteAppServerEndpoint) -> anyhow::
|
||||
.request_typed::<ThreadStartResponse>(ClientRequest::ThreadStart {
|
||||
request_id: ids.next(),
|
||||
params: ThreadStartParams {
|
||||
model: model.clone(),
|
||||
approval_policy: Some(codex_app_server_protocol::AskForApproval::Never),
|
||||
..Default::default()
|
||||
},
|
||||
@@ -127,6 +156,10 @@ pub(super) async fn run(cli: Cli, endpoint: RemoteAppServerEndpoint) -> anyhow::
|
||||
text_elements: Vec::new(),
|
||||
}],
|
||||
approval_policy: Some(codex_app_server_protocol::AskForApproval::Never),
|
||||
// Like other app-server clients, explicit overrides apply to this
|
||||
// turn and subsequent turns. Omission preserves the thread settings.
|
||||
model,
|
||||
effort,
|
||||
..Default::default()
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user