Work effectively with AI coding agents. Understand them as language models running in a tool loop with limited context, which is why they guess, game the visible signal and report confidently. Recognise the shortcut and correctness tells in their code across Python, TypeScript/JavaScript, Rust, Java and Go, and know the damage each one does later. Verify changes instead of trusting them, review diffs fast for quality and security, judge when work is truly finished, and choose, design and steer tasks so agents can finish them well.
Race conditions and interleavings card 1 of 6

A sleep made the counter test pass

Your service's hit counter comes up a few short under load. You ask the agent to fix the flaky test that checks it. It adds `time.sleep(0.01)` between thread starts, reruns, gets green and reports "fixed a timing issue". The way the counter is updated did not change. Is the bug gone, or is it only harder to see?
Terms on this card
flaky
Describes a test that sometimes passes and sometimes fails with no code change, often because its outcome depends on timing or ordering.
the agent
The AI coding system doing the work: a chat assistant, IDE agent or terminal agent.
green
A test or check that passes.
flaky test
A test that sometimes passes and sometimes fails on the same code, often because of timing or ordering.
pass
Python statement that does nothing; used as a body, it makes a function or handler an empty shell.
Learn this step by step on Bytewise
Lesson goal: Explain how concurrent code can interleave and produce wrong results, using check-then-act and read-modify-write as examples. Distinguish a data race from a logical race, and explain why only synchronization (locks, atomics, channels) creates ordering while timing does not. · the whole lesson