- The problem statement
- The solution approach
- Conclusions and References
Problem Statement
When I created the Agentic game of "Tic Tac Toe" — I was also impressed by the way in which we can create recursive agents for proviing a goal oriented solution where the state can change within the same agent. So at a certain time, the same agent might declare that the game is over and no need to recursively play another round, but on other instances, the agent might decide that game is in progress and recursively call itself.
Check the Tic-Tac-Toe Agent @ https://medium.com/p/3da646177980
The game is as below: A farmer with a wolf, a goat, and a cabbage must cross a river by boat. The boat can carry only the farmer and a single item. If left unattended together, the wolf would eat the goat, or the goat would eat the cabbage. How can they cross the river without anything being eaten?
The idea of this agentic solution is to make the game a bit more complex with a few things:
- Introduce a rule engine to add the rules of the game
- Introduce a reasoning engine to continuously evaluate the rules
- The agentic framework that can call itself based on state of the game.
- The guardrails that can help play the game without derailing
Without much ado, lets get started.
Solution:
The solution starts with the usual Agent Marketplace where we can choose the new agent we want to play with. I added this agent right below the previous 'tic-tac-toe' agent.

Next, I start by saying — Hi (a typical greeting for a informal natural language interaction with a system).
In this case, the system recognizes my greeting and provides a very natural way to the next step. This is the start of the agentic workflow. See how smooth the Human-System-Human interaction is in this case. I feel like I am having a very natural/ organic progression of the game.
The system tells me that currently it has only 1 game I can play. The Wolf, Goat, Cabbage Puzzle.

Next, I mention that I want to play the puzzle, so I put that as my request. Once I do that, the agent guides me through the game and provides a very specific set of questions.
See how instead of me trying to put some values, this is driven by System, the system is guiding me as what is my next step and I am only responding. It feels very smooth and intuitive.
The system here asks me to fill in 2 things — which item (between wolf, cabbage and goat) I need to move to the destination river bank and which one I need to bring back to the source back as part of my round trip (the player, which is me in this case is the Farmer).

Next, I provide a partial answer. I only provide the details of who I will carry to the destination bank. See how in this case, the system is asking me to provide the person I need to carry back ? The agent has complete control of the state and does not execute the rules and the reasoning engine yet. It just tells me that I still need to provide more entry. This is the guardrails and state management I was talking about which makes Agentic solutions great.

Now, I specify that I do not want to bring anyone back to source river bank in this trip by specifying NA. Now the agent executes the reasoning engine and the rules engine to know the game state and I can see the result (nice touch right :-) ).
The system tells me that th egame state is in progress, the reasining engine gives me a reason and I get next step (the recursive call) to keep playing.

In the next round, I wanted to throw off the game and say that I want to move the crocodile to the destination river bank. There is no crocodile and hence, the system prompts me back to play correctly. This also proves that I cannot just hijack the rules of the game.

Next, the game is taking some serious turns, I specify that I will move the wolf to the destination and move the goat to the source. After the reasoning engine execution it confirms that I can keep playing and I can see the response.

In my next move, I put the cabbage to destination river bank and keep the goat to the source bank.

Finally, I move the goat to destination. The reasoning engine suggests that. have won the game and as it is an end state, it declares the game to be over and no more resursive calls.

Conclusion & References
This was a quick blog and approach on how to design and implement a Gen AI driven recursive agent. This is a work in progress and stay tuned on more capabilities I will be adding in future.
To learn more on agentic use cases which I wrote, check below:
Now, I have been working on Agents for quite a while now, below are some of the agentic use cases I implemented, I will mention these cases for your reference:
- Overview of the whole 'agentic solution' @ https://medium.com/@nayan.j.paul/implementing-llm-and-gen-ai-applications-using-the-world-of-llm-agents-37fab8889bd3
- Goal based agent development @ https://medium.com/@nayan.j.paul/how-i-designed-a-tic-tac-toe-agent-in-a-multi-agent-setup-with-llm-and-gen-ai-3da646177980
- Exploratory Data Analysis using collection of agents @ https://medium.com/@nayan.j.paul/designing-exploratory-analysis-agent-with-gen-ai-large-language-models-llms-61310a1cd60f
- Designing hypothesis testing and pattern analysis agents @ https://medium.com/@nayan.j.paul/designing-hypothesis-analysis-agent-with-gen-ai-large-language-models-llms-a09aaf7016d4
- Designing a supply chain simulation modelling @ https://medium.com/@nayan.j.paul/designing-simulation-modeling-agents-using-gen-ai-large-language-models-llms-ed12f462c3f2
- Multi turn use case for car order placement @ https://medium.com/@nayan.j.paul/multi-turn-goal-based-agents-with-large-language-models-with-practical-use-case-49a78fcc79c4
- Scheduling assistant @ https://medium.com/@nayan.j.paul/designing-scheduling-assistant-agent-using-gen-ai-large-language-models-llms-7799d882ee6e
Do reach out to me on linkedin for 1–1 for discussions and exchange of ideas.
