Skip to content

Commit

Permalink
fix(agents-api): refactor test_task_execution_workflow.py with ``…
Browse files Browse the repository at this point in the history
…$`` prefix
  • Loading branch information
Ahmad-mtos committed Jan 30, 2025
1 parent ad78f6b commit b4aa6b5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 22 deletions.
7 changes: 1 addition & 6 deletions agents-api/agents_api/workflows/task_execution/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
StepOutcome,
)
from ...common.retry_policies import DEFAULT_RETRY_POLICY
from ...common.utils.template import render_template
from ...env import (
debug,
temporal_heartbeat_timeout,
Expand Down Expand Up @@ -152,11 +151,7 @@ async def eval_step_exprs(self, step_type: WorkflowStep):
case SetStep(set=set):
expr = set
case LogStep(log=log):
output = await render_template(
input=log,
variables=await self.context.prepare_for_step(),
skip_vars=["developer_id"],
)
expr = log
case SwitchStep(switch=switch):
output: int = -1
cases: list[str] = [c.case for c in switch]
Expand Down
32 changes: 16 additions & 16 deletions agents-api/tests/test_task_execution_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ async def _():
),
)
result = await wf.eval_step_exprs(
ForeachStep(foreach=ForeachDo(in_="1 + 2", do=YieldStep(workflow="wf1")))
ForeachStep(foreach=ForeachDo(in_="$ 1 + 2", do=YieldStep(workflow="wf1")))
)

assert result == StepOutcome(output=3)
Expand Down Expand Up @@ -802,7 +802,7 @@ async def _():
),
)
result = await wf.eval_step_exprs(
IfElseWorkflowStep(if_="1 + 2", then=YieldStep(workflow="wf1")),
IfElseWorkflowStep(if_="$ 1 + 2", then=YieldStep(workflow="wf1")),
)

assert result == StepOutcome(output=3)
Expand Down Expand Up @@ -866,7 +866,7 @@ async def _():
),
)
result = await wf.eval_step_exprs(
ReturnStep(return_={"x": "1 + 2"}),
ReturnStep(return_={"x": "$ 1 + 2"}),
)

assert result == StepOutcome(output={"x": 3})
Expand Down Expand Up @@ -930,7 +930,7 @@ async def _():
),
)
result = await wf.eval_step_exprs(
WaitForInputStep(wait_for_input=WaitForInputInfo(info={"x": "1 + 2"})),
WaitForInputStep(wait_for_input=WaitForInputInfo(info={"x": "$ 1 + 2"})),
)

assert result == StepOutcome(output={"x": 3})
Expand Down Expand Up @@ -994,7 +994,7 @@ async def _():
),
)
result = await wf.eval_step_exprs(
EvaluateStep(evaluate={"x": "1 + 2"}),
EvaluateStep(evaluate={"x": "$ 1 + 2"}),
)

assert result == StepOutcome(output={"x": 3})
Expand Down Expand Up @@ -1058,7 +1058,7 @@ async def _():
),
)
result = await wf.eval_step_exprs(
MapReduceStep(over="1 + 2", map=YieldStep(workflow="wf1")),
MapReduceStep(over="$ 1 + 2", map=YieldStep(workflow="wf1")),
)

assert result == StepOutcome(output=3)
Expand Down Expand Up @@ -1121,7 +1121,7 @@ async def _():
),
),
)
result = await wf.eval_step_exprs(SetStep(set={"x": "1 + 2"}))
result = await wf.eval_step_exprs(SetStep(set={"x": "$ 1 + 2"}))

assert result == StepOutcome(output={"x": 3})

Expand Down Expand Up @@ -1183,7 +1183,7 @@ async def _():
),
),
)
result = await wf.eval_step_exprs(LogStep(log="{{_0['x']}}"))
result = await wf.eval_step_exprs(LogStep(log="$ _0['x']"))

assert result == StepOutcome(output="5")

Expand Down Expand Up @@ -1248,8 +1248,8 @@ async def _():
result = await wf.eval_step_exprs(
SwitchStep(
switch=[
CaseThen(case="None", then=YieldStep(workflow="wf1")),
CaseThen(case="1 + 3", then=YieldStep(workflow="wf2")),
CaseThen(case="$ None", then=YieldStep(workflow="wf1")),
CaseThen(case="$ 1 + 3", then=YieldStep(workflow="wf2")),
]
),
)
Expand All @@ -1260,7 +1260,7 @@ async def _():
@test("task execution workflow: evaluate tool call expressions")
async def _():
wf = TaskExecutionWorkflow()
step = ToolCallStep(tool="tool1", arguments={"x": "1 + 2"})
step = ToolCallStep(tool="tool1", arguments={"x": "$ 1 + 2"})
execution_input = ExecutionInput(
developer_id=uuid.uuid4(),
agent=Agent(
Expand Down Expand Up @@ -1325,7 +1325,7 @@ async def _():
),
)
result = await wf.eval_step_exprs(
ToolCallStep(tool="tool1", arguments={"x": "1 + 2"}),
ToolCallStep(tool="tool1", arguments={"x": "$ 1 + 2"}),
)

assert result == StepOutcome(
Expand All @@ -1340,7 +1340,7 @@ async def _():
@test("task execution workflow: evaluate yield expressions")
async def _():
wf = TaskExecutionWorkflow()
step = YieldStep(arguments={"x": "1 + 2"}, workflow="main")
step = YieldStep(arguments={"x": "$ 1 + 2"}, workflow="main")
execution_input = ExecutionInput(
developer_id=uuid.uuid4(),
agent=Agent(
Expand Down Expand Up @@ -1394,7 +1394,7 @@ async def _():
),
),
)
result = await wf.eval_step_exprs(YieldStep(arguments={"x": "1 + 2"}, workflow="main"))
result = await wf.eval_step_exprs(YieldStep(arguments={"x": "$ 1 + 2"}, workflow="main"))

assert result == StepOutcome(
output={"x": 3}, transition_to=("step", TransitionTarget(step=0, workflow="main"))
Expand All @@ -1404,7 +1404,7 @@ async def _():
@test("task execution workflow: evaluate yield expressions assertion")
async def _():
wf = TaskExecutionWorkflow()
step = step = ToolCallStep(tool="tool1", arguments={"x": "1 + 2"})
step = ToolCallStep(tool="tool1", arguments={"x": "$ 1 + 2"})
execution_input = ExecutionInput(
developer_id=uuid.uuid4(),
agent=Agent(
Expand Down Expand Up @@ -1459,4 +1459,4 @@ async def _():
),
)
with raises(AssertionError):
await wf.eval_step_exprs(YieldStep(arguments={"x": "1 + 2"}, workflow="main"))
await wf.eval_step_exprs(YieldStep(arguments={"x": "$ 1 + 2"}, workflow="main"))

0 comments on commit b4aa6b5

Please sign in to comment.