childtoken and tests

This commit is contained in:
Ahmed Ibrahim
2026-01-11 22:52:46 -08:00
parent f651e72ef4
commit 016f8ba2db
10 changed files with 15 additions and 15 deletions

View File

@@ -106,7 +106,7 @@ impl SessionTask for UserShellCommandTask {
// default timeout now that cancellation is wired through ExecExpiration.
expiration: ExecExpiration::from_timeout_ms(
Some(USER_SHELL_TIMEOUT_MS),
cancellation_token.clone(),
cancellation_token.child_token(),
),
sandbox: SandboxType::None,
sandbox_permissions: SandboxPermissions::UseDefault,

View File

@@ -145,7 +145,7 @@ impl ToolHandler for ApplyPatchHandler {
turn: turn.as_ref(),
call_id: call_id.clone(),
tool_name: tool_name.to_string(),
cancellation_token: cancellation_token.clone(),
cancellation_token: cancellation_token.child_token(),
};
let out = orchestrator
.run(&mut runtime, &req, &tool_ctx, &turn, turn.approval_policy)

View File

@@ -115,7 +115,7 @@ impl ToolHandler for ShellHandler {
ToolPayload::Function { arguments } => {
let params: ShellToolCallParams = parse_arguments(&arguments)?;
let exec_params =
Self::to_exec_params(params, turn.as_ref(), cancellation_token.clone());
Self::to_exec_params(params, turn.as_ref(), cancellation_token.child_token());
Self::run_exec_like(
tool_name.as_str(),
exec_params,
@@ -126,7 +126,7 @@ impl ToolHandler for ShellHandler {
}
ToolPayload::LocalShell { params } => {
let exec_params =
Self::to_exec_params(params, turn.as_ref(), cancellation_token.clone());
Self::to_exec_params(params, turn.as_ref(), cancellation_token.child_token());
Self::run_exec_like(
tool_name.as_str(),
exec_params,
@@ -188,7 +188,7 @@ impl ToolHandler for ShellCommandHandler {
params,
session.as_ref(),
turn.as_ref(),
cancellation_token.clone(),
cancellation_token.child_token(),
);
ShellHandler::run_exec_like(
tool_name.as_str(),
@@ -265,7 +265,7 @@ impl ShellHandler {
Some(&tracker),
&call_id,
tool_name,
cancellation_token.clone(),
cancellation_token.child_token(),
)
.await?
{

View File

@@ -164,7 +164,7 @@ impl ToolHandler for UnifiedExecHandler {
Some(&tracker),
&context.call_id,
tool_name.as_str(),
context.cancellation_token.clone(),
context.cancellation_token.child_token(),
)
.await?
{

View File

@@ -64,7 +64,7 @@ impl ToolCallRuntime {
let handle: AbortOnDropHandle<Result<ResponseInputItem, FunctionCallError>> =
AbortOnDropHandle::new(tokio::spawn(async move {
let dispatch_cancellation = cancellation_token.clone();
let dispatch_cancellation = cancellation_token.child_token();
let mut dispatch_future = Box::pin(async {
let _guard = if supports_parallel {
Either::Left(lock.read().await)

View File

@@ -154,7 +154,7 @@ impl ToolRuntime<ApplyPatchRequest, ExecToolCallOutput> for ApplyPatchRuntime {
attempt: &SandboxAttempt<'_>,
ctx: &ToolCtx<'_>,
) -> Result<ExecToolCallOutput, ToolError> {
let spec = Self::build_command_spec(req, ctx.cancellation_token.clone())?;
let spec = Self::build_command_spec(req, ctx.cancellation_token.child_token())?;
let env = attempt
.env_for(spec)
.map_err(|err| ToolError::Codex(err.into()))?;

View File

@@ -157,7 +157,7 @@ impl ToolRuntime<ShellRequest, ExecToolCallOutput> for ShellRuntime {
};
let expiration =
ExecExpiration::from_timeout_ms(req.timeout_ms, ctx.cancellation_token.clone());
ExecExpiration::from_timeout_ms(req.timeout_ms, ctx.cancellation_token.child_token());
let spec = build_command_spec(
&command,
&req.cwd,

View File

@@ -180,7 +180,7 @@ impl<'a> ToolRuntime<UnifiedExecRequest, UnifiedExecProcess> for UnifiedExecRunt
&command,
&req.cwd,
&req.env,
ExecExpiration::default(ctx.cancellation_token.clone()),
ExecExpiration::default(ctx.cancellation_token.child_token()),
req.sandbox_permissions,
req.justification.clone(),
)

View File

@@ -543,7 +543,7 @@ impl UnifiedExecProcessManager {
turn: context.turn.as_ref(),
call_id: context.call_id.clone(),
tool_name: "exec_command".to_string(),
cancellation_token: context.cancellation_token.clone(),
cancellation_token: context.cancellation_token.child_token(),
};
orchestrator
.run(

View File

@@ -29,7 +29,7 @@ fn long_running_exec_command_with_output() -> (String, Option<&'static str>) {
)
} else {
(
"sleep 0.2; printf 'partial output\\n'; sleep 60".to_string(),
"sleep 0.2; printf 'partial output\\n' >&2; sleep 60".to_string(),
None,
)
}
@@ -47,7 +47,7 @@ fn long_running_shell_command_with_output() -> Vec<String> {
vec![
"/bin/sh".to_string(),
"-c".to_string(),
"sleep 0.2; printf 'partial output\\n'; sleep 60".to_string(),
"sleep 0.2; printf 'partial output\\n' >&2; sleep 60".to_string(),
]
}
}
@@ -64,7 +64,7 @@ fn long_running_local_shell_call_with_output() -> Vec<&'static str> {
vec![
"/bin/sh",
"-c",
"sleep 0.2; printf 'partial output\\n'; sleep 60",
"sleep 0.2; printf 'partial output\\n' >&2; sleep 60",
]
}
}