Files
kandev/apps/backend
João Salavisa 450c89285e fix(orchestrator): stop duplicating workflow auto-start prompt on boot-ready drain (#1160)
* fix(orchestrator): stop duplicating workflow auto-start prompt on boot-ready drain

When a workflow auto-start prompt failed transiently and was queued by the
retry branches in autoStartStepPrompt, the boot_ready drain later re-inserted
the same user message because executeQueuedMessage always called
CreateUserMessage — producing the two identical Merge prompts observed when
an ACP session resumed after going idle.

Tag the queued message with user_message_recorded when recordAutoStartMessage
has already run before the queue, and have executeQueuedMessage skip its
chat-history insert when the flag is set. The early-busy queue path
(queueAutoStartPromptIfRunning) still queues without the flag so the drain
side keeps owning the record for that path.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* fix(orchestrator): propagate recordAutoStartMessage result and tighten else-if guard

recordAutoStartMessage now returns bool (true = chat row successfully
inserted). Both queueAutoStartPrompt call sites in autoStartStepPrompt
pass the return value instead of hardcoded true, so user_message_recorded
is only stamped true when CreateUserMessage actually succeeded. A silently
swallowed DB write failure no longer stamps the flag, letting
executeQueuedMessage fall back to inserting the message on drain.

Also scope the debug-log else-if to s.messageCreator != nil so it only
fires when a CreateUserMessage attempt would otherwise have been made.

---------

Co-authored-by: Kandev Agent <agent@kandev.dev>
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-29 20:13:49 +01:00
..