fix(ai): _run_dir_loop APIError path doesn't flush partial dir entry, loses cached work #83
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
_run_dir_loophas two early-exit paths: budget exhaustion and API error. The budget path flushes a partialdircache entry so the work already done in this loop (anyfilecache entries the agent wrote before the budget tripped) is preserved and usable by synthesis. The API error path just breaks.luminos_lib/ai.py:1207-1225:Consequence
A transient API error (rate limit, 500, network blip) after the agent has written several
filecache entries results in:dircache entry for this directory--fresh), the whole dir is re-investigated from scratch — even though thefileentries are still thereThe budget path's logic is exactly what we want here too: cache whatever the agent already produced, mark it partial, don't waste it.
Fix
Before
breakin the APIError path, call the same helper:_flush_partial_dir_entryis already idempotent (returns""if a dir entry already exists), so calling it here is safe.Acceptance
dircache entry when the agent has written at least onefileentrytest_ai_pure.pycovers the_flush_partial_dir_entryidempotency for both paths (budget + APIError)