🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
🐛 fix(prompts): mark an empty command result as (no output) (#19398)
Arvin Xu08e5a5c61326
diff --git a/packages/builtin-tool-skills/src/ExecutionRuntime/index.test.ts b/packages/builtin-tool-skills/src/ExecutionRuntime/index.test.tsindex 933a9dedd44..96987ce2490 100644--- a/packages/builtin-tool-skills/src/ExecutionRuntime/index.test.ts+++ b/packages/builtin-tool-skills/src/ExecutionRuntime/index.test.ts@@ -105,7 +105,7 @@ describe('SkillsExecutionRuntime', () => {const result = await runtime.execScript(args);- expect(result.content).toBe('Command completed successfully.');+ expect(result.content).toBe('Command completed successfully.\n\n(no output)');});it('should return success: false when execScript throws', async () => {diff --git a/packages/prompts/src/prompts/fileSystem/formatCommandResult.test.ts b/packages/prompts/src/prompts/fileSystem/formatCommandResult.test.tsindex 7ed7290ce7c..a0ef9e9915c 100644--- a/packages/prompts/src/prompts/fileSystem/formatCommandResult.test.ts+++ b/packages/prompts/src/prompts/fileSystem/formatCommandResult.test.ts@@ -5,7 +5,34 @@ import { formatCommandResult } from './formatCommandResult';describe('formatCommandResult', () => {it('should format successful command without output', () => {const result = formatCommandResult({ exitCode: 0, success: true });- expect(result).toMatchInlineSnapshot(`"Command completed successfully."`);+ expect(result).toMatchInlineSnapshot(`+ "Command completed successfully.++ (no output)"+ `);+ });++ it('should mark empty output when the command crashed with stderr discarded', () => {+ const result = formatCommandResult({ exitCode: 0, stderr: '', stdout: '', success: true });+ expect(result).toMatchInlineSnapshot(`+ "Command completed successfully.++ (no output)"+ `);+ });++ it('should mark empty output on a failed command too', () => {+ const result = formatCommandResult({ exitCode: 1, success: true });+ expect(result).toMatchInlineSnapshot(`+ "Command failed with exit code 1++ (no output)"+ `);+ });++ it('should not mark empty output while the command is still running', () => {+ const result = formatCommandResult({ shellId: 'shell-123', success: true });+ expect(result).not.toContain('(no output)');});it('should format still-running command', () => {@@ -112,7 +139,11 @@ describe('formatCommandResult', () => {exitCode: 0,success: true,});- expect(result).toMatchInlineSnapshot(`"Command completed successfully."`);+ expect(result).toMatchInlineSnapshot(`+ "Command completed successfully.++ (no output)"+ `);});it('should treat shell id with exitCode 0 as completed', () => {@@ -121,7 +152,11 @@ describe('formatCommandResult', () => {shellId: 'shell-123',success: true,});- expect(result).toMatchInlineSnapshot(`"Command completed successfully."`);+ expect(result).toMatchInlineSnapshot(`+ "Command completed successfully.++ (no output)"+ `);});it('should treat a non-zero exit code as failure even when envelope success is true', () => {diff --git a/packages/prompts/src/prompts/fileSystem/formatCommandResult.ts b/packages/prompts/src/prompts/fileSystem/formatCommandResult.tsindex 36c01f85a85..0b413767268 100644--- a/packages/prompts/src/prompts/fileSystem/formatCommandResult.ts+++ b/packages/prompts/src/prompts/fileSystem/formatCommandResult.ts@@ -60,5 +60,14 @@ export const formatCommandResult = ({if (stdout) parts.push(`Stdout:\n${stdout}`);if (stderr) parts.push(`Stderr:\n${stderr}`);+ // A command that ran but wrote nothing to either stream has to say so. Without+ // the marker, "wrote nothing" and "wrote to stderr, which `2>/dev/null` threw+ // away" render as the same lone header line, and the caller reads that silence+ // as a clean run. Only for a command that actually finished — `exitCode`+ // undefined is the still-running branch, where empty output means nothing yet.+ const hasOutput =+ !!stdout || !!stderr || !!outputFiles?.stdout?.path || !!outputFiles?.stderr?.path;+ if (!hasOutput && exitCode !== undefined) parts.push('(no output)');+return parts.join('\n\n');};