Skip to content

Conversation

@ParthSingh0506
Copy link

Summary

Adds a complete LangGraph + Google Gemini integration example demonstrating APO (Automatic Prompt Optimization) training.

Features

  • LangGraph integration with Google Gemini 2.5 Flash (non-OpenAI LLM)
  • Bulletproof placeholder handling to prevent KeyErrors from APO's creative prompt generation
  • Persistent training result storage (JSON, TXT, PKL formats)
  • Windows compatibility fixes for path handling
  • Comprehensive README with installation, troubleshooting, and customization guides

What's Included

  • agent_train.py - Complete training script with news agent + APO setup
  • README.md - Detailed setup instructions and troubleshooting
  • requirements.txt - All Python dependencies
  • .env.example - API key configuration template
  • .gitignore - Prevents accidental secret commits

Problem Solved

This example addresses common issues developers face when integrating LangGraph with Agent Lightning:

  1. KeyError on unexpected placeholders - APO's GPT-4 editor creates prompts with placeholders beyond {query}, causing runtime errors
  2. Infinite training loops - Missing beam_rounds parameter causes training to run indefinitely
  3. Lost optimization results - Incorrect prompt extraction methods lose the optimized prompt

Testing

Tested on:

  • ✅ Windows 11 with Python 3.12
  • ✅ Standard pip + venv workflow
  • ✅ Successfully completes 3 training rounds
  • ✅ Produces optimized prompt with improved validation scores

Related

This example fills a gap in the current examples - there are no LangGraph integrations or non-OpenAI LLM examples in the repository yet.

Note: I'm writing a companion blog article with a detailed walkthrough that
can serve as additional community documentation.

- Demonstrates LangGraph integration with Google Gemini
- Includes bulletproof placeholder handling for APO
- Adds persistent training result storage
- Provides Windows compatibility fixes
- Comprehensive README with troubleshooting
@ParthSingh0506
Copy link
Author

@microsoft-github-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant