Skip to content

Commit 8858012

Browse files
authored
chore: emit unified exec begin only when PTY exist (#8780)
1 parent 6346e4f commit 8858012

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

codex-rs/core/src/tools/handlers/unified_exec.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
use crate::function_tool::FunctionCallError;
22
use crate::is_safe_command::is_known_safe_command;
33
use crate::protocol::EventMsg;
4-
use crate::protocol::ExecCommandSource;
54
use crate::protocol::TerminalInteractionEvent;
65
use crate::sandboxing::SandboxPermissions;
76
use crate::shell::Shell;
87
use crate::shell::get_shell_by_model_provided_path;
98
use crate::tools::context::ToolInvocation;
109
use crate::tools::context::ToolOutput;
1110
use crate::tools::context::ToolPayload;
12-
use crate::tools::events::ToolEmitter;
13-
use crate::tools::events::ToolEventCtx;
14-
use crate::tools::events::ToolEventStage;
1511
use crate::tools::handlers::apply_patch::intercept_apply_patch;
1612
use crate::tools::registry::ToolHandler;
1713
use crate::tools::registry::ToolKind;
@@ -172,20 +168,6 @@ impl ToolHandler for UnifiedExecHandler {
172168
return Ok(output);
173169
}
174170

175-
let event_ctx = ToolEventCtx::new(
176-
context.session.as_ref(),
177-
context.turn.as_ref(),
178-
&context.call_id,
179-
None,
180-
);
181-
let emitter = ToolEmitter::unified_exec(
182-
&command,
183-
cwd.clone(),
184-
ExecCommandSource::UnifiedExecStartup,
185-
Some(process_id.clone()),
186-
);
187-
emitter.emit(event_ctx, ToolEventStage::Begin).await;
188-
189171
manager
190172
.exec_command(
191173
ExecCommandRequest {

codex-rs/core/src/unified_exec/session_manager.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@ use crate::codex::TurnContext;
1616
use crate::exec_env::create_env;
1717
use crate::protocol::BackgroundEventEvent;
1818
use crate::protocol::EventMsg;
19+
use crate::protocol::ExecCommandSource;
1920
use crate::sandboxing::ExecEnv;
2021
use crate::sandboxing::SandboxPermissions;
22+
use crate::tools::events::ToolEmitter;
23+
use crate::tools::events::ToolEventCtx;
24+
use crate::tools::events::ToolEventStage;
2125
use crate::tools::orchestrator::ToolOrchestrator;
2226
use crate::tools::runtimes::unified_exec::UnifiedExecRequest as UnifiedExecToolRequest;
2327
use crate::tools::runtimes::unified_exec::UnifiedExecRuntime;
@@ -141,6 +145,19 @@ impl UnifiedExecSessionManager {
141145
};
142146

143147
let transcript = Arc::new(tokio::sync::Mutex::new(CommandTranscript::default()));
148+
let event_ctx = ToolEventCtx::new(
149+
context.session.as_ref(),
150+
context.turn.as_ref(),
151+
&context.call_id,
152+
None,
153+
);
154+
let emitter = ToolEmitter::unified_exec(
155+
&request.command,
156+
cwd.clone(),
157+
ExecCommandSource::UnifiedExecStartup,
158+
Some(request.process_id.clone()),
159+
);
160+
emitter.emit(event_ctx, ToolEventStage::Begin).await;
144161
start_streaming_output(&session, context, Arc::clone(&transcript));
145162

146163
let max_tokens = resolve_max_tokens(request.max_output_tokens);

0 commit comments

Comments
 (0)