
# defines the agent

(define reflexion-agent

    (:states 
        (thought
            (:text "Thought:")
        )
        (action
            (:text "Action:")
        )
        (action-input
            (:text "Action Input:")
        )
        (observation
            (:text "Observation:")
            (:flags :env-input)
        )
        (evaluator
            (:text "Evaluation:")
            (:flags :env-input)
        )
        (reflection
            (:text "Reflection:")
        )
        (final-thought
            (:text "Final Thought:")
        )
        (answer
            (:text "Answer:")
        )
        (finish
            (:text "Generation complete!")
        )
    )
    
    (:behavior
        (until
            (next
                (until
                    (next thought action action-input observation)
                    final-thought)
                answer
                evaluator
                reflection)
            finish)
    )

)
