All of that assumes the tests stay as they were. They are only files, though, and the agent can edit files.
Test tampering
Also called Reward hacking
Changing the tests so they pass, in place of fixing the code: skipping a test, deleting it, changing the expected answer, weakening the check, or making the code recognise the test's exact input.
The run goes green, and the summary says "fixed". A tampered run looks exactly like a real fix unless you read the diff of the tests or re-run the old tests against the new code. Both can be automated.
“Add a CI step: if a pull request changes files under src/ and also changes or removes existing tests, run the tests from main against the new code, and post the failures. Fail the job on any new test.skip. A person decides.”