feat: Allow processing of additional_context envelopes when using Flow Registry
Why do we need this change?
The Flow Registry currently doesnt have access to the additional_context, like the classic flow registry does (See CONTEXT_REGISTRY in duo_workflow_service/components/base.py).
Related Work
Rails will be passing additional context to the fix pipeline flow, as of this MR
Go Executor will be passing along additional context as of this MR
Change Summary
This MR adds a new way of specifying the additional_context_schema in the flow config file, which defines which fields the flow can accept via the additional_context field. The content is taken from this field in additional_context:
{'additional_context': [{'Category': 'agent_user_environment': 'Content': '<CONTENT HERE>'}]
The reason we are only pulling data from additional_context.agent_user_environment, is that the field agent_user_environment already passes the Unit Primitive check. When we remove this Unit Primitive check, we can remove this nesting of the data (conversation here)
How to set up and validate locally
- Setup Remote Flows
- Apply this patch: addcontext.patch
- Run this command:
curl --location 'http://gdk.test:3000/api/v4/ai/duo_workflows/workflows' \
--header 'Content-Type: application/json' \
--header "PRIVATE-TOKEN: $PAT" \
--data '{
"project_id": "$PROJECT_ID",
"goal": "test",
"workflow_definition": "fix_pipeline/experimental",
"agent_privileges": [1,2,3,4,5],
"pre_approved_agent_privileges": [1,2,3,4,5],
"start_workflow": true,
"allow_agent_to_request_user": false,
"additional_context": [{"Category": "agent_user_environment", "Content": "{\"date\": \"January 1 2021\", \"time\": \"3pm\"}"}]
}'
- Verify in Langsmith that the additional context was passed to the agent. You can see an example here
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.
Closes #1445 (closed)