Coding agents on long tasks
Give DeepSeek V4 Pro a repository, a failing test and your tools, and let it read, edit and rerun until the test passes. Keep the tool log and review the final diff yourself before merging.
Example: Why does this payment retry charge the customer twice?
Material
- Code
- for attempt in range(3): key = uuid4() resp = charge(order_id, amount, idempotency_key=key) if resp.ok: break
- Log
- attempt 1: timeout after 10s; attempt 2: ok. Payment provider shows two charges.
PromptFind the bug that can charge a customer twice, explain how it happens, and show the smallest fix.
Sample answer · written by hand to show the reasoning
The idempotency key is created inside the loop, so each retry looks like a new payment. When attempt 1 timed out, the provider had already processed it, and attempt 2 charged again. Create the key once before the loop, for example from the order ID, and pass the same key on every attempt.