Building a human-in-the-loop browser workflow for PhotoCraft AI
Описание и применение
В workflow для PhotoCraft AI реализована проверка таймаутов и выходных кодов, чтобы избежать повторных попыток при успешном выполнении действий, а также отдельная обработка состояния браузера и уникальных записей в базе.
Задача
Timeouts in browser automation can falsely indicate a failed action, leading to unnecessary retries and potential duplicate side effects.
Результат
The workflow now distinguishes between client-side timeouts and actual failures, preventing unnecessary retries and duplicate actions while allowing human review before publication.
Рабочий процесс
- Commit the "submitting" state before clicking the final button to mark an external attempt.
- Check both the CLI exit code and the captured output for error markers before retrying.
- Persist browser state separately and reimport it to restore markers after a restart.
- Use a database uniqueness constraint to avoid duplicate local records.
- Reconcile ambiguous outcomes by inspecting the page before deciding on a retry.
- Ensure human review occurs before publishing final fields.
- Maintain tests to verify that reimporting, restarts, timeouts, and restricted opportunities behave correctly.
Доказательства
During a local browser-automation test on macOS, a CLI click returned a timeout. The shell process still returned exit code 0. Inspection of the resulting browser state showed that the click's intended effect had occurred.
Commit submitting before clicking the final button. If the process crashes, the next run sees an unfinished external attempt rather than a fresh task.
For the CLI version used in this test, an execution wrapper checks both: if proc.returncode or "### Error" in result: raise WorkflowError...
Another local test closed and reopened Chrome with the same persistent Profile. localStorage survived, but the test cookie did not. The cause has not been isolated.
- Дата записи: 2026-10-27T16:26:25.298Z