feat: add is-mutating detection for shell command handler (#7729)

This commit is contained in:
jif-oai
2025-12-08 18:42:09 +00:00
committed by GitHub
parent c2bdee0946
commit da983c1761

View File

@@ -148,6 +148,20 @@ impl ToolHandler for ShellCommandHandler {
matches!(payload, ToolPayload::Function { .. })
}
fn is_mutating(&self, invocation: &ToolInvocation) -> bool {
let ToolPayload::Function { arguments } = &invocation.payload else {
return true;
};
serde_json::from_str::<ShellCommandToolCallParams>(arguments)
.map(|params| {
let shell = invocation.session.user_shell();
let command = shell.derive_exec_args(&params.command, params.login.unwrap_or(true));
!is_known_safe_command(&command)
})
.unwrap_or(true)
}
async fn handle(&self, invocation: ToolInvocation) -> Result<ToolOutput, FunctionCallError> {
let ToolInvocation {
session,