Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions packages/core/src/tools/shell.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,16 +195,15 @@ describe('ShellTool', () => {
expect(error).toBeNull();
});

it('should not suggest the intentional sleep comment for sleep chains', async () => {
it('should guide model to split and use intentional-sleep for sleep chains', async () => {
const error = shellTool.validateToolParams({
command: 'sleep 5 && echo ok',
is_background: false,
});

expect(error).toContain(
'intentional-sleep escape hatch only applies to standalone sleep commands',
);
expect(error).not.toContain('# intentional-sleep:');
expect(error).toContain('Split into two calls');
expect(error).toContain('intentional-sleep:');
expect(error).toContain('reason');
});

it('should throw an error for a relative directory path', async () => {
Expand Down
6 changes: 2 additions & 4 deletions packages/core/src/tools/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4361,16 +4361,14 @@ export class ShellTool extends BaseDeclarativeTool<
// `-c` script. This matches every other sensitive check in this file
// (directory, read-only, command-root extraction, etc.).
if (!params.is_background) {
const sleepPattern = detectBlockedSleepPatternDetails(
stripShellWrapper(params.command),
);
const sleepPattern = detectBlockedSleepPatternDetails(strippedCommand);
if (sleepPattern !== null) {
const intentionalSleepGuidance =
sleepPattern.intentionalSleepRejection ??
(sleepPattern.isStandalone
? 'If you genuinely need a standalone delay (rate limiting, deliberate pacing), ' +
'add a trailing comment like `# intentional-sleep: wait for MCP rate limit reset` (up to 10 minutes).'
: 'The intentional-sleep escape hatch only applies to standalone sleep commands; split follow-up commands into a separate invocation.');
: 'Split into two calls: first `sleep N # intentional-sleep: <reason>` (standalone), then the follow-up command.');
return (
`Blocked: ${sleepPattern.description}. ` +
'Run blocking commands in the background with is_background: true. ' +
Expand Down
Loading