October 22, 2025 8 min read Codecutter Team

Building AI Agents: Successes, Failures, and Lessons Learned

Our journey creating AI agents for email processing. The proofreader agent worked flawlessly, while the games agent taught us valuable lessons about prompt engineering and state management.

AI/ML Development Lessons Learned

When we set out to build AI agents for email processing, we expected challenges. What we didn't anticipate was how dramatically different the outcomes would be between our two agents: a proofreader that worked flawlessly from day one, and a games agent that taught us hard lessons about the complexities of state management and prompt engineering.

The Challenge: Email Parsing at Scale

Our initial approach to building email-based AI agents relied on traditional parsing techniques. We used regex patterns, string matching, and structured data extraction to understand user intent and maintain game state. This worked reasonably well for simple cases, but quickly became brittle when faced with the reality of how users actually write emails.

The Problem: Users create a variety of email structures that are impossible to code for all eventualities. Natural language is inherently unpredictable, making traditional parsing approaches fundamentally flawed.

Why Traditional Parsing Failed

Our brittle parsing patterns included:

  • Game State Extraction: Regex patterns to find game state sections with specific emoji and formatting
  • Move Parsing: Multiple regex patterns for different game types (hangman letters, chess moves, checkers moves)
  • State Parsing: Simple key-value parsing that broke with formatting variations
  • Input Extraction: Complex regex patterns that failed with natural language variations

Each new user email format required new parsing rules, creating a maintenance nightmare and limiting the system's ability to handle natural language variations.

The Solution: LLM-Based Parsing

We pivoted to a comprehensive LLM-based solution that handles all parsing and state management. The key insight was to let the LLM do what it does best: understand natural language and extract structured information from unstructured text.

The Solution: Pass the entire email to the LLM for parsing, let it draft appropriate responses, and manage state for the next interaction. Most of the intelligence is in the prompt engineering.

Our LLM-Based Architecture

The new approach uses a single LLM call that:

  • Parses the incoming email to understand user intent
  • Extracts current game state from the email content
  • Processes the user's move or request
  • Updates the game state appropriately
  • Generates a natural language response
  • Embeds the new state in the response for the next interaction

Two Very Different Outcomes

The Proofreader Agent: A Resounding Success

Our proofreader agent worked flawlessly from the first implementation. This agent has no state to maintain - it simply receives an email, processes the text for grammar and style improvements, and returns the corrected version.

Why it succeeded:

  • Stateless operation: No complex state management required
  • Clear input/output: Text in, improved text out
  • Well-defined task: Grammar and style correction is a well-understood problem
  • No user interaction complexity: No need to parse user intent or maintain conversation context

The Games Agent: Lessons in Complexity

The games agent, on the other hand, presented significant challenges. This agent needs to:

  • Maintain game state across multiple email interactions
  • Parse user moves from natural language
  • Validate moves according to game rules
  • Generate appropriate responses based on game state
  • Handle edge cases and error conditions

Key challenges we encountered:

  • State consistency: Ensuring game state remains consistent across interactions
  • Move validation: Parsing and validating user moves from natural language
  • Error handling: Gracefully handling invalid moves or unclear instructions
  • Prompt engineering: Creating prompts that reliably produce consistent, accurate responses

Lessons Learned

1. Stateless vs. Stateful Agents

The fundamental difference between our two agents highlights a critical design consideration: stateless agents are significantly easier to implement and maintain than stateful ones.

"The proofreader agent's success comes from its simplicity: it processes each email independently without needing to remember previous interactions. The games agent's complexity comes from its need to maintain and update state across multiple interactions."

2. The Importance of Prompt Engineering

For the games agent, prompt engineering became the critical success factor. The quality of the prompts directly determines:

  • Accuracy of state parsing
  • Consistency of move validation
  • Quality of generated responses
  • Reliability of state management

3. Natural Language Understanding

Traditional parsing approaches fail because they can't handle the natural variation in how users express themselves. LLM-based parsing succeeds because it can understand intent even when the exact wording varies.

4. Error Handling and Edge Cases

The games agent revealed the importance of comprehensive error handling. Users don't always follow expected patterns, and the system needs to gracefully handle:

  • Ambiguous moves
  • Invalid game states
  • Unclear instructions
  • Multiple requests in a single email

Implications for Enterprise AI

This experience has important implications for enterprise AI implementations:

Start Simple

Begin with stateless agents that perform well-defined tasks. These provide immediate value while building experience with LLM integration and prompt engineering.

Invest in Prompt Engineering

For complex, stateful agents, prompt engineering is not optional - it's the core of the system. Invest significant time in developing, testing, and refining prompts.

Plan for Complexity

Stateful agents introduce significant complexity. Ensure you have the resources and expertise to handle the additional challenges they present.

Test Extensively

LLM-based systems can behave unpredictably. Comprehensive testing with real-world data is essential to ensure reliability and consistency.

Key Insight: The success of AI agents depends more on thoughtful design and prompt engineering than on the underlying LLM technology. The technology is powerful, but it requires careful orchestration to work reliably.

Next Steps

Our experience with the games agent has taught us that stateful AI agents require significantly more work on prompt engineering and error handling. We're now focusing on:

  • Developing more robust prompt templates
  • Implementing comprehensive error handling
  • Creating better state validation mechanisms
  • Building more sophisticated testing frameworks

The proofreader agent continues to work flawlessly, demonstrating that well-designed stateless agents can provide immediate value with minimal complexity.

Conclusion

Building AI agents has been a journey of contrasts. The proofreader agent's immediate success showed us the power of LLM-based processing for well-defined tasks. The games agent's challenges taught us valuable lessons about the complexity of stateful systems and the critical importance of prompt engineering.

For organizations considering AI agent implementation, our experience suggests starting with simple, stateless agents that can provide immediate value while building expertise in LLM integration and prompt engineering. More complex, stateful agents are possible, but they require significant investment in design, testing, and ongoing refinement.

About Codecutter

Codecutter provides elite advisory services for Private Equity and C-suite leaders, bridging the gap between high-stakes M&A, investment strategy, and deep technology expertise.

Get in touch

Related Articles

Email Server Security: Lessons from the Front Lines

Setting up an email server reveals the harsh reality of internet security. Within hours of opening the firewall, automated scanners were already probing for vulnerabilities.

Read More

The Power of "Vibe Coding" with Cursor

How AI-assisted development with Cursor transformed our productivity. The combination of natural language prompts and intelligent code generation creates a new paradigm.

Read More