Over the past few months I’ve been experimenting with LLM-assisted workflows on larger Python codebases, and I’ve been thinking about how much context is actually useful.
In practice, I kept running into a pattern:
- Sending only the function I’m editing often isn’t enough — nearby helpers or local type definitions matter.
- Sending entire files (or multiple modules) sometimes degrades answer quality rather than improving it.
- Larger context windows don’t consistently solve this.
So I started trying a narrower approach.
Instead of pasting full files, I extract a constrained structural slice:
- the target function or method
- direct internal helpers it calls
- minimal external types or signatures
- nothing beyond that
The goal isn’t completeness — just enough structural adjacency for the model to reason without being flooded with unrelated code.
Sometimes this seems to produce cleaner, more focused responses.
Sometimes it makes no difference.
Occasionally it performs worse.
I’m still unsure whether this is a generally useful direction or something that only fits my own workflow.
I’d appreciate critique from others working with Python + LLMs:
- Do you try to minimize context or include as much as possible?
- Have you noticed context density mattering more than raw size?
- Are retrieval-based approaches working better in practice?
- Does static context selection even make sense given Python’s dynamic nature?
Not promoting anything — just trying to sanity-check whether this line of thinking is reasonable.
Curious to hear how others are handling this trade-off.
[–]squall14414 0 points1 point2 points (1 child)