MCPcopy Create free account
hub / github.com/Virtual-Protocol/virtuals-python / step

Method step

src/virtuals_sdk/game/worker.py:123–159  ·  view source on GitHub ↗

Execute the next step in the task - requires a task ID (i.e. task ID)

(self)

Source from the content-addressed store, hash-verified

121 return ActionResponse.model_validate(response)
122
123 def step(self):
124 """
125 Execute the next step in the task - requires a task ID (i.e. task ID)
126 """
127 if not self._submission_id:
128 raise ValueError("No task set")
129
130 # get action from GAME API (Agent)
131 action_response = self._get_action(self._function_result)
132 action_type = action_response.action_type
133
134 print(f"Action response: {action_response}")
135 print(f"Action type: {action_type}")
136
137 # execute action
138 if action_type == ActionType.CALL_FUNCTION:
139 if not action_response.action_args:
140 raise ValueError("No function information provided by GAME")
141
142 self._function_result = self.action_space[
143 action_response.action_args["fn_name"]
144 ].execute(**action_response.action_args)
145
146 print(f"Function result: {self._function_result}")
147
148 # update state
149 self.state = self.get_state_fn(self._function_result, self.state)
150
151 elif action_response.action_type == ActionType.WAIT:
152 print("Task completed or ended (not possible)")
153 self._submission_id = None
154
155 else:
156 raise ValueError(
157 f"Unexpected action type: {action_response.action_type}")
158
159 return action_response, self._function_result.model_copy()
160
161 def run(self, task: str):
162 """

Callers 1

runMethod · 0.95

Calls 2

_get_actionMethod · 0.95
executeMethod · 0.80

Tested by

no test coverage detected