Model and Inference EngineeringPost-training and alignmentPrincipal
How would you diagnose a coding policy that passes fixed training tests but fails unseen cases?
By Amit Kumar3 min readWorked answer includedReviewed 28 Sept 2026
The question
Interview question
A reinforcement-learning coding policy passes nearly all tests in a small fixed reward suite, yet independent tests expose empty-input, overflow and boundary failures. Distinguish specification errors, ordinary generalization and verifier exploitation. Design stronger training feedback and fresh release evidence, accounting for the sparse-reward cost of harder tests.
Draft your approach first
Take a few minutes before you read the answer. Name the constraint that matters most, the failure you are designing for and how you would know it worked.
Reveal the worked answerWorked answer
It is improving on the reward it can observe. A small test suite is evidence about a program's behavior on those inputs, not a proof of the intended function. If the same tasks and tests are reused for many training steps, the policy can learn shortcuts that exploit their coverage even without literally reading or editing the tests. Research on fuzzing RLVR verifiers studies how verifier bugs can become optimization targets. That supports a risk, not a claim that every failing hidden case was consciously gamed by the model. Some may be ordinary generalization failures or a bad task specification.
A hypothetical sorting task makes the coverage problem visible. If every reward test supplies an already sorted list, returning the input unchanged passes them all. A hidden test with [2,1] exposes that it does not implement sorting. The same defect can arise without editing tests or deliberately identifying them. The observations rewarded a behavior that was insufficiently constrained by the task’s tested inputs.
I would classify failures first. Is the prompt ambiguous, the solution invalid under the stated constraints, the verifier wrong, or the hidden suite checking a requirement never expressed? For a sample of tasks, compare public-test pass rate with held-out edge and property tests, mutation testing, and differential checks against trusted reference implementations. Mutation testing deliberately introduces faults and asks whether tests detect them. Differential checking compares outputs with an independently trusted implementation. Neither proves correctness if its oracle or specification is wrong. Keep test generation and labels outside the policy's writable sandbox. Randomized tests can raise coverage, but fixed seeds used forever can become another memorized target. Version and audit test suites so reward changes are visible in the training trace.
I would not secretly move all hidden cases into the reward and declare success. That can lift training reward while consuming the independent evidence of generalization. Keep a genuinely held-out task set, preferably with fresh problems and tests from a separate process. For training, strengthen verifier coverage and problem specifications, and use reward signal only from trusted tests with bounded compute. Measure pass on new tasks under the actual sampling budget, not just the number of public tests passed on seen prompts.
What if the policy cannot learn from a binary pass/fail signal when the hard test suite is broad? Every sampled solution gets zero reward. Why is the GRPO training run doing almost no learning? explains how all-zero groups remove relative task advantage. A more informative reward can help, but partial-credit tests can make the policy optimize easy cases while ignoring essential rare ones. A coding policy earns full reward by changing the tests. What was the verifier allowed to trust? covers changing the test files themselves. Here the tests are immutable and the reward is still an incomplete proxy for correct code.
Related questions
Keep practising model and inference engineering
Follow another question in this area, or search the complete library.
Get my essays on AI engineering and distributed systems by email. Subscribe to ArchCrux