Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/conductor/engine/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1399,6 +1399,13 @@ async def _execute_loop(self, current_agent_name: str) -> dict[str, Any]:
agent.input,
mode=self.config.workflow.context.mode,
)
# Script args are rendered locally (no LLM cost), so
# workflow inputs must always be available for template
# resolution — even in explicit mode where they'd
# otherwise be filtered out.
agent_context.setdefault("workflow", {})["input"] = (
self.context.workflow_inputs.copy()
)
_script_start = _time.time()

# Count how many times this specific script has been executed
Expand Down Expand Up @@ -1491,6 +1498,12 @@ async def _execute_loop(self, current_agent_name: str) -> dict[str, Any]:
agent.input,
mode=self.config.workflow.context.mode,
)
# input_mapping templates are rendered locally (no LLM
# cost), so workflow inputs must always be available —
# even in explicit mode.
agent_context.setdefault("workflow", {})["input"] = (
self.context.workflow_inputs.copy()
)
_sub_start = _time.time()

sub_execution_count = (
Expand Down
37 changes: 37 additions & 0 deletions tests/test_engine/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,43 @@ def mock_handler(agent, prompt, context):
# Workflow.input.goal should not be in agent2's context since it's not in input list
assert "other" not in agent2_context.get("workflow", {}).get("input", {})

@pytest.mark.asyncio
async def test_explicit_mode_script_gets_workflow_inputs(self) -> None:
"""Regression: script agents in explicit mode must see workflow.input.

In explicit mode, workflow.input was empty {} for script agents that
didn't declare inputs. Script args are rendered locally (no LLM cost),
so workflow inputs must always be available for template resolution.
"""
config = WorkflowConfig(
workflow=WorkflowDef(
name="explicit-script",
entry_point="detector",
context=ContextConfig(mode="explicit"),
),
agents=[
AgentDef(
name="detector",
type="script",
command="pwsh",
args=[
"-Command",
"Write-Output '{{ workflow.input.work_item_id }}'; exit 0",
],
# No input: list — should still see workflow.input
routes=[RouteDef(to="$end")],
),
],
)

provider = CopilotProvider(mock_handler=lambda a, p, c: {})
engine = WorkflowEngine(config, provider)

await engine.run({"work_item_id": 42})

# Script should have rendered the template successfully
assert engine.context.agent_outputs["detector"]["stdout"].strip() == "42"


class TestWorkflowEngineRouting:
"""Tests for workflow routing."""
Expand Down
Loading