feat: Add optional option to the flow registry
What does this merge request do and why?
Currently, the inputs defined in the flow definitions always have to be provided. This make sense for some inputs (e.g. goal, MR url for fix pipeline) but some other inputs might be optional like AGENTS.md.
This MR adds the optional ~~and default ~~keywords to the inputs. For now, default can only be a string value, but in the future we might want to allow it to reference other IOKeys.
Duo summary
This change adds support for optional inputs with default values in workflow components. Previously, all inputs were required and the system would fail if any specified data was missing. Now developers can mark inputs as optional, allowing components to gracefully handle missing data by either using a None value or a specified default value. This makes workflows more robust by preventing failures when non-critical data is unavailable, while still ensuring required inputs are validated. The feature includes comprehensive documentation with examples showing how to configure optional inputs and default values in YAML configuration files.
How to set up and validate locally
- Run a flow with a missing input (it should fail)
version: "v1"
environment: ambient
components:
- name: "test"
type: AgentComponent
prompt_id: "test_prompt"
toolset: []
inputs:
- from: "context:inputs.missing_input"
as: "foo"
ui_log_events:
- "on_agent_final_answer"
prompts:
- name: "test_prompt"
unit_primitives: []
prompt_id: "test_prompt"
prompt_template:
system: |
Do the task specified by the user
user: |
{% if foo %} ECHO {{foo}} {% else %} ECHO "BAR" {% endif %}
params:
timeout: 300
routers:
- from: "test"
to: "end"
flow:
entry_point: "test"
2. Run the same flow but with the optional input
inputs:
- from: "context:inputs.missing_input"
as: "foo"
optional: True
Merge request checklist
- Tests added for new functionality. If not, please raise an issue to follow up.
- Documentation added/updated, if needed.
- If this change requires executor implementation: verified that issues/MRs exist for both Go executor and Node executor or confirmed that changes are backward-compatible and don't break existing executor functionality.
Relates to #1662
Relates to gitlab-org/editor-extensions/gitlab-lsp!2597 (merged)