adk-docs
adk-docs copied to clipboard
docs: add Agent Instruction Anti-Patterns guide
Summary
Add comprehensive documentation identifying common agent instruction anti-patterns and providing proven solutions. This guide addresses community-reported issues with HITL (Human-in-the-Loop) patterns and autonomous polling instructions.
Problem Addressed
Based on analysis of GitHub issues #3607, #3645, and #3184, developers are struggling with:
- Agent instructions that create polling loops, increasing inference costs by ~93%
- Poor user experience from manual "continue" clicking in HITL scenarios
- Confusion about when to use different HITL patterns
- Lack of guidance on proper agent instruction architecture
Key Features
- Identifies autonomous polling anti-patterns that violate LLM stateless principles
- Documents Backend Blocking Poll pattern as the proven solution used in ADK framework
- Provides decision matrix for choosing appropriate HITL approaches
- Includes validated code examples cross-referenced with ADK codebase samples
- Covers instruction overloading and separation of concerns best practices
Validation
All patterns and solutions have been validated against:
/contributing/samples/human_in_loop/- Complete HITL example implementation/contributing/samples/human_tool_confirmation/- Tool confirmation patterns/src/google/adk/tools/long_running_tool.py- Framework-level anti-polling protection/src/google/adk/flows/llm_flows/functions.py- Async execution patterns
Impact
This documentation fills a critical gap identified in community discussions, providing:
- Cost reduction by preventing inefficient polling patterns
- Better UX through proper async HITL implementation
- Clear guidance for developers on instruction best practices
- Framework alignment with ADK's event-driven architecture
Testing
- ✅ Markdown syntax validated
- ✅ Navigation structure updated in mkdocs.yml
- ✅ Examples cross-referenced with working ADK samples
- ✅ Links to GitHub issues verified
The guide provides immediately actionable guidance for ADK developers building production agent systems.