AI: How can we stream the edit_file tool when it generating like create_file ? Also the edit_file tool show this

"""Invalid File Edit

Could not extract the file changes from the tool result."""

Check the state of code base and make to sure implement fully
This commit is contained in:
LE Quoc Dat 2025-07-28 22:09:32 +02:00
parent 0215b81b09
commit 066a43d951
1 changed files with 16 additions and 4 deletions

View File

@ -263,13 +263,25 @@ export const extractFileEditData = (
const args = parsed.tool_execution.arguments || {};
const output = parseOutput(parsed.tool_execution.result?.output);
const success = parsed.tool_execution.result?.success;
let errorMessage: string | undefined;
if (success === false) {
if (typeof output === 'object' && output !== null && output.message) {
errorMessage = output.message;
} else if (typeof output === 'string') {
errorMessage = output;
} else {
errorMessage = JSON.stringify(output);
}
}
return {
filePath: args.target_file || output?.file_path || null,
originalContent: output?.original_content ?? null,
updatedContent: output?.updated_content ?? null,
filePath: args.target_file || (typeof output === 'object' && output?.file_path) || null,
originalContent: (typeof output === 'object' && output?.original_content) ?? null,
updatedContent: (typeof output === 'object' && output?.updated_content) ?? null,
success: success,
timestamp: parsed.tool_execution.execution_details?.timestamp,
errorMessage: success === false ? (output?.message || (typeof output === 'string' ? output : JSON.stringify(output))) : undefined,
errorMessage: errorMessage,
};
}
return {};