Skip to content
DeepForgeby svx
All problems
EasyNLPnlp-263

ReAct Trace Step Count

Problem

Count executable ReAct steps in a trace given as a list of lines. A step is a line starting with 'Action:' whose action text is non-empty and not 'finish' in any casing.

Return the number of such steps.

Hint

Strip each line first, and skip the final finish action.

Test cases

case 1
in: [["Thought: x","Action: search","Observation: y","Action: finish"]]
expected: 1
case 2
in: [[]]
expected: 0
case 3
in: [["Action: calc","Action: search"]]
expected: 2
case 4
in: [["Action: finish"]]
expected: 0
case 5
in: [["action: search","Action: FINISH","Action: lookup"]]
expected: 1
Starter codePython
def react_step_count(trace):
    # Your code here
    pass

5 test cases · run your code against them in the editor