Skip to content

Commit 619b140

Browse files
gabrycinaclaude
andcommitted
feat: add get_current_state workflow query to BaseWorkflow
Adds a default @workflow.query handler named "get_current_state" to BaseWorkflow. Returns a _workflow_state string that defaults to "initialized". Agents using StateMachine should override this to return the state machine's current state, enabling external callers to detect turn completion (state == "waiting_for_input"). Example override: @workflow.query(name="get_current_state") def get_current_state(self) -> str: return self.state_machine.get_current_state() Companion to scaleapi/scale-agentex#173 which adds GET /tasks/{task_id}/query/{query_name} endpoint. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent aa3aaa1 commit 619b140

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/agentex/lib/core/temporal/workflows/workflow.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,23 @@ def __init__(
1515
display_name: str,
1616
):
1717
self.display_name = display_name
18+
self._workflow_state: str = "initialized"
19+
20+
@workflow.query(name="get_current_state")
21+
def get_current_state(self) -> str:
22+
"""Query handler for the current workflow state.
23+
24+
Subclasses using StateMachine should override this to return
25+
the state machine's current state:
26+
27+
@workflow.query(name="get_current_state")
28+
def get_current_state(self) -> str:
29+
return self.state_machine.get_current_state()
30+
31+
This enables external callers to detect when the agent has
32+
finished processing a turn (state == "waiting_for_input").
33+
"""
34+
return self._workflow_state
1835

1936
@abstractmethod
2037
@workflow.signal(name=SignalName.RECEIVE_EVENT)

0 commit comments

Comments
 (0)