Train model to refactor in better order

Open 💬 0 comments Opened May 9, 2026 by joshka

What variant of Codex are you using?

CLI / TUI

What feature would you like to see?

TL;DR: train the gpt model to write code so that existing code continues to compile while editing.

Often when codex refactors code, it does the calling side of the code before the called side. So for instance if it is refactoring a module into multiple modules it might add mod foo before adding foo.rs. This makes the project unable to be compiled, tested, etc. while codex is in the process of making edits. In effect, codex leaves the project unbuildable for long periods of time. This is annoying as often in multi-step situations it would be great to be able to see the part of the work that's done first, while waiting for the next piece to be done. This is systemic observation over many many refactorings.

What I'd like to see here is some model tuning that helps source code stay compilable while modifying it. So you might add a function and then call it from the location it needs to be called, instead of calling a function and then defining it.

There's probably local agents.md steering that would help push codex to do this (and obv. there's the question of whether this type of ordering results in higher evals one way or the other). Would be good to see a "we tried it that way and it was worse" generally.

The impact of this is being unable to interact with compiling code for periods where codex has control over the code. E.g. being able to cargo run a tool that has a purely additive new feature being added.

Additional information

_No response_

View original on GitHub ↗