OpenHands / OpenHands/software-agent-sdk
[Feature]: Add DAG task execution (run_dag) with dependency barriers to WorkflowContext
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 542
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 137
Description
Is there an existing feature request for this?
- I have searched existing issues and feature requests, and this is not a duplicate.
Problem or Use Case
In software-agent-sdk, dynamic workflow scripts run in a sandboxed AST environment where module imports (import asyncio, etc.) are forbidden. All sub-agent coordination must occur through WorkflowContext (wf).
Currently, wf provides run_agent, map_agents, pipeline, and reduce_agent. There is no built-in primitive for executing a Directed Acyclic Graph (DAG) of heterogeneous sub-agent tasks with interdependent dependencies (e.g. Task A produces an architecture specification; Tasks B and C run in parallel based on A; Task D joins B and C; Task E runs in parallel with B and C depending only on A). Without this, agents must serialize work sequentially or cannot express non-linear workflows.
Desired Behavior
Add await wf.run_dag(nodes, max_concurrency=None) to WorkflowContext:
- Accept a dictionary mapping
node_idto specifications (prompt,depends_on,subagent_type,description). - Run pre-flight Kahn's topological sort to detect circular dependencies or unknown parent IDs before spawning tasks.
- Execute tasks concurrently as soon as all upstream dependencies complete, bounded by
max_concurrency. - Automatically resolve upstream results into downstream prompt templates (
{parent_node}) or callable prompt functions. - If an upstream task fails, automatically prune downstream dependent tasks to avoid wasting LLM calls.
Acceptance Criteria
-
WorkflowContext.run_dagexecutes heterogeneous tasks respectingdepends_onordering. - Diamond dependency workflows (A -> B, C -> D) execute B and C in parallel and join at D.
- Cyclic graphs raise a
ValueErrorwith clear cycle diagnosis prior to task execution. - Downstream dependent tasks are pruned without dispatch when an upstream dependency fails.
- All tests pass under
pytest tests/tools/workflow/test_workflow_tool.py.
Alternatives Considered
Writing custom asyncio code inside the workflow script is blocked because module imports and raw concurrency primitives are restricted by the script AST sandbox.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the WorkflowContext implementation and tests in tests/tools/workflow/test_workflow_tool.py; run the existing workflow test suite first. Trace run_agent, map_agents, pipeline, and reduce_agent to understand task dispatch and result handling. Done means run_dag validates dependencies before execution, respects barriers and max_concurrency, resolves upstream results, prunes failed descendants, and passes the listed acceptance cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- ai, backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100