Skip to content

Bug: Script and sub-workflow templates fail in explicit context mode #120

@PolyphonyRequiem

Description

@PolyphonyRequiem

Bug Description

In explicit context mode, script agent args and sub-workflow input_mapping templates that reference {{ workflow.input.X }} fail with TemplateError because workflow.input is an empty dict {}, even though the inputs were correctly passed via --input.

Reproduction

workflow:
  name: explicit-script
  entry_point: detector
  context:
    mode: explicit
  input:
    work_item_id:
      type: number
      required: true
agents:
  - name: detector
    type: script
    command: pwsh
    args:
      - "-Command"
      - "Write-Output '{{ workflow.input.work_item_id }}'; exit 0"
    routes:
      - to: $end
conductor run explicit-script.yaml --input work_item_id=42

Expected: Script outputs 42
Actual: TemplateError: 'dict object' has no attribute 'work_item_id'

Root Cause

WorkflowContext.build_for_agent() in explicit mode initializes workflow.input as {} and only populates entries explicitly declared in the agent's input: list via _add_explicit_input(). Script agents and sub-workflow input_mapping templates typically don't declare workflow inputs in their input: list because they are local template renders (no LLM prompt/token cost concern).

The same {{ workflow.input.X }} template works fine in:

  • accumulate mode (default) — workflow.input is always fully populated
  • last_only mode — same
  • LLM agent prompt fields in explicit mode — if workflow.input.X is declared in the agent's input: list

Impact

Any workflow using context.mode: explicit with:

  • type: script agents whose args reference {{ workflow.input.X }}
  • type: workflow agents whose input_mapping references {{ workflow.input.X }}

...will fail at runtime with a TemplateError.

Workaround: Add workflow.input.X to the script agent's input: list, or switch to accumulate mode.

Environment

  • Conductor v0.1.9
  • Python 3.14.2
  • Windows 11

Fix

PR #119

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions