Skip to content

Commit 6c0affc

Browse files
Merge pull request #108 from ServiceNow/fix-trace-collection
Refactor cheat logic for compositional tasks
2 parents 4fa3ecc + 620c319 commit 6c0affc

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/wa_action_traces.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,15 @@ def extract_trace(task_cls, headless=True):
111111
monkey_patch_playwright(observation_callback=env._get_obs, trace_storage=trace)
112112

113113
env.reset()
114-
env.task.cheat(env.page, env.chat.messages)
115-
env.close()
114+
# For compositional tasks, we need to cheat on each subtask
115+
if hasattr(env.task, 'subtasks'):
116+
# This is a compositional task, solve each subtask
117+
for subtask_idx in range(len(env.task.subtasks)):
118+
env.task.cheat(env.page, env.chat.messages, subtask_idx)
119+
else:
120+
# This is a regular task
121+
env.task.cheat(env.page, env.chat.messages)
122+
env.close()
116123

117124
return trace
118125

0 commit comments

Comments
 (0)