Bug
When shell_execute is called with a WorkingDirectory outside the session directory (e.g. ~/.freshdesk-analysis/tickets/601/), ShellTool.ExecuteAsync sets ProcessStartInfo.WorkingDirectory directly without checking if the directory exists.
The code creates the directory only when IsResolvedSessionDirectory() returns true:
// ShellTool.cs lines ~85-100
var resolvedCwd = context.ResolveShellCwd(args.WorkingDirectory);
if (!string.IsNullOrWhiteSpace(resolvedCwd))
{
if (IsResolvedSessionDirectory(resolvedCwd, context.SessionDirectory))
{
Directory.CreateDirectory(resolvedCwd); // Only here
}
psi.WorkingDirectory = resolvedCwd; // Set regardless
}
When the directory doesn't exist, Process.Start() throws DirectoryNotFoundException, which bubbles up as a generic "Error starting process: ..." message.
Root Cause
ProcessStartInfo.WorkingDirectory requires the path to exist — this is a .NET runtime requirement, not an OS limitation. Forcing agents to create directories via skills before using them as working directories leads to infinite approval-expires loops because the error message doesn't explain why the command failed.
Proposed Fix
Check directory existence before setting WorkingDirectory, and return a helpful error:
if (!string.IsNullOrWhiteSpace(resolvedCwd))
{
if (IsResolvedSessionDirectory(resolvedCwd, context.SessionDirectory))
{
Directory.CreateDirectory(resolvedCwd);
}
else if (!Directory.Exists(resolvedCwd))
{
return $"Error: Working directory '{resolvedCwd}' does not exist. Create it first (e.g., mkdir -p {resolvedCwd}).";
}
psi.WorkingDirectory = resolvedCwd;
}
Impact
- Affects all shell commands with non-session working directories
- Affects PowerShell support when it lands (same code path)
- Agents get stuck in retry loops because the error message doesn't indicate the directory is missing
Bug
When
shell_executeis called with aWorkingDirectoryoutside the session directory (e.g.~/.freshdesk-analysis/tickets/601/),ShellTool.ExecuteAsyncsetsProcessStartInfo.WorkingDirectorydirectly without checking if the directory exists.The code creates the directory only when
IsResolvedSessionDirectory()returnstrue:When the directory doesn't exist,
Process.Start()throwsDirectoryNotFoundException, which bubbles up as a generic "Error starting process: ..." message.Root Cause
ProcessStartInfo.WorkingDirectoryrequires the path to exist — this is a .NET runtime requirement, not an OS limitation. Forcing agents to create directories via skills before using them as working directories leads to infinite approval-expires loops because the error message doesn't explain why the command failed.Proposed Fix
Check directory existence before setting
WorkingDirectory, and return a helpful error:Impact