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 21:55:45 +02:00
parent 4a19e1e521
commit cb424d8fe7
2 changed files with 5 additions and 5 deletions

View File

@ -1727,10 +1727,10 @@ class ResponseProcessor:
# If parsing fails, keep the original string
pass
output_to_use = output
# If this is for the LLM and it's an edit_file tool, create a concise output
if for_llm and function_name == 'edit_file' and isinstance(output, dict):
output_for_llm = {"message": output.get("message", "File edited successfully.")}
output = output_for_llm
output_to_use = {"message": output.get("message", "File edited successfully.")}
# Create the structured result
structured_result_v1 = {
@ -1741,7 +1741,7 @@ class ResponseProcessor:
"arguments": arguments,
"result": {
"success": result.success if hasattr(result, 'success') else True,
"output": output, # This will be either rich or concise based on `for_llm`
"output": output_to_use, # This will be either rich or concise based on `for_llm`
"error": getattr(result, 'error', None) if hasattr(result, 'error') else None
},
}

View File

@ -246,9 +246,9 @@ export const extractPrimaryParam = (
return match ? match[1].split('/').pop() || match[1] : null;
case 'edit-file':
// Try to match target_file attribute for edit-file
match = content.match(/target_file=(?:"|')([^"|']+)(?:"|')/);
match = content.match(/target_file=(?:"|')([^"|']+)(?:"|')/) || content.match(/<parameter\s+name=["']target_file["']>([^<]+)/i);
// Return just the filename part
return match ? match[1].split('/').pop() || match[1] : null;
return match ? (match[1].split('/').pop() || match[1]).trim() : null;
// Shell commands
case 'execute-command':