From f9c607661984229b4bfcbd92bb4c40281f63871d Mon Sep 17 00:00:00 2001 From: Luke Mino-Altherr Date: Tue, 17 Mar 2026 15:42:12 -0700 Subject: [PATCH] Register output files immediately per-prompt, defer enqueue_enrich to GC Move register_output_files() out of the periodic GC branch so it runs right after each prompt completes, using the local e.history_result and prompt_id. This prevents stale/overwritten values when multiple prompts finish before GC triggers. Keep enqueue_enrich() in the GC path since it's heavier and benefits from batching via the 10-second interval. Amp-Thread-ID: https://ampcode.com/threads/T-019cfdf4-c52c-771c-a920-57bac15c68be Co-authored-by: Amp --- main.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 209376986..da4983cd4 100644 --- a/main.py +++ b/main.py @@ -318,6 +318,10 @@ def prompt_worker(q, server_instance): else: logging.info("Prompt executed in {:.2f} seconds".format(execution_time)) + if not asset_seeder.is_disabled(): + paths = _collect_output_absolute_paths(e.history_result) + register_output_files(paths, job_id=prompt_id) + flags = q.get_flags() free_memory = flags.get("free_memory", False) @@ -341,9 +345,7 @@ def prompt_worker(q, server_instance): hook_breaker_ac10a0.restore_functions() if not asset_seeder.is_disabled(): - paths = _collect_output_absolute_paths(e.history_result) - if register_output_files(paths, job_id=prompt_id) > 0: - asset_seeder.enqueue_enrich(roots=("output",), compute_hashes=True) + asset_seeder.enqueue_enrich(roots=("output",), compute_hashes=True) asset_seeder.resume()