mmm, practically, llamacpp solved this with reasoning budget for tokens and a customized message.
ive tailored my local models to match agent with a message that pushes to use subagents and context compression.
it works pretty smoothly if theres proper vector and scope to the project. theres probably a way to also get it to record memories but ive not seen a memory system that includes spatial type reasoning which would create memories associated with file paths down to AST graphlike leaves.
then we could include remembering details about the path.
llamacpp also has a header for setting these that an intelligent harness could tailor per round message and budget. ideally you start with a small budget and expand based on some complexity criteria.
alas, i want to build things not related to AI.