This paper introduces TENET, an LLM agent for generating functions from complex real-world code repositories in a TDD environment. TENET features three components: (1) concise test suite selection that maximizes the variety of usage scenarios, (2) efficient retrieval of relevant code through interactive debugging, and (3) a reflection-based improvement workflow that iterates through failure analysis, context augmentation, and code improvement. TENET achieves 69.08% and 81.77% Pass@1 on the RepoCod and RepoEval benchmarks, respectively, outperforming the best agent-based baselines. Furthermore, as the first study on TDD code generation using repository-level context, we investigate the impact of various aspects of the test suite on the performance of the LLM agent in a TDD environment.