Kitchen Nightmares: LangChain Agents Edition
I built a health app to parse recipes and create meal plans.
I used FastAPI and React for the web app. I used LangChain for the agents. I used LangSmith to see what my agents were doing.
The goal was simple. A user provides a URL. The app fetches the recipe and splits it into components like mains, sides, and sauces. Users can then mix and match these to build meals or track calories.
I ran into a major problem with agent reliability.
At first, I used one agent to group the recipe and format the output. It failed constantly. It produced duplicate items. It left out instructions. It combined everything into one giant block.
I tried a dual agent setup to fix this:
- Agent 1 (Grouping): Finds the different recipe components and organizes ingredients and instructions.
- Agent 2 (Structuring): Takes that organized text and turns it into a clean JSON format.
This worked for one day. The next day, the errors returned. The structuring agent started returning JSON that missed all the ingredients and instructions.
I stopped using print statements and started using LangSmith.
LangSmith shows me latency, token usage, and cost. Most importantly, it shows me exactly where the chain breaks.
In my case, the grouping agent was working perfectly. It produced great markdown with all the details. The failure happened in the second agent. It was losing data during the transformation.
Now I am working on three fixes:
- Improve agent reliability: I noticed the structuring agent tries to guess a cuisine field that was not in the original prompt. This confusion causes errors.
- Add validation: I will use Python functions to check the output. I want to ensure the markdown is correct and there are no duplicates.
- Better observability: I want to link every agent execution to a specific user request for easier tracing.
Building with agents is not a one-time task. It is a constant loop of testing and fixing.
Source: https://dev.to/kristianroopnarine/kitchen-nightmares-langchain-agents-edition-45co
Optional learning community: https://t.me/GyaanSetuAi
