taskflow icon indicating copy to clipboard operation
taskflow copied to clipboard

[feat] support loading `task` instructions from external files

Open natural opened this issue 3 months ago • 0 comments

Feature request: support loading task instructions from external files

What problem does this solve? Long, complex, or reusable task instructions are awkward to maintain as inline strings inside flow definitions. Flow JSON/TS files become harder to read, review, and diff when a task field runs to many paragraphs, and the same instruction text often needs to be duplicated across multiple flows or maintained by non-engineers (e.g. prompt writers) who shouldn't need to touch the flow structure itself.

Current workaround Keeping the full instruction inline in the task string, which makes the flow definition noisy and hard to skim, and copy-pasting the same instruction text into other flows that need it, with no single source of truth to update.

Proposed solution

  • DSL syntax: a taskFile field as an alternative to task on phases that currently accept task, e.g.:
{
  "id": "review",
  "type": "agent",
  "agent": "security-reviewer",
  "taskFile": "prompts/security-review.md",
  "final": true
}

Details to work out: whether taskFile supports interpolation (e.g. {args.promptPath}) like context does; whether the path resolves relative to the flow definition's directory (consistent with scriptCwd: "flow") or the run's cwd; whether task and taskFile are mutually exclusive with a validation error if both are set.

Alternatives considered

A lighter alternative that avoids adding a new field or file-lookup mechanism: support YAML as an authoring format for flow definitions (alongside the existing JSON/TS surfaces), so task can use YAML's block scalars (|/>) for long instructions while keeping everything in one file:

name: review
phases:
  - id: review
    type: agent
    agent: security-reviewer
    task: |
      Review every changed file under {args.dir} for security risks.
      Pay particular attention to:
        - authentication and authorization checks
        - unvalidated input reaching sinks
        - hardcoded secrets or credentials
      Return a prioritized summary.
    final: true

This keeps the "one flow, one file" model intact — no external prompt files to keep in sync, no path-resolution questions — and would compile to the same FlowIR as the JSON/TS surfaces, i.e. just another authoring surface. It solves readability for a single flow's own long instructions but doesn't address cross-flow reuse the way taskFile would; the two aren't mutually exclusive.

Is this a good fit?

  • [x] It's an orchestration concern (not a subagent / model / prompting concern)
  • [x] It fits the declarative JSON-DSL model (not imperative scripting)
  • [x] It doesn't require new runtime dependencies (YAML parsing would be the one addition to weigh for that alternative)

natural avatar Aug 19 '26 09:08 natural