Compare commits

..

2 Commits

Author SHA1 Message Date
Dylan Hurd
bdac1c6192 tweak 2025-10-31 15:13:53 -07:00
Dylan Hurd
8671f79a00 fix: Longer apply_patch instructions 2025-10-31 14:18:32 -07:00
6 changed files with 13 additions and 22 deletions

View File

@@ -89,10 +89,7 @@ impl SessionTask for UserShellCommandTask {
let tool_call = ToolCall {
tool_name: USER_SHELL_TOOL_NAME.to_string(),
call_id: Uuid::new_v4().to_string(),
payload: ToolPayload::LocalShell {
params,
is_user_shell_command: true,
},
payload: ToolPayload::LocalShell { params },
};
let router = Arc::new(ToolRouter::from_config(&turn_context.tools_config, None));

View File

@@ -40,7 +40,6 @@ pub enum ToolPayload {
},
LocalShell {
params: ShellToolCallParams,
is_user_shell_command: bool,
},
UnifiedExec {
arguments: String,
@@ -57,7 +56,7 @@ impl ToolPayload {
match self {
ToolPayload::Function { arguments } => Cow::Borrowed(arguments),
ToolPayload::Custom { input } => Cow::Borrowed(input),
ToolPayload::LocalShell { params, .. } => Cow::Owned(params.command.join(" ")),
ToolPayload::LocalShell { params } => Cow::Owned(params.command.join(" ")),
ToolPayload::UnifiedExec { arguments } => Cow::Borrowed(arguments),
ToolPayload::Mcp { raw_arguments, .. } => Cow::Borrowed(raw_arguments),
}

View File

@@ -165,7 +165,13 @@ pub enum ApplyPatchToolType {
pub(crate) fn create_apply_patch_freeform_tool() -> ToolSpec {
ToolSpec::Freeform(FreeformTool {
name: "apply_patch".to_string(),
description: "Use the `apply_patch` tool to edit files. This is a FREEFORM tool, so do not wrap the patch in JSON.".to_string(),
description: "Send a patch to filesystem.apply_patch to edit files. This is a FREEFORM tool, so do not wrap the patch in JSON.
The patch must start with `*** Begin Patch` and end with `*** End Patch`. The second line is the beginning of a hunk:
- `*** Add File: PATH` creates a new file and is followed by lines that begin with `+`.
- `*** Delete File: PATH` removes a file.
- `*** Update File: PATH` edits a file. You may add `*** Move to: PATH` to rename it.
- Update lines should either start with @@ (start of range), ` ` (context line), `+` (add line), or `-` (delete line).
A patch can contain multiple hunks. `PATH` should be absolute.".to_string(),
format: FreeformToolFormat {
r#type: "grammar".to_string(),
syntax: "lark".to_string(),

View File

@@ -82,10 +82,7 @@ impl ToolHandler for ShellHandler {
)
.await
}
ToolPayload::LocalShell {
params,
is_user_shell_command,
} => {
ToolPayload::LocalShell { params } => {
let exec_params = Self::to_exec_params(params, turn.as_ref());
Self::run_exec_like(
tool_name.as_str(),
@@ -94,7 +91,7 @@ impl ToolHandler for ShellHandler {
turn,
tracker,
call_id,
is_user_shell_command,
true,
)
.await
}
@@ -222,7 +219,6 @@ impl ShellHandler {
env: exec_params.env.clone(),
with_escalated_permissions: exec_params.with_escalated_permissions,
justification: exec_params.justification.clone(),
is_user_shell_command,
};
let mut orchestrator = ToolOrchestrator::new();
let mut runtime = ShellRuntime::new();

View File

@@ -120,10 +120,7 @@ impl ToolRouter {
Ok(Some(ToolCall {
tool_name: "local_shell".to_string(),
call_id,
payload: ToolPayload::LocalShell {
params,
is_user_shell_command: false,
},
payload: ToolPayload::LocalShell { params },
}))
}
}

View File

@@ -34,7 +34,6 @@ pub struct ShellRequest {
pub env: std::collections::HashMap<String, String>,
pub with_escalated_permissions: Option<bool>,
pub justification: Option<String>,
pub is_user_shell_command: bool,
}
impl ProvidesSandboxRetryData for ShellRequest {
@@ -122,9 +121,6 @@ impl Approvable<ShellRequest> for ShellRuntime {
policy: AskForApproval,
sandbox_policy: &SandboxPolicy,
) -> bool {
if req.is_user_shell_command {
return false;
}
if is_known_safe_command(&req.command) {
return false;
}
@@ -150,7 +146,7 @@ impl Approvable<ShellRequest> for ShellRuntime {
}
fn wants_escalated_first_attempt(&self, req: &ShellRequest) -> bool {
req.is_user_shell_command || req.with_escalated_permissions.unwrap_or(false)
req.with_escalated_permissions.unwrap_or(false)
}
}