Skip to content

Commit 72f0ed3

Browse files
committed
Refactor task retrieval logic to improve clarity and handle completed steps correctly
1 parent ef460ec commit 72f0ed3

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

agent/my_agent/agent.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,20 @@ def get_plan(state: ReWOO):
6262
def _get_current_task(state: ReWOO):
6363
if "results" not in state or state["results"] is None:
6464
return 1
65-
if len(state["results"]) == len(state["steps"]):
65+
completed_steps = len(state["results"])
66+
if completed_steps >= len(state["steps"]):
6667
return None
6768
else:
68-
return len(state["results"]) + 1
69+
return completed_steps + 1
6970

7071

7172
def tool_execution(state: ReWOO):
7273
"""Worker node that executes the tools of a given plan."""
74+
7375
_step = _get_current_task(state)
76+
if _step is None:
77+
return state
78+
7479
step = state["steps"][_step - 1]
7580
_results = state.get("results", {})
7681

0 commit comments

Comments
 (0)