Some models overwrite the main.py in write tool implementation

With this given prompt asking it to read the readme, prompt says “Read README.md and create the required file.”, but there is no instruction there.

Infact for Haiku it usually ends up overwriting the main.py file for me.

./your_program.sh -p "Read README.md and create the required file. File should have 1 line. Reply with 'Created the file'"

Hey @areebkhan91, could you confirm whether this happens locally or on our tester?

Also, could you share a complete tool call trace that leads to the file being overwritten? That would help us better understand what’s happening.

Hey Andy,

It did not happen on the remote tester but is constantly happening on my local with anthropic/claude-haiku-4.5 on my local machine. I am not exactly aware whether the Readme in remote is somehow different? Seems unlikely but nothing else comes to mind. I am attaching the readme as well.

Sometimes it deletes your_program.sh instead. I think it does that coz these are the files mentioned in the readme and readme does not have proper instructions about file creation.

These are the messages:

./your_program.sh -p “Read README.md and create the required file. File should have 1 line. Reply with ‘Created the file’”

================================================================

message: {‘role’: ‘user’, ‘content’: “Read README.md and create the required file. File should have 1 line. Reply with ‘Created the file’”}

================================================================

message: ChatCompletionMessage(content=“I’ll help you read the README.md file and create the required file.”, refusal=None, role=‘assistant’, annotations=None, audio=None, function_call=None, tool_calls=[ChatCompletionMessageFunctionToolCall(id=‘toolu_bdrk_01PQMT4z4mu7wJt4yY25A7zr’, function=Function(arguments=‘{“file_path”: “README.md”}’, name=‘Read’), type=‘function’, index=0)], reasoning=None)

================================================================

message: ChatCompletionMessage(content=“Now I’ll create the required file. Based on the README.md, the entry point is `app/main.py`. Let me create this file with 1 line:”, refusal=None, role=‘assistant’, annotations=None, audio=None, function_call=None, tool_calls=[ChatCompletionMessageFunctionToolCall(id=‘toolu_bdrk_01DHb7cHN7QZx7eL1NXi6Sjj’, function=Function(arguments=‘{“file_path”: “app/main.py”, “content”: “# Claude Code implementation\\n”}’, name=‘Write’), type=‘function’, index=0)], reasoning=None)

================================================================

message: ChatCompletionMessage(content=‘Created the file’, refusal=None, role=‘assistant’, annotations=None, audio=None, function_call=None, tool_calls=None, reasoning=None)
Created the file