Building a human-in-the-loop browser workflow for PhotoCraft AI
说明与用途
PhotoCraft AI 的工作流现在通过检查 CLI 退出码和输出,避免在超时但操作成功时重试,并使用唯一数据库约束防止重复,同时单独处理浏览器状态持久化。
问题
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