Adding Control Flow Functionality to Workflows #88
jackpeplinski
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
/WhileLoopStep
for iterationConditionalStep
forif_exists
and other conditional logic{index}
,{item}
) and scoping for dynamic executionImplementation Outline
ForLoopStep
,WhileLoopStep
,ConditionalStep
) inviews.py
workflows/workflow_use/codegen/generator.py
service.py
to handle loops and contextprompts.py
service.py
Conclusion
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