Release extraction intermediates after their last consumers

This commit is contained in:
2026-11-26 02:13:11 +00:00
parent 2d4a2c9c7a
commit dbe1dfbe60
5 changed files with 103 additions and 3 deletions

View File

@@ -80,6 +80,10 @@ func (r *Runner) runLanes(parent context.Context, input RunInput, step PreparedP
groups = append(groups, state.completedGroups[index]...)
}
completedOutputs[lane].diagnosticGroups = append(groups, completedOutputs[lane].diagnosticGroups...)
// All dispatched jobs have drained; incomplete values cannot be consumed.
state.completedGroups = nil
state.results = nil
state.values = nil
}
mergeCompletedLanes(&output, completedOutputs)
if err := selectRunError(parent, runErrors); err != nil {
@@ -263,6 +267,9 @@ func (e *laneEngine) handleExtractResult(result extractJobResult) {
}
func (e *laneEngine) handleCompletion(completion laneCompletion) {
// The worker has returned, so merge, normalization, and capture no longer
// borrow this lane's extraction values even if a sibling is still running.
e.states[completion.index].values = nil
e.completedOutputs[completion.index] = completion.output
if completion.err != nil {
e.runErrors = append(e.runErrors, classifyLaneError(completion.index, len(e.chunks), completion.err))
@@ -342,6 +349,8 @@ func finalizeLaneExtract(state *laneExtractState) {
state.fallbackCount++
}
}
// Ordered values now own the needed references; the reorder map is redundant.
state.results = nil
}
func (r *Runner) continueLane(ctx context.Context, input RunInput, doc *source.SourceDocument, sourceInput contracts.LLMInputMaterial, sessionID string, chunks []source.Chunk, state *laneExtractState) (laneOutput, error) {