Apply argument comment lint across codex-rs (#14652)

## Why

Once the repo-local lint exists, `codex-rs` needs to follow the
checked-in convention and CI needs to keep it from drifting. This commit
applies the fallback `/*param*/` style consistently across existing
positional literal call sites without changing those APIs.

The longer-term preference is still to avoid APIs that require comments
by choosing clearer parameter types and call shapes. This PR is
intentionally the mechanical follow-through for the places where the
existing signatures stay in place.

After rebasing onto newer `main`, the rollout also had to cover newly
introduced `tui_app_server` call sites. That made it clear the first cut
of the CI job was too expensive for the common path: it was spending
almost as much time installing `cargo-dylint` and re-testing the lint
crate as a representative test job spends running product tests. The CI
update keeps the full workspace enforcement but trims that extra
overhead from ordinary `codex-rs` PRs.

## What changed

- keep a dedicated `argument_comment_lint` job in `rust-ci`
- mechanically annotate remaining opaque positional literals across
`codex-rs` with exact `/*param*/` comments, including the rebased
`tui_app_server` call sites that now fall under the lint
- keep the checked-in style aligned with the lint policy by using
`/*param*/` and leaving string and char literals uncommented
- cache `cargo-dylint`, `dylint-link`, and the relevant Cargo
registry/git metadata in the lint job
- split changed-path detection so the lint crate's own `cargo test` step
runs only when `tools/argument-comment-lint/*` or `rust-ci.yml` changes
- continue to run the repo wrapper over the `codex-rs` workspace, so
product-code enforcement is unchanged

Most of the code changes in this commit are intentionally mechanical
comment rewrites or insertions driven by the lint itself.

## Verification

- `./tools/argument-comment-lint/run.sh --workspace`
- `cargo test -p codex-tui-app-server -p codex-tui`
- parsed `.github/workflows/rust-ci.yml` locally with PyYAML

---

* -> #14652
* #14651
This commit is contained in:
Michael Bolin
2026-03-16 16:48:15 -07:00
committed by GitHub
Unverified
parent 6f05d8d735
commit b77fe8fefe
261 changed files with 2311 additions and 1377 deletions
+3 -3
View File
@@ -186,7 +186,7 @@ impl AgentControl {
initial_history,
self.clone(),
session_source,
false,
/*persist_extended_history*/ false,
inherited_shell_snapshot,
)
.await?
@@ -196,8 +196,8 @@ impl AgentControl {
config,
self.clone(),
session_source,
false,
None,
/*persist_extended_history*/ false,
/*metrics_service_name*/ None,
inherited_shell_snapshot,
)
.await?
+7 -3
View File
@@ -138,7 +138,11 @@ impl Guards {
active_agents.used_agent_nicknames.clear();
active_agents.nickname_reset_count += 1;
if let Some(metrics) = codex_otel::metrics::global() {
let _ = metrics.counter("codex.multi_agent.nickname_pool_reset", 1, &[]);
let _ = metrics.counter(
"codex.multi_agent.nickname_pool_reset",
/*inc*/ 1,
&[],
);
}
format_agent_nickname(
names.choose(&mut rand::rng())?,
@@ -179,7 +183,7 @@ pub(crate) struct SpawnReservation {
impl SpawnReservation {
pub(crate) fn reserve_agent_nickname(&mut self, names: &[&str]) -> Result<String> {
self.reserve_agent_nickname_with_preference(names, None)
self.reserve_agent_nickname_with_preference(names, /*preferred*/ None)
}
pub(crate) fn reserve_agent_nickname_with_preference(
@@ -198,7 +202,7 @@ impl SpawnReservation {
}
pub(crate) fn commit(self, thread_id: ThreadId) {
self.commit_with_agent_nickname(thread_id, None);
self.commit_with_agent_nickname(thread_id, /*agent_nickname*/ None);
}
pub(crate) fn commit_with_agent_nickname(
+4 -1
View File
@@ -231,7 +231,10 @@ mod reload {
fn existing_layers(config: &Config) -> Vec<ConfigLayerEntry> {
config
.config_layer_stack
.get_layers(ConfigLayerStackOrdering::LowestPrecedenceFirst, true)
.get_layers(
ConfigLayerStackOrdering::LowestPrecedenceFirst,
/*include_disabled*/ true,
)
.into_iter()
.cloned()
.collect()
+6 -2
View File
@@ -194,7 +194,11 @@ impl CodexAuth {
codex_home: &Path,
auth_credentials_store_mode: AuthCredentialsStoreMode,
) -> std::io::Result<Option<Self>> {
load_auth(codex_home, false, auth_credentials_store_mode)
load_auth(
codex_home,
/*enable_codex_api_key_env*/ false,
auth_credentials_store_mode,
)
}
pub fn auth_mode(&self) -> AuthMode {
@@ -457,7 +461,7 @@ pub fn load_auth_dot_json(
pub fn enforce_login_restrictions(config: &Config) -> std::io::Result<()> {
let Some(auth) = load_auth(
&config.codex_home,
true,
/*enable_codex_api_key_env*/ true,
config.cli_auth_credentials_store_mode,
)?
else {
+24 -18
View File
@@ -564,7 +564,7 @@ impl ModelClient {
auth_context.recovery_mode,
auth_context.recovery_phase,
request_route_telemetry.endpoint,
false,
/*connection_reused*/ false,
response_debug.request_id.as_deref(),
response_debug.cf_ray.as_deref(),
response_debug.auth_error.as_deref(),
@@ -796,9 +796,11 @@ impl ModelClientSession {
let Some(last_response) = self.get_last_response() else {
return ResponsesWsRequest::ResponseCreate(payload);
};
let Some(incremental_items) =
self.get_incremental_items(request, Some(&last_response), true)
else {
let Some(incremental_items) = self.get_incremental_items(
request,
Some(&last_response),
/*allow_empty_delta*/ true,
) else {
return ResponsesWsRequest::ResponseCreate(payload);
};
@@ -846,13 +848,14 @@ impl ModelClientSession {
client_setup.api_provider,
client_setup.api_auth,
Some(Arc::clone(&self.turn_state)),
None,
/*turn_metadata_header*/ None,
auth_context,
RequestRouteTelemetry::for_endpoint(RESPONSES_ENDPOINT),
)
.await?;
self.websocket_session.connection = Some(connection);
self.websocket_session.set_connection_reused(false);
self.websocket_session
.set_connection_reused(/*connection_reused*/ false);
Ok(())
}
/// Returns a websocket connection for this turn.
@@ -906,9 +909,11 @@ impl ModelClientSession {
)
.await?;
self.websocket_session.connection = Some(new_conn);
self.websocket_session.set_connection_reused(false);
self.websocket_session
.set_connection_reused(/*connection_reused*/ false);
} else {
self.websocket_session.set_connection_reused(true);
self.websocket_session
.set_connection_reused(/*connection_reused*/ true);
}
self.websocket_session
@@ -1202,7 +1207,7 @@ impl ModelClientSession {
summary,
service_tier,
turn_metadata_header,
true,
/*warmup*/ true,
)
.await
{
@@ -1255,7 +1260,7 @@ impl ModelClientSession {
summary,
service_tier,
turn_metadata_header,
false,
/*warmup*/ false,
)
.await?
{
@@ -1297,14 +1302,15 @@ impl ModelClientSession {
warn!("falling back to HTTP");
session_telemetry.counter(
"codex.transport.fallback_to_http",
1,
/*inc*/ 1,
&[("from_wire_api", "responses_websocket")],
);
self.websocket_session.connection = None;
self.websocket_session.last_request = None;
self.websocket_session.last_response_rx = None;
self.websocket_session.set_connection_reused(false);
self.websocket_session
.set_connection_reused(/*connection_reused*/ false);
}
activated
}
@@ -1527,7 +1533,7 @@ async fn handle_unauthorized(
debug.cf_ray.as_deref(),
debug.auth_error.as_deref(),
debug.auth_error_code.as_deref(),
None,
/*recovery_reason*/ None,
step_result.auth_state_changed(),
);
emit_feedback_auth_recovery_tags(
@@ -1550,8 +1556,8 @@ async fn handle_unauthorized(
debug.cf_ray.as_deref(),
debug.auth_error.as_deref(),
debug.auth_error_code.as_deref(),
None,
None,
/*recovery_reason*/ None,
/*auth_state_changed*/ None,
);
emit_feedback_auth_recovery_tags(
mode,
@@ -1573,8 +1579,8 @@ async fn handle_unauthorized(
debug.cf_ray.as_deref(),
debug.auth_error.as_deref(),
debug.auth_error_code.as_deref(),
None,
None,
/*recovery_reason*/ None,
/*auth_state_changed*/ None,
);
emit_feedback_auth_recovery_tags(
mode,
@@ -1607,7 +1613,7 @@ async fn handle_unauthorized(
debug.auth_error.as_deref(),
debug.auth_error_code.as_deref(),
recovery_reason,
None,
/*auth_state_changed*/ None,
);
emit_feedback_auth_recovery_tags(
mode,
+30 -18
View File
@@ -630,7 +630,7 @@ impl Codex {
/// Submit the `op` wrapped in a `Submission` with a unique ID.
pub async fn submit(&self, op: Op) -> CodexResult<String> {
self.submit_with_trace(op, None).await
self.submit_with_trace(op, /*trace*/ None).await
}
pub async fn submit_with_trace(
@@ -855,9 +855,11 @@ impl TurnContext {
};
config.model_reasoning_effort = reasoning_effort;
let collaboration_mode =
self.collaboration_mode
.with_updates(Some(model.clone()), Some(reasoning_effort), None);
let collaboration_mode = self.collaboration_mode.with_updates(
Some(model.clone()),
Some(reasoning_effort),
/*developer_instructions*/ None,
);
let features = self.features.clone();
let tools_config = ToolsConfig::new(&ToolsConfigParams {
model_info: &model_info,
@@ -1590,7 +1592,7 @@ impl Session {
config.features.emit_metrics(&session_telemetry);
session_telemetry.counter(
THREAD_STARTED_METRIC,
1,
/*inc*/ 1,
&[(
"is_git",
if get_git_repo_root(&session_configuration.cwd).is_some() {
@@ -1722,7 +1724,8 @@ impl Session {
(None, None)
};
let mut hook_shell_argv = default_shell.derive_exec_args("", false);
let mut hook_shell_argv =
default_shell.derive_exec_args("", /*use_login_shell*/ false);
let hook_shell_program = hook_shell_argv.remove(0);
let _ = hook_shell_argv.pop();
let hooks = Hooks::new(HooksConfig {
@@ -2072,7 +2075,8 @@ impl Session {
InitialHistory::New => {
// Defer initial context insertion until the first real turn starts so
// turn/start overrides can be merged before we write model-visible context.
self.set_previous_turn_settings(None).await;
self.set_previous_turn_settings(/*previous_turn_settings*/ None)
.await;
}
InitialHistory::Resumed(resumed_history) => {
let rollout_items = resumed_history.history;
@@ -2449,7 +2453,7 @@ impl Session {
startup_turn_context.as_ref(),
&[],
&HashSet::new(),
None,
/*skills_outcome*/ None,
&startup_cancellation_token,
)
.await?;
@@ -2535,8 +2539,13 @@ impl Session {
let state = self.state.lock().await;
state.session_configuration.clone()
};
self.new_turn_from_configuration(sub_id, session_configuration, None, false)
.await
self.new_turn_from_configuration(
sub_id,
session_configuration,
/*final_output_json_schema*/ None,
/*sandbox_policy_changed*/ false,
)
.await
}
async fn build_settings_update_items(
@@ -3284,7 +3293,7 @@ impl Session {
pub(crate) async fn record_model_warning(&self, message: impl Into<String>, ctx: &TurnContext) {
self.services
.session_telemetry
.counter("codex.model_warning", 1, &[]);
.counter("codex.model_warning", /*inc*/ 1, &[]);
let item = ResponseItem::Message {
id: None,
role: "user".to_string(),
@@ -4186,7 +4195,7 @@ async fn submission_loop(sess: Arc<Session>, config: Arc<Config>, rx_sub: Receiv
state.session_configuration.collaboration_mode.with_updates(
model.clone(),
effort,
None,
/*developer_instructions*/ None,
)
};
handlers::override_turn_context(
@@ -4536,7 +4545,9 @@ mod handlers {
current_context.session_telemetry.user_prompt(&items);
// Attempt to inject input into current task.
if let Err(SteerInputError::NoActiveTurn(items)) = sess.steer_input(items, None).await {
if let Err(SteerInputError::NoActiveTurn(items)) =
sess.steer_input(items, /*expected_turn_id*/ None).await
{
sess.refresh_mcp_servers_if_requested(&current_context)
.await;
let regular_task = sess.take_startup_regular_task().await.unwrap_or_default();
@@ -5281,7 +5292,7 @@ async fn spawn_review_thread(
sess.services.shell_zsh_path.as_ref(),
sess.services.main_execve_wrapper_exe.as_ref(),
)
.with_web_search_config(None)
.with_web_search_config(/*web_search_config*/ None)
.with_allow_login_shell(config.permissions.allow_login_shell)
.with_agent_roles(config.agent_roles.clone());
@@ -5964,7 +5975,7 @@ pub(crate) async fn run_turn(
}
Err(e) => {
info!("Turn error: {e:#}");
let event = EventMsg::Error(e.to_error_event(None));
let event = EventMsg::Error(e.to_error_event(/*message_prefix*/ None));
sess.send_event(&turn_context, event).await;
// let the user continue the conversation
break;
@@ -7031,7 +7042,8 @@ async fn handle_assistant_item_done_in_plan_mode(
{
maybe_complete_plan_item_from_message(sess, turn_context, state, item).await;
if let Some(turn_item) = handle_non_tool_response_item(sess, turn_context, item, true).await
if let Some(turn_item) =
handle_non_tool_response_item(sess, turn_context, item, /*plan_mode*/ true).await
{
emit_turn_item_in_plan_mode(
sess,
@@ -7044,7 +7056,7 @@ async fn handle_assistant_item_done_in_plan_mode(
}
record_completed_response_item(sess, turn_context, item).await;
if let Some(agent_message) = last_assistant_message_from_item(item, true) {
if let Some(agent_message) = last_assistant_message_from_item(item, /*plan_mode*/ true) {
*last_agent_message = Some(agent_message);
}
return true;
@@ -7415,7 +7427,7 @@ async fn try_run_sampling_request(
pub(super) fn get_last_assistant_message_from_turn(responses: &[ResponseItem]) -> Option<String> {
for item in responses.iter().rev() {
if let Some(message) = last_assistant_message_from_item(item, false) {
if let Some(message) = last_assistant_message_from_item(item, /*plan_mode*/ false) {
return Some(message);
}
}
+3 -3
View File
@@ -481,7 +481,7 @@ async fn handle_exec_approval(
parent_session,
&approval_id_for_op,
cancel_token,
None,
/*review_cancel_token*/ None,
)
.await
};
@@ -587,7 +587,7 @@ async fn handle_patch_approval(
parent_session,
&approval_id,
cancel_token,
None,
/*review_cancel_token*/ None,
)
.await
};
@@ -675,7 +675,7 @@ async fn maybe_auto_review_mcp_request_user_input(
Arc::clone(parent_session),
Arc::clone(parent_ctx),
build_guardian_mcp_tool_review_request(&event.call_id, &invocation, metadata.as_ref()),
None,
/*retry_reason*/ None,
review_cancel.clone(),
);
let decision = await_approval_with_cancel(
+2 -2
View File
@@ -173,7 +173,7 @@ impl CodexThread {
if was_zero {
self.codex
.session
.set_out_of_band_elicitation_pause_state(true);
.set_out_of_band_elicitation_pause_state(/*paused*/ true);
}
Ok(*guard)
@@ -192,7 +192,7 @@ impl CodexThread {
if now_zero {
self.codex
.session
.set_out_of_band_elicitation_pause_state(false);
.set_out_of_band_elicitation_pause_state(/*paused*/ false);
}
Ok(*guard)
+2 -2
View File
@@ -163,7 +163,7 @@ async fn run_compact_task_inner(
continue;
}
sess.set_total_tokens_full(turn_context.as_ref()).await;
let event = EventMsg::Error(e.to_error_event(None));
let event = EventMsg::Error(e.to_error_event(/*message_prefix*/ None));
sess.send_event(&turn_context, event).await;
return Err(e);
}
@@ -180,7 +180,7 @@ async fn run_compact_task_inner(
tokio::time::sleep(delay).await;
continue;
} else {
let event = EventMsg::Error(e.to_error_event(None));
let event = EventMsg::Error(e.to_error_event(/*message_prefix*/ None));
sess.send_event(&turn_context, event).await;
return Err(e);
}
+1 -1
View File
@@ -101,7 +101,7 @@ async fn run_remote_compact_task_inner_impl(
turn_context.as_ref(),
&prompt_input,
&HashSet::new(),
None,
/*skills_outcome*/ None,
&CancellationToken::new(),
)
.await?;
+12 -9
View File
@@ -19,8 +19,10 @@ pub(crate) fn load_agent_roles(
config_layer_stack: &ConfigLayerStack,
startup_warnings: &mut Vec<String>,
) -> std::io::Result<BTreeMap<String, AgentRoleConfig>> {
let layers =
config_layer_stack.get_layers(ConfigLayerStackOrdering::LowestPrecedenceFirst, false);
let layers = config_layer_stack.get_layers(
ConfigLayerStackOrdering::LowestPrecedenceFirst,
/*include_disabled*/ false,
);
if layers.is_empty() {
return load_agent_roles_without_layers(cfg);
}
@@ -450,13 +452,14 @@ fn discover_agent_roles_in_dir(
if declared_role_files.contains(&agent_file) {
continue;
}
let parsed_file = match read_resolved_agent_role_file(&agent_file, None) {
Ok(parsed_file) => parsed_file,
Err(err) => {
push_agent_role_warning(startup_warnings, err);
continue;
}
};
let parsed_file =
match read_resolved_agent_role_file(&agent_file, /*role_name_hint*/ None) {
Ok(parsed_file) => parsed_file,
Err(err) => {
push_agent_role_warning(startup_warnings, err);
continue;
}
};
let role_name = parsed_file.role_name;
if roles.contains_key(&role_name) {
push_agent_role_warning(
+8 -3
View File
@@ -81,11 +81,11 @@ impl ManagedFeatures {
}
pub fn enable(&mut self, feature: Feature) -> ConstraintResult<()> {
self.set_enabled(feature, true)
self.set_enabled(feature, /*enabled*/ true)
}
pub fn disable(&mut self, feature: Feature) -> ConstraintResult<()> {
self.set_enabled(feature, false)
self.set_enabled(feature, /*enabled*/ false)
}
}
@@ -321,7 +321,12 @@ pub(crate) fn validate_feature_requirements_in_config_toml(
})
}
validate_profile(cfg, None, &ConfigProfile::default(), feature_requirements)?;
validate_profile(
cfg,
/*profile_name*/ None,
&ConfigProfile::default(),
feature_requirements,
)?;
for (profile_name, profile) in &cfg.profiles {
validate_profile(cfg, Some(profile_name), profile, feature_requirements)?;
}
+4 -3
View File
@@ -1831,9 +1831,10 @@ fn resolve_permission_config_syntax(
}
let mut selection = None;
for layer in
config_layer_stack.get_layers(ConfigLayerStackOrdering::LowestPrecedenceFirst, false)
{
for layer in config_layer_stack.get_layers(
ConfigLayerStackOrdering::LowestPrecedenceFirst,
/*include_disabled*/ false,
) {
let Ok(layer_selection) = layer.config.clone().try_into::<PermissionSelectionToml>() else {
continue;
};
@@ -77,7 +77,7 @@ impl NetworkProxySpec {
}
pub fn proxy_host_and_port(&self) -> String {
host_and_port_from_network_addr(&self.config.network.proxy_url, 3128)
host_and_port_from_network_addr(&self.config.network.proxy_url, /*default_port*/ 3128)
}
pub fn socks_enabled(&self) -> bool {
+4 -2
View File
@@ -281,9 +281,11 @@ fn parse_special_path(path: &str) -> Option<FileSystemSpecialPath> {
match path {
":root" => Some(FileSystemSpecialPath::Root),
":minimal" => Some(FileSystemSpecialPath::Minimal),
":project_roots" => Some(FileSystemSpecialPath::project_roots(None)),
":project_roots" => Some(FileSystemSpecialPath::project_roots(/*subpath*/ None)),
":tmpdir" => Some(FileSystemSpecialPath::Tmpdir),
_ if path.starts_with(':') => Some(FileSystemSpecialPath::unknown(path, None)),
_ if path.starts_with(':') => {
Some(FileSystemSpecialPath::unknown(path, /*subpath*/ None))
}
_ => None,
}
}
+4 -1
View File
@@ -183,7 +183,10 @@ impl ConfigService {
origins: layers.origins(),
layers: params.include_layers.then(|| {
layers
.get_layers(ConfigLayerStackOrdering::HighestPrecedenceFirst, true)
.get_layers(
ConfigLayerStackOrdering::HighestPrecedenceFirst,
/*include_disabled*/ true,
)
.iter()
.map(|layer| layer.as_layer())
.collect()
+7 -6
View File
@@ -56,12 +56,13 @@ pub(super) async fn load_config_layers_internal(
managed_config_path.unwrap_or_else(|| managed_config_default_path(codex_home)),
)?;
let managed_config = read_config_from_path(&managed_config_path, false)
.await?
.map(|managed_config| MangedConfigFromFile {
managed_config,
file: managed_config_path.clone(),
});
let managed_config =
read_config_from_path(&managed_config_path, /*log_missing_as_info*/ false)
.await?
.map(|managed_config| MangedConfigFromFile {
managed_config,
file: managed_config_path.clone(),
});
#[cfg(target_os = "macos")]
let managed_preferences =
+10 -5
View File
@@ -209,7 +209,7 @@ pub async fn load_config_layers_state(
return Err(io_error_from_config_error(
io::ErrorKind::InvalidData,
config_error,
None,
/*source*/ None,
));
}
return Err(err);
@@ -853,15 +853,20 @@ async fn load_project_layers(
&dot_codex_abs,
&layer_dir,
TomlValue::Table(toml::map::Map::new()),
true,
/*config_toml_exists*/ true,
));
continue;
}
};
let config =
resolve_relative_paths_in_config_toml(config, dot_codex_abs.as_path())?;
let entry =
project_layer_entry(trust_context, &dot_codex_abs, &layer_dir, config, true);
let entry = project_layer_entry(
trust_context,
&dot_codex_abs,
&layer_dir,
config,
/*config_toml_exists*/ true,
);
layers.push(entry);
}
Err(err) => {
@@ -874,7 +879,7 @@ async fn load_project_layers(
&dot_codex_abs,
&layer_dir,
TomlValue::Table(toml::map::Map::new()),
false,
/*config_toml_exists*/ false,
));
} else {
let config_file_display = config_file.as_path().display();
+13 -6
View File
@@ -104,9 +104,11 @@ pub async fn list_accessible_connectors_from_mcp_tools(
config: &Config,
) -> anyhow::Result<Vec<AppInfo>> {
Ok(
list_accessible_connectors_from_mcp_tools_with_options_and_status(config, false)
.await?
.connectors,
list_accessible_connectors_from_mcp_tools_with_options_and_status(
config, /*force_refetch*/ false,
)
.await?
.connectors,
)
}
@@ -186,7 +188,12 @@ pub async fn list_accessible_connectors_from_mcp_tools_with_options_and_status(
});
}
let mcp_servers = with_codex_apps_mcp(HashMap::new(), true, auth.as_ref(), config);
let mcp_servers = with_codex_apps_mcp(
HashMap::new(),
/*connectors_enabled*/ true,
auth.as_ref(),
config,
);
if mcp_servers.is_empty() {
return Ok(AccessibleConnectorsStatus {
connectors: Vec::new(),
@@ -408,7 +415,7 @@ async fn list_directory_connectors_for_tool_suggest_with_auth(
codex_connectors::list_all_connectors_with_options(
cache_key,
is_workspace_account,
false,
/*force_refetch*/ false,
|path| {
let access_token = access_token.clone();
let account_id = account_id.clone();
@@ -459,7 +466,7 @@ async fn chatgpt_get_request_with_token<T: DeserializeOwned>(
fn auth_manager_from_config(config: &Config) -> std::sync::Arc<AuthManager> {
AuthManager::shared(
config.codex_home.clone(),
false,
/*enable_codex_api_key_env*/ false,
config.cli_auth_credentials_store_mode,
)
}
+3 -1
View File
@@ -55,7 +55,9 @@ impl ContextManager {
pub(crate) fn new() -> Self {
Self {
items: Vec::new(),
token_info: TokenUsageInfo::new_or_append(&None, &None, None),
token_info: TokenUsageInfo::new_or_append(
&None, &None, /*model_context_window*/ None,
),
reference_context_item: None,
}
}
+2 -2
View File
@@ -97,7 +97,7 @@ pub fn originator() -> Originator {
}
if std::env::var(CODEX_INTERNAL_ORIGINATOR_OVERRIDE_ENV_VAR).is_ok() {
let originator = get_originator_value(None);
let originator = get_originator_value(/*provided*/ None);
if let Ok(mut guard) = ORIGINATOR.write() {
match guard.as_ref() {
Some(originator) => return originator.clone(),
@@ -107,7 +107,7 @@ pub fn originator() -> Originator {
return originator;
}
get_originator_value(None)
get_originator_value(/*provided*/ None)
}
pub fn is_first_party_originator(originator_value: &str) -> bool {
+10 -3
View File
@@ -82,7 +82,14 @@ impl EnvironmentContext {
} else {
before_network
};
EnvironmentContext::new(cwd, shell.clone(), current_date, timezone, network, None)
EnvironmentContext::new(
cwd,
shell.clone(),
current_date,
timezone,
network,
/*subagents*/ None,
)
}
pub fn from_turn_context(turn_context: &TurnContext, shell: &Shell) -> Self {
@@ -92,7 +99,7 @@ impl EnvironmentContext {
turn_context.current_date.clone(),
turn_context.timezone.clone(),
Self::network_from_turn_context(turn_context),
None,
/*subagents*/ None,
)
}
@@ -103,7 +110,7 @@ impl EnvironmentContext {
turn_context_item.current_date.clone(),
turn_context_item.timezone.clone(),
Self::network_from_turn_context_item(turn_context_item),
None,
/*subagents*/ None,
)
}
+2 -2
View File
@@ -877,12 +877,12 @@ async fn consume_truncated_output(
let stdout_handle = tokio::spawn(read_capped(
BufReader::new(stdout_reader),
stdout_stream.clone(),
false,
/*is_stderr*/ false,
));
let stderr_handle = tokio::spawn(read_capped(
BufReader::new(stderr_reader),
stdout_stream.clone(),
true,
/*is_stderr*/ true,
));
let (exit_status, timed_out) = tokio::select! {
+4 -1
View File
@@ -449,7 +449,10 @@ pub async fn load_exec_policy(config_stack: &ConfigLayerStack) -> Result<Policy,
// from each layer, so that higher-precedence layers can override
// rules defined in lower-precedence ones.
let mut policy_paths = Vec::new();
for layer in config_stack.get_layers(ConfigLayerStackOrdering::LowestPrecedenceFirst, false) {
for layer in config_stack.get_layers(
ConfigLayerStackOrdering::LowestPrecedenceFirst,
/*include_disabled*/ false,
) {
if let Some(config_folder) = layer.config_folder() {
#[expect(clippy::expect_used)]
let policy_dir = config_folder.join(RULES_DIR_NAME).expect("safe join");
+6 -6
View File
@@ -60,7 +60,7 @@ impl ExternalAgentConfigService {
) -> io::Result<Vec<ExternalAgentConfigMigrationItem>> {
let mut items = Vec::new();
if params.include_home {
self.detect_migrations(None, &mut items)?;
self.detect_migrations(/*repo_root*/ None, &mut items)?;
}
for cwd in params.cwds.as_deref().unwrap_or(&[]) {
@@ -81,7 +81,7 @@ impl ExternalAgentConfigService {
emit_migration_metric(
EXTERNAL_AGENT_CONFIG_IMPORT_METRIC,
ExternalAgentConfigMigrationItemType::Config,
None,
/*skills_count*/ None,
);
}
ExternalAgentConfigMigrationItemType::Skills => {
@@ -97,7 +97,7 @@ impl ExternalAgentConfigService {
emit_migration_metric(
EXTERNAL_AGENT_CONFIG_IMPORT_METRIC,
ExternalAgentConfigMigrationItemType::AgentsMd,
None,
/*skills_count*/ None,
);
}
ExternalAgentConfigMigrationItemType::McpServerConfig => {}
@@ -153,7 +153,7 @@ impl ExternalAgentConfigService {
emit_migration_metric(
EXTERNAL_AGENT_CONFIG_DETECT_METRIC,
ExternalAgentConfigMigrationItemType::Config,
None,
/*skills_count*/ None,
);
}
}
@@ -210,7 +210,7 @@ impl ExternalAgentConfigService {
emit_migration_metric(
EXTERNAL_AGENT_CONFIG_DETECT_METRIC,
ExternalAgentConfigMigrationItemType::AgentsMd,
None,
/*skills_count*/ None,
);
}
@@ -684,7 +684,7 @@ fn emit_migration_metric(
.iter()
.map(|(key, value)| (*key, value.as_str()))
.collect::<Vec<_>>();
let _ = metrics.counter(metric_name, 1, &tag_refs);
let _ = metrics.counter(metric_name, /*inc*/ 1, &tag_refs);
}
#[cfg(test)]
+1 -1
View File
@@ -341,7 +341,7 @@ impl Features {
if self.enabled(feature.id) != feature.default_enabled {
otel.counter(
"codex.feature.state",
1,
/*inc*/ 1,
&[
("feature", feature.key),
("value", &self.enabled(feature.id).to_string()),
@@ -198,7 +198,7 @@ pub(crate) fn guardian_approval_request_to_json(
*sandbox_permissions,
additional_permissions.as_ref(),
justification.as_ref(),
None,
/*tty*/ None,
),
GuardianApprovalRequest::ExecCommand {
id: _,
+1 -1
View File
@@ -221,7 +221,7 @@ pub(crate) async fn review_approval_request(
Arc::clone(turn),
request,
retry_reason,
None,
/*external_cancel*/ None,
)
.await
}
+7 -2
View File
@@ -266,7 +266,7 @@ impl GuardianReviewSessionManager {
params.spawn_config.clone(),
next_reuse_key.clone(),
spawn_cancel_token.clone(),
None,
/*initial_history*/ None,
)),
)
.await
@@ -297,7 +297,12 @@ impl GuardianReviewSessionManager {
if trunk.reuse_key != next_reuse_key {
return self
.run_ephemeral_review(params, next_reuse_key, deadline, None)
.run_ephemeral_review(
params,
next_reuse_key,
deadline,
/*initial_history*/ None,
)
.await;
}
+1 -1
View File
@@ -43,7 +43,7 @@ where
network_sandbox_policy,
sandbox_policy_cwd,
use_legacy_landlock,
allow_network_for_proxy(false),
allow_network_for_proxy(/*enforce_managed_network*/ false),
);
let arg0 = Some("codex-linux-sandbox");
spawn_child_async(SpawnChildRequest {
+1 -1
View File
@@ -252,7 +252,7 @@ fn effective_mcp_servers(
pub async fn collect_mcp_snapshot(config: &Config) -> McpListToolsResponseEvent {
let auth_manager = AuthManager::shared(
config.codex_home.clone(),
false,
/*enable_codex_api_key_env*/ false,
config.cli_auth_credentials_store_mode,
);
let auth = auth_manager.auth().await;
+1 -1
View File
@@ -239,7 +239,7 @@ pub(crate) async fn maybe_install_mcp_dependencies(
.await;
let resolved_scopes = resolve_oauth_scopes(
None,
/*explicit_scopes*/ None,
server_config.scopes.clone(),
oauth_config.discovered_scopes.clone(),
);
+3 -1
View File
@@ -1585,7 +1585,9 @@ async fn list_tools_for_client_uncached(
client: &Arc<RmcpClient>,
timeout: Option<Duration>,
) -> Result<Vec<ToolInfo>> {
let resp = client.list_tools_with_connector_ids(None, timeout).await?;
let resp = client
.list_tools_with_connector_ids(/*params*/ None, timeout)
.await?;
let tools = resp
.tools
.into_iter()
+15 -11
View File
@@ -108,13 +108,15 @@ pub(crate) async fn handle_mcp_tool_call(
&call_id,
invocation,
"MCP tool call blocked by app configuration".to_string(),
false,
/*already_started*/ false,
)
.await;
let status = if result.is_ok() { "ok" } else { "error" };
turn_context
.session_telemetry
.counter("codex.mcp.call", 1, &[("status", status)]);
turn_context.session_telemetry.counter(
"codex.mcp.call",
/*inc*/ 1,
&[("status", status)],
);
return CallToolResult::from_result(result);
}
let request_meta = build_mcp_tool_call_request_meta(&server, metadata.as_ref());
@@ -190,7 +192,7 @@ pub(crate) async fn handle_mcp_tool_call(
&call_id,
invocation,
message,
true,
/*already_started*/ true,
)
.await
}
@@ -202,7 +204,7 @@ pub(crate) async fn handle_mcp_tool_call(
&call_id,
invocation,
message,
true,
/*already_started*/ true,
)
.await
}
@@ -213,16 +215,18 @@ pub(crate) async fn handle_mcp_tool_call(
&call_id,
invocation,
message,
true,
/*already_started*/ true,
)
.await
}
};
let status = if result.is_ok() { "ok" } else { "error" };
turn_context
.session_telemetry
.counter("codex.mcp.call", 1, &[("status", status)]);
turn_context.session_telemetry.counter(
"codex.mcp.call",
/*inc*/ 1,
&[("status", status)],
);
return CallToolResult::from_result(result);
}
@@ -263,7 +267,7 @@ pub(crate) async fn handle_mcp_tool_call(
let status = if result.is_ok() { "ok" } else { "error" };
turn_context
.session_telemetry
.counter("codex.mcp.call", 1, &[("status", status)]);
.counter("codex.mcp.call", /*inc*/ 1, &[("status", status)]);
CallToolResult::from_result(result)
}
+2 -2
View File
@@ -97,7 +97,7 @@ pub(in crate::memories) async fn run(session: &Arc<Session>, config: &Config) {
if claimed_candidates.is_empty() {
session.services.session_telemetry.counter(
metrics::MEMORY_PHASE_ONE_JOBS,
1,
/*inc*/ 1,
&[("status", "skipped_no_candidates")],
);
return;
@@ -211,7 +211,7 @@ async fn claim_startup_jobs(
warn!("state db claim_stage1_jobs_for_startup failed during memories startup: {err}");
session.services.session_telemetry.counter(
metrics::MEMORY_PHASE_ONE_JOBS,
1,
/*inc*/ 1,
&[("status", "failed_claim")],
);
None
+5 -5
View File
@@ -61,7 +61,7 @@ pub(super) async fn run(session: &Arc<Session>, config: Arc<Config>) {
Err(e) => {
session.services.session_telemetry.counter(
metrics::MEMORY_PHASE_TWO_JOBS,
1,
/*inc*/ 1,
&[("status", e)],
);
return;
@@ -198,7 +198,7 @@ mod job {
} => {
session_telemetry.counter(
metrics::MEMORY_PHASE_TWO_JOBS,
1,
/*inc*/ 1,
&[("status", "claimed")],
);
(ownership_token, input_watermark)
@@ -218,7 +218,7 @@ mod job {
) {
session.services.session_telemetry.counter(
metrics::MEMORY_PHASE_TWO_JOBS,
1,
/*inc*/ 1,
&[("status", reason)],
);
if matches!(
@@ -250,7 +250,7 @@ mod job {
) {
session.services.session_telemetry.counter(
metrics::MEMORY_PHASE_TWO_JOBS,
1,
/*inc*/ 1,
&[("status", reason)],
);
let _ = db
@@ -462,7 +462,7 @@ fn emit_metrics(session: &Arc<Session>, counters: Counters) {
otel.counter(
metrics::MEMORY_PHASE_TWO_JOBS,
1,
/*inc*/ 1,
&[("status", "agent_spawned")],
);
}
+1 -1
View File
@@ -41,7 +41,7 @@ pub(crate) async fn emit_metric_for_tool_read(invocation: &ToolInvocation, succe
for kind in kinds {
invocation.turn.session_telemetry.counter(
MEMORIES_USAGE_METRIC,
1,
/*inc*/ 1,
&[
("kind", kind.as_tag()),
("tool", invocation.tool_name.as_str()),
+2 -2
View File
@@ -182,7 +182,7 @@ impl ModelsManager {
auth_manager,
model_catalog,
collaboration_modes_config,
ModelProviderInfo::create_openai_provider(/* base_url */ None),
ModelProviderInfo::create_openai_provider(/*base_url*/ None),
)
}
@@ -523,7 +523,7 @@ impl ModelsManager {
Self::new_with_provider(
codex_home,
auth_manager,
None,
/*model_catalog*/ None,
CollaborationModesConfig::default(),
provider,
)
@@ -80,7 +80,7 @@ pub(crate) fn model_info_from_slug(slug: &str) -> ModelInfo {
default_verbosity: None,
apply_patch_tool_type: None,
web_search_tool_type: WebSearchToolType::Text,
truncation_policy: TruncationPolicyConfig::bytes(10_000),
truncation_policy: TruncationPolicyConfig::bytes(/*limit*/ 10_000),
supports_parallel_tool_calls: false,
supports_image_detail_original: false,
context_window: Some(272_000),
+13 -4
View File
@@ -46,7 +46,7 @@ async fn build_config_state_with_mtimes() -> Result<(ConfigState, Vec<LayerMtime
let overrides = LoaderOverrides::default();
let config_layer_stack = load_config_layers_state(
&codex_home,
None,
/*cwd*/ None,
&cli_overrides,
overrides,
CloudRequirementsLoader::default(),
@@ -78,7 +78,10 @@ async fn build_config_state_with_mtimes() -> Result<(ConfigState, Vec<LayerMtime
fn collect_layer_mtimes(stack: &ConfigLayerStack) -> Vec<LayerMtime> {
stack
.get_layers(ConfigLayerStackOrdering::LowestPrecedenceFirst, false)
.get_layers(
ConfigLayerStackOrdering::LowestPrecedenceFirst,
/*include_disabled*/ false,
)
.iter()
.filter_map(|layer| {
let path = match &layer.name {
@@ -113,7 +116,10 @@ fn network_constraints_from_trusted_layers(
layers: &ConfigLayerStack,
) -> Result<NetworkProxyConstraints> {
let mut constraints = NetworkProxyConstraints::default();
for layer in layers.get_layers(ConfigLayerStackOrdering::LowestPrecedenceFirst, false) {
for layer in layers.get_layers(
ConfigLayerStackOrdering::LowestPrecedenceFirst,
/*include_disabled*/ false,
) {
if is_user_controlled_layer(&layer.name) {
continue;
}
@@ -196,7 +202,10 @@ fn config_from_layers(
exec_policy: &codex_execpolicy::Policy,
) -> Result<NetworkProxyConfig> {
let mut config = NetworkProxyConfig::default();
for layer in layers.get_layers(ConfigLayerStackOrdering::LowestPrecedenceFirst, false) {
for layer in layers.get_layers(
ConfigLayerStackOrdering::LowestPrecedenceFirst,
/*include_disabled*/ false,
) {
let parsed = network_tables_from_toml(&layer.config)?;
apply_network_tables(&mut config, parsed)?;
}
+9 -9
View File
@@ -34,7 +34,7 @@ pub async fn maybe_migrate_personality(
}
let config_profile = config_toml
.get_config_profile(None)
.get_config_profile(/*override_profile*/ None)
.map_err(|err| io::Error::new(io::ErrorKind::InvalidData, err))?;
if config_toml.personality.is_some() || config_profile.personality.is_some() {
create_marker(&marker_path).await?;
@@ -70,12 +70,12 @@ async fn has_recorded_sessions(codex_home: &Path, default_provider: &str) -> io:
&& let Some(ids) = state_db::list_thread_ids_db(
Some(state_db_ctx.as_ref()),
codex_home,
1,
None,
/*page_size*/ 1,
/*cursor*/ None,
ThreadSortKey::CreatedAt,
allowed_sources,
None,
false,
/*model_providers*/ None,
/*archived_only*/ false,
"personality_migration",
)
.await
@@ -86,8 +86,8 @@ async fn has_recorded_sessions(codex_home: &Path, default_provider: &str) -> io:
let sessions = get_threads_in_root(
codex_home.join(SESSIONS_SUBDIR),
1,
None,
/*page_size*/ 1,
/*cursor*/ None,
ThreadSortKey::CreatedAt,
ThreadListConfig {
allowed_sources,
@@ -103,8 +103,8 @@ async fn has_recorded_sessions(codex_home: &Path, default_provider: &str) -> io:
let archived_sessions = get_threads_in_root(
codex_home.join(ARCHIVED_SESSIONS_SUBDIR),
1,
None,
/*page_size*/ 1,
/*cursor*/ None,
ThreadSortKey::CreatedAt,
ThreadListConfig {
allowed_sources,
+5 -1
View File
@@ -434,7 +434,11 @@ impl PluginsManager {
}
pub fn plugins_for_config(&self, config: &Config) -> PluginLoadOutcome {
self.plugins_for_layer_stack(&config.cwd, &config.config_layer_stack, false)
self.plugins_for_layer_stack(
&config.cwd,
&config.config_layer_stack,
/*force_reload*/ false,
)
}
pub fn plugins_for_layer_stack(
+4 -4
View File
@@ -190,10 +190,10 @@ pub fn discover_project_doc_paths(config: &Config) -> std::io::Result<Vec<PathBu
}
let mut merged = TomlValue::Table(toml::map::Map::new());
for layer in config
.config_layer_stack
.get_layers(ConfigLayerStackOrdering::LowestPrecedenceFirst, false)
{
for layer in config.config_layer_stack.get_layers(
ConfigLayerStackOrdering::LowestPrecedenceFirst,
/*include_disabled*/ false,
) {
if matches!(layer.name, ConfigLayerSource::Project { .. }) {
continue;
}
+5 -5
View File
@@ -105,12 +105,12 @@ async fn load_recent_threads(sess: &Session) -> Vec<ThreadMetadata> {
match state_db
.list_threads(
MAX_RECENT_THREADS,
None,
/*anchor*/ None,
SortKey::UpdatedAt,
&[],
None,
false,
None,
/*model_providers*/ None,
/*archived_only*/ false,
/*search_term*/ None,
)
.await
{
@@ -235,7 +235,7 @@ fn render_tree(root: &Path) -> Option<Vec<String>> {
}
let mut lines = Vec::new();
collect_tree_lines(root, 0, &mut lines);
collect_tree_lines(root, /*depth*/ 0, &mut lines);
(!lines.is_empty()).then_some(lines)
}
+1 -1
View File
@@ -68,7 +68,7 @@ pub fn render_review_output_text(output: &ReviewOutputEvent) -> String {
sections.push(explanation.to_string());
}
if !output.findings.is_empty() {
let findings = format_review_findings_block(&output.findings, None);
let findings = format_review_findings_block(&output.findings, /*selection*/ None);
let trimmed = findings.trim();
if !trimmed.is_empty() {
sections.push(trimmed.to_string());
+1 -1
View File
@@ -1223,7 +1223,7 @@ async fn find_thread_path_by_id_str_in_subdir(
..Default::default()
};
let results = file_search::run(id_str, vec![root], options, None)
let results = file_search::run(id_str, vec![root], options, /*cancel_flag*/ None)
.map_err(|e| io::Error::other(format!("file search failed: {e}")))?;
let found = results.matches.into_iter().next().map(|m| m.full_path());
+5 -5
View File
@@ -180,7 +180,7 @@ impl RolloutRecorder {
allowed_sources,
model_providers,
default_provider,
false,
/*archived*/ false,
search_term,
)
.await
@@ -206,7 +206,7 @@ impl RolloutRecorder {
allowed_sources,
model_providers,
default_provider,
true,
/*archived*/ true,
search_term,
)
.await
@@ -320,8 +320,8 @@ impl RolloutRecorder {
sort_key,
allowed_sources,
model_providers,
false,
None,
/*archived*/ false,
/*search_term*/ None,
)
.await
else {
@@ -889,7 +889,7 @@ async fn write_and_reconcile_items(
state_builder,
items,
default_provider,
None,
/*new_thread_memory_mode*/ None,
)
.await;
Ok(())
+7 -1
View File
@@ -728,7 +728,13 @@ pub async fn execute_env(
stdout_stream: Option<StdoutStream>,
) -> crate::error::Result<ExecToolCallOutput> {
let effective_policy = exec_request.sandbox_policy.clone();
execute_exec_request(exec_request, &effective_policy, stdout_stream, None).await
execute_exec_request(
exec_request,
&effective_policy,
stdout_stream,
/*after_spawn*/ None,
)
.await
}
pub async fn execute_exec_request_with_after_spawn(
+8 -3
View File
@@ -45,8 +45,13 @@ pub async fn spawn_command_under_seatbelt(
network: Option<&NetworkProxy>,
mut env: HashMap<String, String>,
) -> std::io::Result<Child> {
let args =
create_seatbelt_command_args(command, sandbox_policy, sandbox_policy_cwd, false, network);
let args = create_seatbelt_command_args(
command,
sandbox_policy,
sandbox_policy_cwd,
/*enforce_managed_network*/ false,
network,
);
let arg0 = None;
env.insert(CODEX_SANDBOX_ENV_VAR.to_string(), "seatbelt".to_string());
spawn_child_async(SpawnChildRequest {
@@ -338,7 +343,7 @@ pub(crate) fn create_seatbelt_command_args(
sandbox_policy_cwd,
enforce_managed_network,
network,
None,
/*extensions*/ None,
)
}
+6 -6
View File
@@ -291,20 +291,20 @@ pub fn default_user_shell() -> Shell {
fn default_user_shell_from_path(user_shell_path: Option<PathBuf>) -> Shell {
if cfg!(windows) {
get_shell(ShellType::PowerShell, None).unwrap_or(ultimate_fallback_shell())
get_shell(ShellType::PowerShell, /*path*/ None).unwrap_or(ultimate_fallback_shell())
} else {
let user_default_shell = user_shell_path
.and_then(|shell| detect_shell_type(&shell))
.and_then(|shell_type| get_shell(shell_type, None));
.and_then(|shell_type| get_shell(shell_type, /*path*/ None));
let shell_with_fallback = if cfg!(target_os = "macos") {
user_default_shell
.or_else(|| get_shell(ShellType::Zsh, None))
.or_else(|| get_shell(ShellType::Bash, None))
.or_else(|| get_shell(ShellType::Zsh, /*path*/ None))
.or_else(|| get_shell(ShellType::Bash, /*path*/ None))
} else {
user_default_shell
.or_else(|| get_shell(ShellType::Bash, None))
.or_else(|| get_shell(ShellType::Zsh, None))
.or_else(|| get_shell(ShellType::Bash, /*path*/ None))
.or_else(|| get_shell(ShellType::Zsh, /*path*/ None))
};
shell_with_fallback.unwrap_or(ultimate_fallback_shell())
+19 -6
View File
@@ -102,7 +102,7 @@ impl ShellSnapshot {
if let Some(failure_reason) = snapshot.as_ref().err() {
counter_tags.push(("failure_reason", *failure_reason));
}
session_telemetry.counter("codex.shell_snapshot", 1, &counter_tags);
session_telemetry.counter("codex.shell_snapshot", /*inc*/ 1, &counter_tags);
let _ = shell_snapshot_tx.send(snapshot.ok());
}
.instrument(snapshot_span),
@@ -199,7 +199,7 @@ async fn write_shell_snapshot(
if shell_type == ShellType::PowerShell || shell_type == ShellType::Cmd {
bail!("Shell snapshot not supported yet for {shell_type:?}");
}
let shell = get_shell(shell_type.clone(), None)
let shell = get_shell(shell_type.clone(), /*path*/ None)
.with_context(|| format!("No available shell for {shell_type:?}"))?;
let raw_snapshot = capture_snapshot(&shell, cwd).await?;
@@ -243,13 +243,26 @@ fn strip_snapshot_preamble(snapshot: &str) -> Result<String> {
async fn validate_snapshot(shell: &Shell, snapshot_path: &Path, cwd: &Path) -> Result<()> {
let snapshot_path_display = snapshot_path.display();
let script = format!("set -e; . \"{snapshot_path_display}\"");
run_script_with_timeout(shell, &script, SNAPSHOT_TIMEOUT, false, cwd)
.await
.map(|_| ())
run_script_with_timeout(
shell,
&script,
SNAPSHOT_TIMEOUT,
/*use_login_shell*/ false,
cwd,
)
.await
.map(|_| ())
}
async fn run_shell_script(shell: &Shell, script: &str, cwd: &Path) -> Result<String> {
run_script_with_timeout(shell, script, SNAPSHOT_TIMEOUT, true, cwd).await
run_script_with_timeout(
shell,
script,
SNAPSHOT_TIMEOUT,
/*use_login_shell*/ true,
cwd,
)
.await
}
async fn run_script_with_timeout(
+1 -1
View File
@@ -81,7 +81,7 @@ fn emit_skill_injected_metric(
otel.counter(
"codex.skill.injected",
1,
/*inc*/ 1,
&[("status", status), ("skill", skill.name.as_str())],
);
}
+1 -1
View File
@@ -96,7 +96,7 @@ pub(crate) async fn maybe_emit_implicit_skill_invocation(
turn_context.session_telemetry.counter(
"codex.skill.injected",
1,
/*inc*/ 1,
&[
("status", "ok"),
("skill", skill_name.as_str()),
+8 -6
View File
@@ -247,9 +247,10 @@ fn skill_roots_from_layer_stack_inner(
) -> Vec<SkillRoot> {
let mut roots = Vec::new();
for layer in
config_layer_stack.get_layers(ConfigLayerStackOrdering::HighestPrecedenceFirst, true)
{
for layer in config_layer_stack.get_layers(
ConfigLayerStackOrdering::HighestPrecedenceFirst,
/*include_disabled*/ true,
) {
let Some(config_folder) = layer.config_folder() else {
continue;
};
@@ -321,9 +322,10 @@ fn repo_agents_skill_roots(config_layer_stack: &ConfigLayerStack, cwd: &Path) ->
fn project_root_markers_from_stack(config_layer_stack: &ConfigLayerStack) -> Vec<String> {
let mut merged = TomlValue::Table(toml::map::Map::new());
for layer in
config_layer_stack.get_layers(ConfigLayerStackOrdering::LowestPrecedenceFirst, false)
{
for layer in config_layer_stack.get_layers(
ConfigLayerStackOrdering::LowestPrecedenceFirst,
/*include_disabled*/ false,
) {
if matches!(layer.name, ConfigLayerSource::Project { .. }) {
continue;
}
+4 -3
View File
@@ -250,9 +250,10 @@ fn disabled_paths_from_stack(
config_layer_stack: &crate::config_loader::ConfigLayerStack,
) -> HashSet<PathBuf> {
let mut configs = HashMap::new();
for layer in
config_layer_stack.get_layers(ConfigLayerStackOrdering::LowestPrecedenceFirst, true)
{
for layer in config_layer_stack.get_layers(
ConfigLayerStackOrdering::LowestPrecedenceFirst,
/*include_disabled*/ true,
) {
if !matches!(
layer.name,
ConfigLayerSource::User { .. } | ConfigLayerSource::SessionFlags
+3 -3
View File
@@ -350,7 +350,7 @@ pub async fn reconcile_rollout(
items,
"reconcile_rollout",
new_thread_memory_mode,
None,
/*updated_at_override*/ None,
)
.await;
return;
@@ -472,10 +472,10 @@ pub async fn read_repair_rollout_path(
Some(ctx),
rollout_path,
default_provider.as_str(),
None,
/*builder*/ None,
&[],
archived_only,
None,
/*new_thread_memory_mode*/ None,
)
.await;
}
+2 -2
View File
@@ -32,14 +32,14 @@ impl SessionTask for CompactTask {
let _ = if crate::compact::should_use_remote_compact_task(&ctx.provider) {
let _ = session.services.session_telemetry.counter(
"codex.task.compact",
1,
/*inc*/ 1,
&[("type", "remote")],
);
crate::compact_remote::run_remote_compact_task(session.clone(), ctx).await
} else {
let _ = session.services.session_telemetry.counter(
"codex.task.compact",
1,
/*inc*/ 1,
&[("type", "local")],
);
crate::compact::run_compact_task(session.clone(), ctx, input).await
+5 -1
View File
@@ -68,7 +68,11 @@ fn emit_turn_network_proxy_metric(
} else {
"false"
};
session_telemetry.counter(TURN_NETWORK_PROXY_METRIC, 1, &[("active", active), tmp_mem]);
session_telemetry.counter(
TURN_NETWORK_PROXY_METRIC,
/*inc*/ 1,
&[("active", active), tmp_mem],
);
}
/// Thin wrapper that exposes the parts of [`Session`] task runners need.
+1 -1
View File
@@ -81,7 +81,7 @@ impl SessionTask for RegularTask {
) -> Option<String> {
let sess = session.clone_session();
let run_turn_span = trace_span!("run_turn");
sess.set_server_reasoning_included(false).await;
sess.set_server_reasoning_included(/*included*/ false).await;
let prewarmed_client_session = self.take_prewarmed_session().await;
run_turn(
sess,
+9 -9
View File
@@ -55,11 +55,11 @@ impl SessionTask for ReviewTask {
input: Vec<UserInput>,
cancellation_token: CancellationToken,
) -> Option<String> {
let _ = session
.session
.services
.session_telemetry
.counter("codex.task.review", 1, &[]);
let _ = session.session.services.session_telemetry.counter(
"codex.task.review",
/*inc*/ 1,
&[],
);
// Start sub-codex conversation and get the receiver for events.
let output = match start_review_conversation(
@@ -80,7 +80,7 @@ impl SessionTask for ReviewTask {
}
async fn abort(&self, session: Arc<SessionTaskContext>, ctx: Arc<TurnContext>) {
exit_review_mode(session.clone_session(), None, ctx).await;
exit_review_mode(session.clone_session(), /*review_output*/ None, ctx).await;
}
}
@@ -121,8 +121,8 @@ async fn start_review_conversation(
ctx.clone(),
cancellation_token,
SubAgentSource::Review,
None,
None,
/*final_output_json_schema*/ None,
/*initial_history*/ None,
)
.await)
.ok()
@@ -217,7 +217,7 @@ pub(crate) async fn exit_review_mode(
findings_str.push_str(text);
}
if !out.findings.is_empty() {
let block = format_review_findings_block(&out.findings, None);
let block = format_review_findings_block(&out.findings, /*selection*/ None);
findings_str.push_str(&format!("\n{block}"));
}
let rendered =
+5 -5
View File
@@ -42,11 +42,11 @@ impl SessionTask for UndoTask {
_input: Vec<UserInput>,
cancellation_token: CancellationToken,
) -> Option<String> {
let _ = session
.session
.services
.session_telemetry
.counter("codex.task.undo", 1, &[]);
let _ = session.session.services.session_telemetry.counter(
"codex.task.undo",
/*inc*/ 1,
&[],
);
let sess = session.clone_session();
sess.send_event(
ctx.as_ref(),
+9 -4
View File
@@ -101,7 +101,7 @@ pub(crate) async fn execute_user_shell_command(
session
.services
.session_telemetry
.counter("codex.task.user_shell", 1, &[]);
.counter("codex.task.user_shell", /*inc*/ 1, &[]);
if mode == UserShellCommandMode::StandaloneTurn {
// Auxiliary mode runs within an existing active turn. That turn already
@@ -185,9 +185,14 @@ pub(crate) async fn execute_user_shell_command(
tx_event: session.get_tx_event(),
});
let exec_result = execute_exec_request(exec_env, &sandbox_policy, stdout_stream, None)
.or_cancel(&cancellation_token)
.await;
let exec_result = execute_exec_request(
exec_env,
&sandbox_policy,
stdout_stream,
/*after_spawn*/ None,
)
.or_cancel(&cancellation_token)
.await;
match exec_result {
Err(CancelErr::Cancelled) => {
+50 -10
View File
@@ -108,7 +108,13 @@ impl TerminalInfo {
version: Option<String>,
multiplexer: Option<Multiplexer>,
) -> Self {
Self::new(name, Some(term_program), version, None, multiplexer)
Self::new(
name,
Some(term_program),
version,
/*term*/ None,
multiplexer,
)
}
/// Creates terminal metadata from a `TERM_PROGRAM` match plus a `TERM` value.
@@ -128,7 +134,13 @@ impl TerminalInfo {
version: Option<String>,
multiplexer: Option<Multiplexer>,
) -> Self {
Self::new(name, None, version, None, multiplexer)
Self::new(
name,
/*term_program*/ None,
version,
/*term*/ None,
multiplexer,
)
}
/// Creates terminal metadata from a `TERM` capability value.
@@ -138,12 +150,24 @@ impl TerminalInfo {
} else {
TerminalName::Unknown
};
Self::new(name, None, None, Some(term), multiplexer)
Self::new(
name,
/*term_program*/ None,
/*version*/ None,
Some(term),
multiplexer,
)
}
/// Creates terminal metadata for unknown terminals.
fn unknown(multiplexer: Option<Multiplexer>) -> Self {
Self::new(TerminalName::Unknown, None, None, None, multiplexer)
Self::new(
TerminalName::Unknown,
/*term_program*/ None,
/*version*/ None,
/*term*/ None,
multiplexer,
)
}
/// Formats the terminal info as a User-Agent token.
@@ -279,11 +303,15 @@ fn detect_terminal_info_from_env(env: &dyn Environment) -> TerminalInfo {
}
if env.has("ITERM_SESSION_ID") || env.has("ITERM_PROFILE") || env.has("ITERM_PROFILE_NAME") {
return TerminalInfo::from_name(TerminalName::Iterm2, None, multiplexer);
return TerminalInfo::from_name(TerminalName::Iterm2, /*version*/ None, multiplexer);
}
if env.has("TERM_SESSION_ID") {
return TerminalInfo::from_name(TerminalName::AppleTerminal, None, multiplexer);
return TerminalInfo::from_name(
TerminalName::AppleTerminal,
/*version*/ None,
multiplexer,
);
}
if env.has("KITTY_WINDOW_ID")
@@ -292,7 +320,7 @@ fn detect_terminal_info_from_env(env: &dyn Environment) -> TerminalInfo {
.map(|term| term.contains("kitty"))
.unwrap_or(false)
{
return TerminalInfo::from_name(TerminalName::Kitty, None, multiplexer);
return TerminalInfo::from_name(TerminalName::Kitty, /*version*/ None, multiplexer);
}
if env.has("ALACRITTY_SOCKET")
@@ -301,7 +329,11 @@ fn detect_terminal_info_from_env(env: &dyn Environment) -> TerminalInfo {
.map(|term| term == "alacritty")
.unwrap_or(false)
{
return TerminalInfo::from_name(TerminalName::Alacritty, None, multiplexer);
return TerminalInfo::from_name(
TerminalName::Alacritty,
/*version*/ None,
multiplexer,
);
}
if env.has("KONSOLE_VERSION") {
@@ -310,7 +342,11 @@ fn detect_terminal_info_from_env(env: &dyn Environment) -> TerminalInfo {
}
if env.has("GNOME_TERMINAL_SCREEN") {
return TerminalInfo::from_name(TerminalName::GnomeTerminal, None, multiplexer);
return TerminalInfo::from_name(
TerminalName::GnomeTerminal,
/*version*/ None,
multiplexer,
);
}
if env.has("VTE_VERSION") {
@@ -319,7 +355,11 @@ fn detect_terminal_info_from_env(env: &dyn Environment) -> TerminalInfo {
}
if env.has("WT_SESSION") {
return TerminalInfo::from_name(TerminalName::WindowsTerminal, None, multiplexer);
return TerminalInfo::from_name(
TerminalName::WindowsTerminal,
/*version*/ None,
multiplexer,
);
}
if let Some(term) = env.var_non_empty("TERM") {
+25 -20
View File
@@ -173,7 +173,7 @@ impl ThreadManager {
.model_providers
.get(OPENAI_PROVIDER_ID)
.cloned()
.unwrap_or_else(|| ModelProviderInfo::create_openai_provider(/* base_url */ None));
.unwrap_or_else(|| ModelProviderInfo::create_openai_provider(/*base_url*/ None));
let (thread_created_tx, _) = broadcast::channel(THREAD_CREATED_CHANNEL_CAPACITY);
let plugins_manager = Arc::new(PluginsManager::new(codex_home.clone()));
let mcp_manager = Arc::new(McpManager::new(Arc::clone(&plugins_manager)));
@@ -213,7 +213,7 @@ impl ThreadManager {
auth: CodexAuth,
provider: ModelProviderInfo,
) -> Self {
set_thread_manager_test_mode_for_tests(true);
set_thread_manager_test_mode_for_tests(/*enabled*/ true);
let codex_home = std::env::temp_dir().join(format!(
"codex-thread-manager-test-{}",
uuid::Uuid::new_v4()
@@ -233,7 +233,7 @@ impl ThreadManager {
provider: ModelProviderInfo,
codex_home: PathBuf,
) -> Self {
set_thread_manager_test_mode_for_tests(true);
set_thread_manager_test_mode_for_tests(/*enabled*/ true);
let auth_manager = AuthManager::from_auth_for_testing(auth);
let (thread_created_tx, _) = broadcast::channel(THREAD_CREATED_CHANNEL_CAPACITY);
let plugins_manager = Arc::new(PluginsManager::new(codex_home.clone()));
@@ -241,7 +241,7 @@ impl ThreadManager {
let skills_manager = Arc::new(SkillsManager::new(
codex_home.clone(),
Arc::clone(&plugins_manager),
true,
/*bundled_skills_enabled*/ true,
));
let file_watcher = build_file_watcher(codex_home.clone(), Arc::clone(&skills_manager));
Self {
@@ -340,7 +340,12 @@ impl ThreadManager {
pub async fn start_thread(&self, config: Config) -> CodexResult<NewThread> {
// Box delegated thread-spawn futures so these convenience wrappers do
// not inline the full spawn path into every caller's async state.
Box::pin(self.start_thread_with_tools(config, Vec::new(), false)).await
Box::pin(self.start_thread_with_tools(
config,
Vec::new(),
/*persist_extended_history*/ false,
))
.await
}
pub async fn start_thread_with_tools(
@@ -353,8 +358,8 @@ impl ThreadManager {
config,
dynamic_tools,
persist_extended_history,
None,
None,
/*metrics_service_name*/ None,
/*parent_trace*/ None,
))
.await
}
@@ -392,7 +397,7 @@ impl ThreadManager {
config,
initial_history,
auth_manager,
false,
/*persist_extended_history*/ false,
parent_trace,
))
.await
@@ -413,7 +418,7 @@ impl ThreadManager {
self.agent_control(),
Vec::new(),
persist_extended_history,
None,
/*metrics_service_name*/ None,
parent_trace,
))
.await
@@ -498,7 +503,7 @@ impl ThreadManager {
self.agent_control(),
Vec::new(),
persist_extended_history,
None,
/*metrics_service_name*/ None,
parent_trace,
))
.await
@@ -558,9 +563,9 @@ impl ThreadManagerState {
config,
agent_control,
self.session_source.clone(),
false,
None,
None,
/*persist_extended_history*/ false,
/*metrics_service_name*/ None,
/*inherited_shell_snapshot*/ None,
))
.await
}
@@ -584,7 +589,7 @@ impl ThreadManagerState {
persist_extended_history,
metrics_service_name,
inherited_shell_snapshot,
None,
/*parent_trace*/ None,
))
.await
}
@@ -605,10 +610,10 @@ impl ThreadManagerState {
agent_control,
session_source,
Vec::new(),
false,
None,
/*persist_extended_history*/ false,
/*metrics_service_name*/ None,
inherited_shell_snapshot,
None,
/*parent_trace*/ None,
))
.await
}
@@ -630,9 +635,9 @@ impl ThreadManagerState {
session_source,
Vec::new(),
persist_extended_history,
None,
/*metrics_service_name*/ None,
inherited_shell_snapshot,
None,
/*parent_trace*/ None,
))
.await
}
@@ -659,7 +664,7 @@ impl ThreadManagerState {
dynamic_tools,
persist_extended_history,
metrics_service_name,
None,
/*inherited_shell_snapshot*/ None,
parent_trace,
))
.await
@@ -84,7 +84,10 @@ impl CodeModeExecuteHandler {
Ok(message) => message,
Err(error) => return Err(FunctionCallError::RespondToModel(error)),
};
handle_node_message(&exec, cell_id, message, None, started_at).await
handle_node_message(
&exec, cell_id, message, /*poll_max_output_tokens*/ None, started_at,
)
.await
};
match result {
Ok(CodeModeSessionProgress::Finished(output))
+1 -1
View File
@@ -230,7 +230,7 @@ async fn build_enabled_tools(exec: &ExecContext) -> Vec<protocol::EnabledTool> {
let mut out = router
.specs()
.into_iter()
.map(|spec| augment_tool_spec_for_code_mode(spec, true))
.map(|spec| augment_tool_spec_for_code_mode(spec, /*code_mode_enabled*/ true))
.filter_map(enabled_tool_from_spec)
.collect::<Vec<_>>();
out.sort_by(|left, right| left.tool_name.cmp(&right.tool_name));
+1 -1
View File
@@ -230,7 +230,7 @@ impl ToolOutput for AbortedToolOutput {
vec![FunctionCallOutputContentItem::InputText {
text: self.message.clone(),
}],
None,
/*success*/ None,
),
}
}
+11 -4
View File
@@ -162,7 +162,14 @@ impl ToolEmitter {
) => {
emit_exec_stage(
ctx,
ExecCommandInput::new(command, cwd.as_path(), parsed_cmd, *source, None, None),
ExecCommandInput::new(
command,
cwd.as_path(),
parsed_cmd,
*source,
/*interaction_input*/ None,
/*process_id*/ None,
),
stage,
)
.await;
@@ -233,7 +240,7 @@ impl ToolEmitter {
changes.clone(),
String::new(),
(*message).to_string(),
false,
/*success*/ false,
PatchApplyStatus::Failed,
)
.await;
@@ -247,7 +254,7 @@ impl ToolEmitter {
changes.clone(),
String::new(),
(*message).to_string(),
false,
/*success*/ false,
PatchApplyStatus::Declined,
)
.await;
@@ -269,7 +276,7 @@ impl ToolEmitter {
cwd.as_path(),
parsed_cmd,
*source,
None,
/*interaction_input*/ None,
process_id.as_deref(),
),
stage,
+37 -7
View File
@@ -584,7 +584,13 @@ async fn run_agent_job_loop(
.await?;
let initial_progress = db.get_agent_job_progress(job_id.as_str()).await?;
progress_emitter
.maybe_emit(&session, &turn, job_id.as_str(), &initial_progress, true)
.maybe_emit(
&session,
&turn,
job_id.as_str(),
&initial_progress,
/*force*/ true,
)
.await?;
let mut cancel_requested = db.is_agent_job_cancelled(job_id.as_str()).await?;
@@ -633,7 +639,7 @@ async fn run_agent_job_loop(
db.mark_agent_job_item_pending(
job_id.as_str(),
item.item_id.as_str(),
None,
/*error_message*/ None,
)
.await?;
break;
@@ -719,7 +725,13 @@ async fn run_agent_job_loop(
active_items.remove(&thread_id);
let progress = db.get_agent_job_progress(job_id.as_str()).await?;
progress_emitter
.maybe_emit(&session, &turn, job_id.as_str(), &progress, false)
.maybe_emit(
&session,
&turn,
job_id.as_str(),
&progress,
/*force*/ false,
)
.await?;
}
}
@@ -738,7 +750,13 @@ async fn run_agent_job_loop(
format!("agent job {job_id} cancelled with {pending_items} unprocessed items");
let _ = session.notify_background_event(&turn, message).await;
progress_emitter
.maybe_emit(&session, &turn, job_id.as_str(), &progress, true)
.maybe_emit(
&session,
&turn,
job_id.as_str(),
&progress,
/*force*/ true,
)
.await?;
return Ok(());
}
@@ -750,7 +768,13 @@ async fn run_agent_job_loop(
db.mark_agent_job_completed(job_id.as_str()).await?;
let progress = db.get_agent_job_progress(job_id.as_str()).await?;
progress_emitter
.maybe_emit(&session, &turn, job_id.as_str(), &progress, true)
.maybe_emit(
&session,
&turn,
job_id.as_str(),
&progress,
/*force*/ true,
)
.await?;
Ok(())
}
@@ -759,7 +783,9 @@ async fn export_job_csv_snapshot(
db: Arc<codex_state::StateRuntime>,
job: &codex_state::AgentJob,
) -> anyhow::Result<()> {
let items = db.list_agent_job_items(job.id.as_str(), None, None).await?;
let items = db
.list_agent_job_items(job.id.as_str(), /*status*/ None, /*limit*/ None)
.await?;
let csv_content = render_job_csv(job.input_headers.as_slice(), items.as_slice())
.map_err(|err| anyhow::anyhow!("failed to render job csv for auto-export: {err}"))?;
let output_path = PathBuf::from(job.output_csv_path.clone());
@@ -778,7 +804,11 @@ async fn recover_running_items(
runtime_timeout: Duration,
) -> anyhow::Result<()> {
let running_items = db
.list_agent_job_items(job_id, Some(codex_state::AgentJobItemStatus::Running), None)
.list_agent_job_items(
job_id,
Some(codex_state::AgentJobItemStatus::Running),
/*limit*/ None,
)
.await?;
for item in running_items {
if is_item_stale(&item, runtime_timeout) {
@@ -225,9 +225,9 @@ async fn emit_exec_begin(session: &Session, turn: &TurnContext, call_id: &str) {
vec![ARTIFACTS_TOOL_NAME.to_string()],
turn.cwd.clone(),
ExecCommandSource::Agent,
true,
/*freeform*/ true,
);
let ctx = ToolEventCtx::new(session, turn, call_id, None);
let ctx = ToolEventCtx::new(session, turn, call_id, /*turn_diff_tracker*/ None);
emitter.emit(ctx, ToolEventStage::Begin).await;
}
@@ -251,9 +251,9 @@ async fn emit_exec_end(
vec![ARTIFACTS_TOOL_NAME.to_string()],
turn.cwd.clone(),
ExecCommandSource::Agent,
true,
/*freeform*/ true,
);
let ctx = ToolEventCtx::new(session, turn, call_id, None);
let ctx = ToolEventCtx::new(session, turn, call_id, /*turn_diff_tracker*/ None);
let stage = if success {
ToolEventStage::Success(exec_output)
} else {
+5 -5
View File
@@ -63,9 +63,9 @@ async fn emit_js_repl_exec_begin(
vec!["js_repl".to_string()],
turn.cwd.clone(),
ExecCommandSource::Agent,
false,
/*freeform*/ false,
);
let ctx = ToolEventCtx::new(session, turn, call_id, None);
let ctx = ToolEventCtx::new(session, turn, call_id, /*turn_diff_tracker*/ None);
emitter.emit(ctx, ToolEventStage::Begin).await;
}
@@ -82,9 +82,9 @@ async fn emit_js_repl_exec_end(
vec!["js_repl".to_string()],
turn.cwd.clone(),
ExecCommandSource::Agent,
false,
/*freeform*/ false,
);
let ctx = ToolEventCtx::new(session, turn, call_id, None);
let ctx = ToolEventCtx::new(session, turn, call_id, /*turn_diff_tracker*/ None);
let stage = if error.is_some() {
ToolEventStage::Failure(ToolEventFailure::Output(exec_output))
} else {
@@ -169,7 +169,7 @@ impl ToolHandler for JsReplHandler {
turn.as_ref(),
&call_id,
&content,
None,
/*error*/ None,
started_at.elapsed(),
)
.await;
@@ -103,7 +103,7 @@ impl ToolHandler for Handler {
return Err(err);
}
turn.session_telemetry
.counter("codex.multi_agent.resume", 1, &[]);
.counter("codex.multi_agent.resume", /*inc*/ 1, &[]);
Ok(ResumeAgentResult { status })
}
@@ -150,7 +150,11 @@ async fn try_resume_closed_agent(
.resume_agent_from_rollout(
config,
receiver_thread_id,
thread_spawn_source(session.conversation_id, child_depth, None),
thread_spawn_source(
session.conversation_id,
child_depth,
/*agent_role*/ None,
),
)
.await
.map_err(|err| collab_agent_error(receiver_thread_id, err))?;
@@ -127,8 +127,11 @@ impl ToolHandler for Handler {
.await;
let new_thread_id = result?;
let role_tag = role_name.unwrap_or(DEFAULT_ROLE_NAME);
turn.session_telemetry
.counter("codex.multi_agent.spawn", 1, &[("role", role_tag)]);
turn.session_telemetry.counter(
"codex.multi_agent.spawn",
/*inc*/ 1,
&[("role", role_tag)],
);
Ok(SpawnAgentResult {
agent_id: new_thread_id.to_string(),
@@ -197,7 +197,7 @@ impl ToolOutput for WaitAgentResult {
}
fn to_response_item(&self, call_id: &str, payload: &ToolPayload) -> ResponseInputItem {
tool_output_response_item(call_id, payload, self, None, "wait_agent")
tool_output_response_item(call_id, payload, self, /*success*/ None, "wait_agent")
}
fn code_mode_result(&self, _payload: &ToolPayload) -> JsonValue {
+12 -2
View File
@@ -417,7 +417,12 @@ impl ShellHandler {
source,
freeform,
);
let event_ctx = ToolEventCtx::new(session.as_ref(), turn.as_ref(), &call_id, None);
let event_ctx = ToolEventCtx::new(
session.as_ref(),
turn.as_ref(),
&call_id,
/*turn_diff_tracker*/ None,
);
emitter.begin(event_ctx).await;
let exec_approval_requirement = session
@@ -478,7 +483,12 @@ impl ShellHandler {
)
.await
.map(|result| result.output);
let event_ctx = ToolEventCtx::new(session.as_ref(), turn.as_ref(), &call_id, None);
let event_ctx = ToolEventCtx::new(
session.as_ref(),
turn.as_ref(),
&call_id,
/*turn_diff_tracker*/ None,
);
let content = emitter.finish(event_ctx, out).await?;
Ok(FunctionToolOutput::from_text(content, Some(true)))
}
+13 -17
View File
@@ -115,23 +115,19 @@ impl ToolHandler for ViewImageHandler {
};
let image_detail = use_original_detail.then_some(ImageDetail::Original);
let content = local_image_content_items_with_label_number(&abs_path, None, image_mode)
.into_iter()
.map(|item| match item {
ContentItem::InputText { text } => {
FunctionCallOutputContentItem::InputText { text }
}
ContentItem::InputImage { image_url } => {
FunctionCallOutputContentItem::InputImage {
image_url,
detail: image_detail,
}
}
ContentItem::OutputText { text } => {
FunctionCallOutputContentItem::InputText { text }
}
})
.collect();
let content = local_image_content_items_with_label_number(
&abs_path, /*label_number*/ None, image_mode,
)
.into_iter()
.map(|item| match item {
ContentItem::InputText { text } => FunctionCallOutputContentItem::InputText { text },
ContentItem::InputImage { image_url } => FunctionCallOutputContentItem::InputImage {
image_url,
detail: image_detail,
},
ContentItem::OutputText { text } => FunctionCallOutputContentItem::InputText { text },
})
.collect();
session
.send_event(
+34 -6
View File
@@ -792,7 +792,11 @@ impl JsReplManager {
}
fn summarize_tool_call_error(error: &str) -> JsReplToolCallResponseSummary {
Self::summarize_text_payload(None, JsReplToolCallPayloadKind::Error, error)
Self::summarize_text_payload(
/*response_type*/ None,
JsReplToolCallPayloadKind::Error,
error,
)
}
pub async fn reset(&self) -> Result<(), FunctionCallError> {
@@ -962,7 +966,7 @@ impl JsReplManager {
with_model_kernel_failure_message(
"js_repl kernel closed unexpectedly",
"response_channel_closed",
None,
/*stream_error*/ None,
&snapshot,
)
} else {
@@ -1531,7 +1535,13 @@ impl JsReplManager {
if is_js_repl_internal_tool(&req.tool_name) {
let error = "js_repl cannot invoke itself".to_string();
let summary = Self::summarize_tool_call_error(&error);
Self::log_tool_call_response(&req, false, &summary, None, Some(&error));
Self::log_tool_call_response(
&req,
/*ok*/ false,
&summary,
/*response*/ None,
Some(&error),
);
return RunToolResult {
id: req.id,
ok: false,
@@ -1610,7 +1620,13 @@ impl JsReplManager {
let summary = Self::summarize_tool_call_response(&response);
match serde_json::to_value(response) {
Ok(value) => {
Self::log_tool_call_response(&req, true, &summary, Some(&value), None);
Self::log_tool_call_response(
&req,
/*ok*/ true,
&summary,
Some(&value),
/*error*/ None,
);
RunToolResult {
id: req.id,
ok: true,
@@ -1621,7 +1637,13 @@ impl JsReplManager {
Err(err) => {
let error = format!("failed to serialize tool output: {err}");
let summary = Self::summarize_tool_call_error(&error);
Self::log_tool_call_response(&req, false, &summary, None, Some(&error));
Self::log_tool_call_response(
&req,
/*ok*/ false,
&summary,
/*response*/ None,
Some(&error),
);
RunToolResult {
id: req.id,
ok: false,
@@ -1634,7 +1656,13 @@ impl JsReplManager {
Err(err) => {
let error = err.to_string();
let summary = Self::summarize_tool_call_error(&error);
Self::log_tool_call_response(&req, false, &summary, None, Some(&error));
Self::log_tool_call_response(
&req,
/*ok*/ false,
&summary,
/*response*/ None,
Some(&error),
);
RunToolResult {
id: req.id,
ok: false,
+4 -4
View File
@@ -377,14 +377,14 @@ impl NetworkApprovalService {
.request_command_approval(
turn_context.as_ref(),
approval_id,
None,
/*approval_id*/ None,
prompt_command,
turn_context.cwd.clone(),
Some(prompt_reason),
Some(network_approval_context.clone()),
None,
None,
None,
/*proposed_execpolicy_amendment*/ None,
/*additional_permissions*/ None,
/*skill_metadata*/ None,
available_decisions,
)
.await
+3 -3
View File
@@ -217,7 +217,7 @@ impl ToolRegistry {
&call_id_owned,
log_payload.as_ref(),
Duration::ZERO,
false,
/*success*/ false,
&message,
&metric_tags,
mcp_server_ref,
@@ -234,7 +234,7 @@ impl ToolRegistry {
&call_id_owned,
log_payload.as_ref(),
Duration::ZERO,
false,
/*success*/ false,
&message,
&metric_tags,
mcp_server_ref,
@@ -341,7 +341,7 @@ impl ToolRegistryBuilder {
}
pub fn push_spec(&mut self, spec: ToolSpec) {
self.push_spec_with_parallel_support(spec, false);
self.push_spec_with_parallel_support(spec, /*supports_parallel_tool_calls*/ false);
}
pub fn push_spec_with_parallel_support(
@@ -147,7 +147,13 @@ impl Approvable<ApplyPatchRequest> for ApplyPatchRuntime {
}
if let Some(reason) = retry_reason {
let rx_approve = session
.request_patch_approval(turn, call_id, changes.clone(), Some(reason), None)
.request_patch_approval(
turn,
call_id,
changes.clone(),
Some(reason),
/*grant_root*/ None,
)
.await;
return rx_approve.await.unwrap_or_default();
}
@@ -158,7 +164,9 @@ impl Approvable<ApplyPatchRequest> for ApplyPatchRuntime {
approval_keys,
|| async move {
let rx_approve = session
.request_patch_approval(turn, call_id, changes, None, None)
.request_patch_approval(
turn, call_id, changes, /*reason*/ None, /*grant_root*/ None,
)
.await;
rx_approve.await.unwrap_or_default()
},
@@ -198,7 +206,7 @@ impl ToolRuntime<ApplyPatchRequest, ExecToolCallOutput> for ApplyPatchRuntime {
) -> Result<ExecToolCallOutput, ToolError> {
let spec = Self::build_command_spec(req, &ctx.turn.config.codex_home)?;
let env = attempt
.env_for(spec, None)
.env_for(spec, /*network*/ None)
.map_err(|err| ToolError::Codex(err.into()))?;
let out = execute_env(env, Self::stdout_stream(ctx))
.await
+2 -2
View File
@@ -174,7 +174,7 @@ impl Approvable<ShellRequest> for ShellRuntime {
.request_command_approval(
turn,
call_id,
None,
/*approval_id*/ None,
command,
cwd,
reason,
@@ -183,7 +183,7 @@ impl Approvable<ShellRequest> for ShellRuntime {
.proposed_execpolicy_amendment()
.cloned(),
req.additional_permissions.clone(),
None,
/*skill_metadata*/ None,
available_decisions,
)
.await
@@ -435,7 +435,7 @@ impl CoreShellActionProvider {
cwd: workdir,
additional_permissions,
},
None,
/*retry_reason*/ None,
)
.await;
}
@@ -468,9 +468,9 @@ impl CoreShellActionProvider {
approval_id,
command,
workdir,
None,
None,
None,
/*reason*/ None,
/*network_approval_context*/ None,
/*proposed_execpolicy_amendment*/ None,
additional_permissions,
skill_metadata,
Some(available_decisions),
@@ -913,7 +913,7 @@ impl ShellCommandExecutor for CoreShellCommandExecutor {
justification: self.justification.clone(),
arg0: self.arg0.clone(),
},
None,
/*stdout_stream*/ None,
after_spawn,
)
.await?;
@@ -143,7 +143,7 @@ impl Approvable<UnifiedExecRequest> for UnifiedExecRuntime<'_> {
.request_command_approval(
turn,
call_id,
None,
/*approval_id*/ None,
command,
cwd,
reason,
@@ -152,7 +152,7 @@ impl Approvable<UnifiedExecRequest> for UnifiedExecRuntime<'_> {
.proposed_execpolicy_amendment()
.cloned(),
req.additional_permissions.clone(),
None,
/*skill_metadata*/ None,
available_decisions,
)
.await
+1 -1
View File
@@ -94,7 +94,7 @@ where
services.session_telemetry.counter(
"codex.approval.requested",
1,
/*inc*/ 1,
&[
("tool", tool_name),
("approved", decision.to_opaque_string()),
+44 -39
View File
@@ -2258,7 +2258,7 @@ fn push_tool_spec(
) {
let spec = augment_tool_spec_for_code_mode(spec, code_mode_enabled);
if supports_parallel_tool_calls {
builder.push_spec_with_parallel_support(spec, true);
builder.push_spec_with_parallel_support(spec, /*supports_parallel_tool_calls*/ true);
} else {
builder.push_spec(spec);
}
@@ -2566,14 +2566,16 @@ pub(crate) fn build_specs_with_discoverable_tools(
&nested_config,
mcp_tools.clone(),
app_tools.clone(),
None,
/*discoverable_tools*/ None,
dynamic_tools,
)
.build();
let mut enabled_tools = nested_specs
.into_iter()
.filter_map(|spec| {
let (name, description) = match augment_tool_spec_for_code_mode(spec.spec, true) {
let (name, description) = match augment_tool_spec_for_code_mode(
spec.spec, /*code_mode_enabled*/ true,
) {
ToolSpec::Function(tool) => (tool.name, tool.description),
ToolSpec::Freeform(tool) => (tool.name, tool.description),
_ => return None,
@@ -2586,14 +2588,14 @@ pub(crate) fn build_specs_with_discoverable_tools(
push_tool_spec(
&mut builder,
create_code_mode_tool(&enabled_tools, config.code_mode_only_enabled),
false,
/*supports_parallel_tool_calls*/ false,
config.code_mode_enabled,
);
builder.register_handler(PUBLIC_TOOL_NAME, code_mode_handler);
push_tool_spec(
&mut builder,
create_exec_wait_tool(),
false,
/*supports_parallel_tool_calls*/ false,
config.code_mode_enabled,
);
builder.register_handler(WAIT_TOOL_NAME, code_mode_wait_handler);
@@ -2604,7 +2606,7 @@ pub(crate) fn build_specs_with_discoverable_tools(
push_tool_spec(
&mut builder,
create_shell_tool(exec_permission_approvals_enabled),
true,
/*supports_parallel_tool_calls*/ true,
config.code_mode_enabled,
);
}
@@ -2612,7 +2614,7 @@ pub(crate) fn build_specs_with_discoverable_tools(
push_tool_spec(
&mut builder,
ToolSpec::LocalShell {},
true,
/*supports_parallel_tool_calls*/ true,
config.code_mode_enabled,
);
}
@@ -2623,13 +2625,13 @@ pub(crate) fn build_specs_with_discoverable_tools(
config.allow_login_shell,
exec_permission_approvals_enabled,
),
true,
/*supports_parallel_tool_calls*/ true,
config.code_mode_enabled,
);
push_tool_spec(
&mut builder,
create_write_stdin_tool(),
false,
/*supports_parallel_tool_calls*/ false,
config.code_mode_enabled,
);
builder.register_handler("exec_command", unified_exec_handler.clone());
@@ -2645,7 +2647,7 @@ pub(crate) fn build_specs_with_discoverable_tools(
config.allow_login_shell,
exec_permission_approvals_enabled,
),
true,
/*supports_parallel_tool_calls*/ true,
config.code_mode_enabled,
);
}
@@ -2663,19 +2665,19 @@ pub(crate) fn build_specs_with_discoverable_tools(
push_tool_spec(
&mut builder,
create_list_mcp_resources_tool(),
true,
/*supports_parallel_tool_calls*/ true,
config.code_mode_enabled,
);
push_tool_spec(
&mut builder,
create_list_mcp_resource_templates_tool(),
true,
/*supports_parallel_tool_calls*/ true,
config.code_mode_enabled,
);
push_tool_spec(
&mut builder,
create_read_mcp_resource_tool(),
true,
/*supports_parallel_tool_calls*/ true,
config.code_mode_enabled,
);
builder.register_handler("list_mcp_resources", mcp_resource_handler.clone());
@@ -2686,7 +2688,7 @@ pub(crate) fn build_specs_with_discoverable_tools(
push_tool_spec(
&mut builder,
PLAN_TOOL.clone(),
false,
/*supports_parallel_tool_calls*/ false,
config.code_mode_enabled,
);
builder.register_handler("update_plan", plan_handler);
@@ -2695,13 +2697,13 @@ pub(crate) fn build_specs_with_discoverable_tools(
push_tool_spec(
&mut builder,
create_js_repl_tool(),
false,
/*supports_parallel_tool_calls*/ false,
config.code_mode_enabled,
);
push_tool_spec(
&mut builder,
create_js_repl_reset_tool(),
false,
/*supports_parallel_tool_calls*/ false,
config.code_mode_enabled,
);
builder.register_handler("js_repl", js_repl_handler);
@@ -2714,7 +2716,7 @@ pub(crate) fn build_specs_with_discoverable_tools(
create_request_user_input_tool(CollaborationModesConfig {
default_mode_request_user_input: config.default_mode_request_user_input,
}),
false,
/*supports_parallel_tool_calls*/ false,
config.code_mode_enabled,
);
builder.register_handler("request_user_input", request_user_input_handler);
@@ -2724,7 +2726,7 @@ pub(crate) fn build_specs_with_discoverable_tools(
push_tool_spec(
&mut builder,
create_request_permissions_tool(),
false,
/*supports_parallel_tool_calls*/ false,
config.code_mode_enabled,
);
builder.register_handler("request_permissions", request_permissions_handler);
@@ -2737,7 +2739,7 @@ pub(crate) fn build_specs_with_discoverable_tools(
push_tool_spec(
&mut builder,
create_tool_search_tool(&app_tools),
true,
/*supports_parallel_tool_calls*/ true,
config.code_mode_enabled,
);
builder.register_handler(TOOL_SEARCH_TOOL_NAME, search_tool_handler);
@@ -2755,7 +2757,10 @@ pub(crate) fn build_specs_with_discoverable_tools(
.as_ref()
.filter(|tools| !tools.is_empty())
{
builder.push_spec_with_parallel_support(create_tool_suggest_tool(discoverable_tools), true);
builder.push_spec_with_parallel_support(
create_tool_suggest_tool(discoverable_tools),
/*supports_parallel_tool_calls*/ true,
);
builder.register_handler(TOOL_SUGGEST_TOOL_NAME, tool_suggest_handler);
}
@@ -2765,7 +2770,7 @@ pub(crate) fn build_specs_with_discoverable_tools(
push_tool_spec(
&mut builder,
create_apply_patch_freeform_tool(),
false,
/*supports_parallel_tool_calls*/ false,
config.code_mode_enabled,
);
}
@@ -2773,7 +2778,7 @@ pub(crate) fn build_specs_with_discoverable_tools(
push_tool_spec(
&mut builder,
create_apply_patch_json_tool(),
false,
/*supports_parallel_tool_calls*/ false,
config.code_mode_enabled,
);
}
@@ -2789,7 +2794,7 @@ pub(crate) fn build_specs_with_discoverable_tools(
push_tool_spec(
&mut builder,
create_grep_files_tool(),
true,
/*supports_parallel_tool_calls*/ true,
config.code_mode_enabled,
);
builder.register_handler("grep_files", grep_files_handler);
@@ -2803,7 +2808,7 @@ pub(crate) fn build_specs_with_discoverable_tools(
push_tool_spec(
&mut builder,
create_read_file_tool(),
true,
/*supports_parallel_tool_calls*/ true,
config.code_mode_enabled,
);
builder.register_handler("read_file", read_file_handler);
@@ -2818,7 +2823,7 @@ pub(crate) fn build_specs_with_discoverable_tools(
push_tool_spec(
&mut builder,
create_list_dir_tool(),
true,
/*supports_parallel_tool_calls*/ true,
config.code_mode_enabled,
);
builder.register_handler("list_dir", list_dir_handler);
@@ -2832,7 +2837,7 @@ pub(crate) fn build_specs_with_discoverable_tools(
push_tool_spec(
&mut builder,
create_test_sync_tool(),
true,
/*supports_parallel_tool_calls*/ true,
config.code_mode_enabled,
);
builder.register_handler("test_sync_tool", test_sync_handler);
@@ -2873,7 +2878,7 @@ pub(crate) fn build_specs_with_discoverable_tools(
.and_then(|cfg| cfg.search_context_size),
search_content_types,
},
false,
/*supports_parallel_tool_calls*/ false,
config.code_mode_enabled,
);
}
@@ -2884,7 +2889,7 @@ pub(crate) fn build_specs_with_discoverable_tools(
ToolSpec::ImageGeneration {
output_format: "png".to_string(),
},
false,
/*supports_parallel_tool_calls*/ false,
config.code_mode_enabled,
);
}
@@ -2892,7 +2897,7 @@ pub(crate) fn build_specs_with_discoverable_tools(
push_tool_spec(
&mut builder,
create_view_image_tool(config.can_request_original_image_detail),
true,
/*supports_parallel_tool_calls*/ true,
config.code_mode_enabled,
);
builder.register_handler("view_image", view_image_handler);
@@ -2901,7 +2906,7 @@ pub(crate) fn build_specs_with_discoverable_tools(
push_tool_spec(
&mut builder,
create_artifacts_tool(),
false,
/*supports_parallel_tool_calls*/ false,
config.code_mode_enabled,
);
builder.register_handler("artifacts", artifacts_handler);
@@ -2911,31 +2916,31 @@ pub(crate) fn build_specs_with_discoverable_tools(
push_tool_spec(
&mut builder,
create_spawn_agent_tool(config),
false,
/*supports_parallel_tool_calls*/ false,
config.code_mode_enabled,
);
push_tool_spec(
&mut builder,
create_send_input_tool(),
false,
/*supports_parallel_tool_calls*/ false,
config.code_mode_enabled,
);
push_tool_spec(
&mut builder,
create_resume_agent_tool(),
false,
/*supports_parallel_tool_calls*/ false,
config.code_mode_enabled,
);
push_tool_spec(
&mut builder,
create_wait_agent_tool(),
false,
/*supports_parallel_tool_calls*/ false,
config.code_mode_enabled,
);
push_tool_spec(
&mut builder,
create_close_agent_tool(),
false,
/*supports_parallel_tool_calls*/ false,
config.code_mode_enabled,
);
builder.register_handler("spawn_agent", Arc::new(SpawnAgentHandler));
@@ -2950,7 +2955,7 @@ pub(crate) fn build_specs_with_discoverable_tools(
push_tool_spec(
&mut builder,
create_spawn_agents_on_csv_tool(),
false,
/*supports_parallel_tool_calls*/ false,
config.code_mode_enabled,
);
builder.register_handler("spawn_agents_on_csv", agent_jobs_handler.clone());
@@ -2958,7 +2963,7 @@ pub(crate) fn build_specs_with_discoverable_tools(
push_tool_spec(
&mut builder,
create_report_agent_job_result_tool(),
false,
/*supports_parallel_tool_calls*/ false,
config.code_mode_enabled,
);
builder.register_handler("report_agent_job_result", agent_jobs_handler);
@@ -2975,7 +2980,7 @@ pub(crate) fn build_specs_with_discoverable_tools(
push_tool_spec(
&mut builder,
ToolSpec::Function(converted_tool),
false,
/*supports_parallel_tool_calls*/ false,
config.code_mode_enabled,
);
builder.register_handler(name, mcp_handler.clone());
@@ -2994,7 +2999,7 @@ pub(crate) fn build_specs_with_discoverable_tools(
push_tool_spec(
&mut builder,
ToolSpec::Function(converted_tool),
false,
/*supports_parallel_tool_calls*/ false,
config.code_mode_enabled,
);
builder.register_handler(tool.name.clone(), dynamic_tool_handler.clone());
+7 -2
View File
@@ -104,7 +104,7 @@ pub async fn build_turn_metadata_header(cwd: &Path, sandbox: Option<&str>) -> Op
}
build_turn_metadata_bag(
None,
/*turn_id*/ None,
sandbox.map(ToString::to_string),
repo_root,
Some(WorkspaceGitMetadata {
@@ -135,7 +135,12 @@ impl TurnMetadataState {
) -> Self {
let repo_root = get_git_repo_root(&cwd).map(|root| root.to_string_lossy().into_owned());
let sandbox = Some(sandbox_tag(sandbox_policy, windows_sandbox_level).to_string());
let base_metadata = build_turn_metadata_bag(Some(turn_id), sandbox, None, None);
let base_metadata = build_turn_metadata_bag(
Some(turn_id),
sandbox,
/*repo_root*/ None,
/*workspace_git_metadata*/ None,
);
let base_header = base_metadata
.to_header_value()
.unwrap_or_else(|| "{}".to_string());
@@ -196,7 +196,12 @@ pub(crate) async fn emit_exec_end_for_unified_exec(
duration,
timed_out: false,
};
let event_ctx = ToolEventCtx::new(session_ref.as_ref(), turn_ref.as_ref(), &call_id, None);
let event_ctx = ToolEventCtx::new(
session_ref.as_ref(),
turn_ref.as_ref(),
&call_id,
/*turn_diff_tracker*/ None,
);
let emitter = ToolEmitter::unified_exec(
&command,
cwd,
@@ -180,7 +180,7 @@ impl UnifiedExecProcessManager {
context.session.as_ref(),
context.turn.as_ref(),
&context.call_id,
None,
/*turn_diff_tracker*/ None,
);
let emitter = ToolEmitter::unified_exec(
&request.command,
+3 -3
View File
@@ -375,7 +375,7 @@ fn emit_windows_sandbox_setup_success_metrics(
);
let _ = metrics.counter(
"codex.windows_sandbox.setup_success",
1,
/*inc*/ 1,
&[("originator", originator_tag), ("mode", mode_tag)],
);
}
@@ -401,7 +401,7 @@ fn emit_windows_sandbox_setup_failure_metrics(
);
let _ = metrics.counter(
"codex.windows_sandbox.setup_failure",
1,
/*inc*/ 1,
&[("originator", originator_tag), ("mode", mode_tag)],
);
@@ -426,7 +426,7 @@ fn emit_windows_sandbox_setup_failure_metrics(
} else {
let _ = metrics.counter(
"codex.windows_sandbox.legacy_setup_preflight_failed",
1,
/*inc*/ 1,
&[("originator", originator_tag)],
);
}