= decoder.raw_decode(actions.strip()) responses.append(response) next_idx = actions.find('{', idx) if next_idx == -1: break actions = actions[next_idx:] agent_actions = [ AgentAction(response["action"], response["action_input"], text) for response in responses ] return agent_actions[0] if len(agent_actions) == 1 else agent_actions