OpenHands / OpenHands/software-agent-sdk

[Feature]: Add DAG task execution (run_dag) with dependency barriers to WorkflowContext

Open
#4,894 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

agent-execution enhancement ready-for-dev
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:

  1. Accept a dictionary mapping node_id to specifications (prompt, depends_on, subagent_type, description).
  2. Run pre-flight Kahn's topological sort to detect circular dependencies or unknown parent IDs before spawning tasks.
  3. Execute tasks concurrently as soon as all upstream dependencies complete, bounded by max_concurrency.
  4. Automatically resolve upstream results into downstream prompt templates ({parent_node}) or callable prompt functions.
  5. If an upstream task fails, automatically prune downstream dependent tasks to avoid wasting LLM calls.
Acceptance Criteria
  • WorkflowContext.run_dag executes heterogeneous tasks respecting depends_on ordering.
  • Diamond dependency workflows (A -> B, C -> D) execute B and C in parallel and join at D.
  • Cyclic graphs raise a ValueError with 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.