Adding Control Flow Functionality to Workflows #88
Replies: 2 comments 4 replies
-
|
Hi, I found here while searching a deterministic execution of browser-use interactions. Why invent a new language while you could use existing building blocks, like python? What matters is what api will be exposed, becoming the functions that could be called using the python code. Playwright already did this and abstracted browser interaction into an api. Hence, why not arriving at creating playwright scripts from the browser-use runs? One could generate these using browser interaction history, in a consistent manner rather than asking LLM to write them. |
Beta Was this translation helpful? Give feedback.
-
|
What do you think of Jupyter notebook like format. So you can run the workflow step by step and edit it? I can launch this next week. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Current Limitations
Currently, workflow steps are recorded in JSON. While JSON is a convenient data exchange format, it lacks native control flow functionality, making it difficult to express common patterns such as:
Options
Option: AI-Generated Code
While generating code and just limiting the functions accessible would be optimal in my view, this quickly becomes complex since no current LLMs verify the generated code, AFAIK. e.g., If I prompt
"Only use functions A, B, C... while writing your code"there's no guarantee these functions 1) aren't in the code and 2) that the code is structured as I intend.Option: JSON-Based
An alternative is to add a few common control flow steps to the JSON schema since many LLMs do provide structured outputs, which can then be transformed into Python code. Users could modify either the JSON or the generated Python, depending on their preferences. This also allows for more control when a workflow pattern cannot currently be expressed in the JSON schema.
Implementation
Proposed Initial JSON Extensions
ForLoopStep/WhileLoopStepfor iterationConditionalStepforif_existsand other conditional logic{index},{item}) and scoping for dynamic executionImplementation Outline
ForLoopStep,WhileLoopStep,ConditionalStep) inviews.pyworkflows/workflow_use/codegen/generator.pyservice.pyto handle loops and contextprompts.pyservice.pyConclusion
This approach keeps the structured JSON format while enabling richer workflow logic. Let me know your thoughts.
Note
P.S., While exploring this idea, I noticed Skyvern is pursuing a similar idea, though they currently lack a browser extension recording setup and I find their documentation less up-to-date.
Beta Was this translation helpful? Give feedback.
All reactions