mirror of
https://github.com/openai/codex.git
synced 2026-11-26 23:40:43 +00:00
Allow async user messages through code mode (#63730)
## Why Agents could send async user messages only through a top-level tool call, even in code mode. ## What changed Set `features.send_message_to_user_async.direct_only` to `false` to make the tool follow the session's tool mode. Direct mode exposes it as a top-level tool, code mode allows both top-level and nested calls, and code-mode-only sessions require nested calls and reject direct calls. The default keeps the tool top-level only. Existing agent opt-ins still apply. ## Testing Add integration coverage for tool visibility, call results, and message delivery across all three tool modes with both values of `direct_only`. Improve failure diagnostics in the multiline shell snapshot test and paste `/status` as a single input event in the daemon compatibility test. GitOrigin-RevId: c69bb2fba8bf776eff01382d8869fc869fc9d479
This commit is contained in:
@@ -852,13 +852,11 @@ fn agent_type_description(
|
||||
}
|
||||
}
|
||||
|
||||
fn is_hidden_by_code_mode_only(
|
||||
turn_context: &TurnContext,
|
||||
model_info: &ModelInfo,
|
||||
pub(super) fn is_hidden_by_code_mode_only(
|
||||
tool_mode: ToolMode,
|
||||
tool_name: &ToolName,
|
||||
exposure: ToolExposure,
|
||||
) -> bool {
|
||||
let tool_mode = effective_tool_mode(turn_context, model_info);
|
||||
tool_mode == ToolMode::CodeModeOnly
|
||||
&& exposure.is_available_in_code_mode()
|
||||
&& codex_code_mode::is_code_mode_nested_tool(&codex_tools::code_mode_name_for_tool_name(
|
||||
@@ -873,8 +871,7 @@ fn is_directly_visible(
|
||||
) -> bool {
|
||||
tool.exposure.is_direct()
|
||||
&& !is_hidden_by_code_mode_only(
|
||||
turn_context,
|
||||
model_info,
|
||||
effective_tool_mode(turn_context, model_info),
|
||||
&tool.runtime.tool_name(),
|
||||
tool.exposure,
|
||||
)
|
||||
@@ -1322,7 +1319,12 @@ fn add_core_utility_tools(context: &CoreToolPlanContext<'_>, registry: &mut Tool
|
||||
let subagent_messages = features.subagent_async_messages_enabled
|
||||
&& turn_context.session_source.parent_thread_id().is_some();
|
||||
if root_messages || subagent_messages {
|
||||
registry.add_with_exposure(SendMessageToUserAsyncHandler, ToolExposure::DirectModelOnly);
|
||||
let exposure = if features.async_messages_in_code_mode {
|
||||
ToolExposure::Direct
|
||||
} else {
|
||||
ToolExposure::DirectModelOnly
|
||||
};
|
||||
registry.add_with_exposure(SendMessageToUserAsyncHandler, exposure);
|
||||
}
|
||||
|
||||
if features.enabled(Feature::RequestPermissionsTool) {
|
||||
|
||||
Reference in New Issue
Block a user