mirror of
https://github.com/openai/codex.git
synced 2026-11-03 16:23:51 +00:00
Move exec command truncation into ExecCommandToolOutput (#14169)
Summary - relocate truncation logic for exec command output into the new `ExecCommandToolOutput` response helper instead of centralized handler code - update all affected tools and unified exec handling to use the new response item structure and eliminate `Function(FunctionToolOutput)` responses - adjust context, registry, and handler interfaces to align with the new response semantics and error fields Testing - Not run (not requested)
This commit is contained in:
1 parent
0c33af7746
commit
a9ae43621b
4 files changed
+154
-75
No files matched your search
@@ -26,7 +26,6 @@ use std::collections::HashSet;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
use std::sync::Weak;
|
||||
use std::time::Duration;
|
||||
|
||||
use codex_network_proxy::NetworkProxy;
|
||||
use codex_protocol::models::PermissionProfile;
|
||||
@@ -108,20 +107,6 @@ pub(crate) struct WriteStdinRequest<'a> {
|
||||
pub max_output_tokens: Option<usize>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub(crate) struct UnifiedExecResponse {
|
||||
pub event_call_id: String,
|
||||
pub chunk_id: String,
|
||||
pub wall_time: Duration,
|
||||
pub output: String,
|
||||
/// Raw bytes returned for this unified exec call before any truncation.
|
||||
pub raw_output: Vec<u8>,
|
||||
pub process_id: Option<String>,
|
||||
pub exit_code: Option<i32>,
|
||||
pub original_token_count: Option<usize>,
|
||||
pub session_command: Option<Vec<String>>,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub(crate) struct ProcessStore {
|
||||
processes: HashMap<String, ProcessEntry>,
|
||||
@@ -192,6 +177,7 @@ mod tests {
|
||||
use crate::codex::make_session_and_context;
|
||||
use crate::protocol::AskForApproval;
|
||||
use crate::protocol::SandboxPolicy;
|
||||
use crate::tools::context::ExecCommandToolOutput;
|
||||
use crate::unified_exec::ExecCommandRequest;
|
||||
use crate::unified_exec::WriteStdinRequest;
|
||||
use core_test_support::skip_if_sandbox;
|
||||
@@ -218,7 +204,7 @@ mod tests {
|
||||
turn: &Arc<TurnContext>,
|
||||
cmd: &str,
|
||||
yield_time_ms: u64,
|
||||
) -> Result<UnifiedExecResponse, UnifiedExecError> {
|
||||
) -> Result<ExecCommandToolOutput, UnifiedExecError> {
|
||||
let context =
|
||||
UnifiedExecContext::new(Arc::clone(session), Arc::clone(turn), "call".to_string());
|
||||
let process_id = session
|
||||
@@ -255,7 +241,7 @@ mod tests {
|
||||
process_id: &str,
|
||||
input: &str,
|
||||
yield_time_ms: u64,
|
||||
) -> Result<UnifiedExecResponse, UnifiedExecError> {
|
||||
) -> Result<ExecCommandToolOutput, UnifiedExecError> {
|
||||
session
|
||||
.services
|
||||
.unified_exec_manager
|
||||
@@ -330,7 +316,7 @@ mod tests {
|
||||
)
|
||||
.await?;
|
||||
assert!(
|
||||
out_2.output.contains("codex"),
|
||||
out_2.truncated_output().contains("codex"),
|
||||
"expected environment variable output"
|
||||
);
|
||||
|
||||
@@ -366,7 +352,7 @@ mod tests {
|
||||
"short command should not report a process id if it exits quickly"
|
||||
);
|
||||
assert!(
|
||||
!out_2.output.contains("codex"),
|
||||
!out_2.truncated_output().contains("codex"),
|
||||
"short command should run in a fresh shell"
|
||||
);
|
||||
|
||||
@@ -382,7 +368,7 @@ mod tests {
|
||||
)
|
||||
.await?;
|
||||
assert!(
|
||||
out_3.output.contains("codex"),
|
||||
out_3.truncated_output().contains("codex"),
|
||||
"session should preserve state"
|
||||
);
|
||||
|
||||
@@ -420,7 +406,7 @@ mod tests {
|
||||
)
|
||||
.await?;
|
||||
assert!(
|
||||
!out_2.output.contains(TEST_VAR_VALUE),
|
||||
!out_2.truncated_output().contains(TEST_VAR_VALUE),
|
||||
"timeout too short should yield incomplete output"
|
||||
);
|
||||
|
||||
@@ -429,7 +415,7 @@ mod tests {
|
||||
let out_3 = write_stdin(&session, process_id, "", 100).await?;
|
||||
|
||||
assert!(
|
||||
out_3.output.contains(TEST_VAR_VALUE),
|
||||
out_3.truncated_output().contains(TEST_VAR_VALUE),
|
||||
"subsequent poll should retrieve output"
|
||||
);
|
||||
|
||||
@@ -444,7 +430,7 @@ mod tests {
|
||||
let result = exec_command(&session, &turn, "echo codex", 120_000).await?;
|
||||
|
||||
assert!(result.process_id.is_some());
|
||||
assert!(result.output.contains("codex"));
|
||||
assert!(result.truncated_output().contains("codex"));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -459,7 +445,7 @@ mod tests {
|
||||
result.process_id.is_some(),
|
||||
"completed command should report a process id"
|
||||
);
|
||||
assert!(result.output.contains("codex"));
|
||||
assert!(result.truncated_output().contains("codex"));
|
||||
|
||||
assert!(
|
||||
session
|
||||
|
||||
Reference in new issue
Block a user