Skip to content

Commit 0809694

Browse files
committed
fix: restore visibility of tool execution output
The CLI was no longer showing tool execution output by default. This change: 1. Fixed the logger's emitMessages method to properly respect log level 2. Changed the default log level to 'log' in the configuration 3. Updated tool execution logs to use info level instead of log level Fixes #328
1 parent de2861f commit 0809694

File tree

7 files changed

+44
-51
lines changed

7 files changed

+44
-51
lines changed

issue_content.md

-21
This file was deleted.

packages/agent/src/core/executeToolCall.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ export const executeToolCall = async (
7373
if (tool.logParameters) {
7474
tool.logParameters(validatedJson, toolContext);
7575
} else {
76-
logger.log('Parameters:');
76+
logger.info('Parameters:');
7777
Object.entries(validatedJson).forEach(([name, value]) => {
78-
logger.log(` - ${name}: ${JSON.stringify(value).substring(0, 60)}`);
78+
logger.info(` - ${name}: ${JSON.stringify(value).substring(0, 60)}`);
7979
});
8080
}
8181

@@ -103,12 +103,12 @@ export const executeToolCall = async (
103103
if (tool.logReturns) {
104104
tool.logReturns(output, toolContext);
105105
} else {
106-
logger.log('Results:');
106+
logger.info('Results:');
107107
if (typeof output === 'string') {
108-
logger.log(` - ${output}`);
108+
logger.info(` - ${output}`);
109109
} else if (typeof output === 'object') {
110110
Object.entries(output).forEach(([name, value]) => {
111-
logger.log(` - ${name}: ${JSON.stringify(value).substring(0, 60)}`);
111+
logger.info(` - ${name}: ${JSON.stringify(value).substring(0, 60)}`);
112112
});
113113
}
114114
}

packages/agent/src/core/toolAgent/toolAgentCore.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export const toolAgent = async (
102102

103103
// Add each message to the conversation
104104
for (const message of pendingUserMessages) {
105-
logger.log(`Message from user: ${message}`);
105+
logger.info(`Message from user: ${message}`);
106106
messages.push({
107107
role: 'user',
108108
content: `[Correction from user]: ${message}`,

packages/agent/src/core/toolAgent/toolExecutor.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export async function executeTools(
3737

3838
const { logger } = context;
3939

40-
logger.debug(`Executing ${toolCalls.length} tool calls`);
40+
logger.info(`Executing ${toolCalls.length} tool calls`);
4141

4242
const toolResults = await Promise.all(
4343
toolCalls.map(async (call) => {

packages/agent/src/utils/interactiveInput.ts

+34-21
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ class OutputInterceptor extends Writable {
2424
this.paused = false;
2525
}
2626

27-
_write(chunk: Buffer | string, encoding: BufferEncoding, callback: (error?: Error | null) => void): void {
27+
_write(
28+
chunk: Buffer | string,
29+
encoding: BufferEncoding,
30+
callback: (error?: Error | null) => void,
31+
): void {
2832
if (!this.paused) {
2933
this.originalStdout.write(chunk, encoding);
3034
}
@@ -36,83 +40,92 @@ class OutputInterceptor extends Writable {
3640
export const initInteractiveInput = () => {
3741
// Save original stdout
3842
const originalStdout = process.stdout;
39-
43+
4044
// Create interceptor
4145
const interceptor = new OutputInterceptor(originalStdout);
42-
46+
4347
// Replace stdout with our interceptor
4448
// @ts-expect-error - This is a hack to replace stdout
4549
process.stdout = interceptor;
46-
50+
4751
// Create readline interface for listening to key presses
4852
const rl = readline.createInterface({
4953
input: process.stdin,
5054
output: interceptor,
5155
terminal: true,
5256
});
53-
57+
5458
// Close the interface to avoid keeping the process alive
5559
rl.close();
56-
60+
5761
// Listen for keypress events
5862
readline.emitKeypressEvents(process.stdin);
5963
if (process.stdin.isTTY) {
6064
process.stdin.setRawMode(true);
6165
}
62-
66+
6367
process.stdin.on('keypress', async (str, key) => {
6468
// Check for Ctrl+C to exit
6569
if (key.ctrl && key.name === 'c') {
6670
process.exit(0);
6771
}
68-
72+
6973
// Check for Ctrl+M to enter message mode
7074
if (key.ctrl && key.name === 'm') {
7175
// Pause output
7276
interceptor.pause();
73-
77+
7478
// Create a readline interface for input
7579
const inputRl = createInterface({
7680
input: process.stdin,
7781
output: originalStdout,
7882
});
79-
83+
8084
try {
8185
// Reset cursor position and clear line
8286
originalStdout.write('\r\n');
83-
originalStdout.write(chalk.green('Enter correction or additional context (Ctrl+C to cancel):\n') + '> ');
84-
87+
originalStdout.write(
88+
chalk.green(
89+
'Enter correction or additional context (Ctrl+C to cancel):\n',
90+
) + '> ',
91+
);
92+
8593
// Get user input
8694
const userInput = await inputRl.question('');
87-
95+
8896
// Add message to queue if not empty
8997
if (userInput.trim()) {
9098
userMessages.push(userInput);
91-
originalStdout.write(chalk.green('\nMessage sent to agent. Resuming output...\n\n'));
99+
originalStdout.write(
100+
chalk.green('\nMessage sent to agent. Resuming output...\n\n'),
101+
);
92102
} else {
93-
originalStdout.write(chalk.yellow('\nEmpty message not sent. Resuming output...\n\n'));
103+
originalStdout.write(
104+
chalk.yellow('\nEmpty message not sent. Resuming output...\n\n'),
105+
);
94106
}
95107
} catch (error) {
96-
originalStdout.write(chalk.red(`\nError sending message: ${error}\n\n`));
108+
originalStdout.write(
109+
chalk.red(`\nError sending message: ${error}\n\n`),
110+
);
97111
} finally {
98112
// Close input readline interface
99113
inputRl.close();
100-
114+
101115
// Resume output
102116
interceptor.resume();
103117
}
104118
}
105119
});
106-
120+
107121
// Return a cleanup function
108122
return () => {
109123
// Restore original stdout
110-
// @ts-expect-error - This is a hack to restore stdout
111124
process.stdout = originalStdout;
112-
125+
113126
// Disable raw mode
114127
if (process.stdin.isTTY) {
115128
process.stdin.setRawMode(false);
116129
}
117130
};
118-
};
131+
};

packages/agent/src/utils/logger.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ export class Logger {
6666
}
6767

6868
private emitMessages(level: LogLevel, messages: unknown[]) {
69-
if (LogLevel.debug < this.logLevelIndex) return;
69+
// Allow all messages at the configured log level or higher
70+
if (level < this.logLevelIndex) return;
7071

7172
const lines = messages
7273
.map((message) =>

packages/cli/src/settings/config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export type Config = {
5454

5555
// Default configuration
5656
const defaultConfig: Config = {
57-
logLevel: 'info',
57+
logLevel: 'log',
5858

5959
// GitHub integration
6060
githubMode: true,

0 commit comments

Comments
 (0)