A sophisticated AI agent built with Google's Agent Development Kit (ADK) that can morph into any specialized agent based on user input. The agent can transform itself into experts, characters, tools, or any other specialized role you desire.
- Transform into any specialized agent (expert, character, tool, etc.)
- Multiple morphing sessions in a single conversation
- Comprehensive agent persona creation with personality, expertise, and communication style
- Persistent session state across morphing cycles
- Agent history tracking
- Morph count and role tracking
- Automatic state persistence
- External API Integration: Simulated API calls for gathering information
- State Management: Save and restore agent states
- Reset Capability: Return to base state for new morphing
- Capability Querying: Check current agent capabilities
- Graceful Exit: Personalized goodbye with session summary
- Welcome new users with capability explanation
- Confirmation before morphing
- Special commands:
reset,morph again,exit,goodbye - Extended conversation loops (up to 20 iterations)
- Python 3.9+
- Google ADK installed:
pip install google-adk - Google AI API access (for Gemini models)
-
Clone or download this project
-
Install dependencies:
pip install google-adk
-
Set up environment variables (create a
.envfile):GOOGLE_API_KEY=your_google_api_key_here
# Run in terminal mode
adk run anygent
# Run with web UI
adk web anygent
# Run API server
adk api_server anygentfrom anygent.agent import root_agent
# Use the root_agent in your ADK application- New users receive a warm welcome and explanation of capabilities
- Agent explains it can morph into any specialized role
- Agent prompts user to describe desired specialization
- User can specify role, expertise, personality, or any combination
- Agent asks for confirmation before morphing
- User can modify or proceed with the transformation
- Agent searches for relevant information using external APIs
- Creates comprehensive agent persona including:
- Role and expertise
- Personality traits
- Communication style
- Key capabilities
- Interaction guidelines
- Agent operates as the specialized persona
- Responds to queries in character
- Maintains role consistency throughout conversation
- Tracks morphing history
- Counts number of transformations
- Saves state for persistence
User: "I want you to become a Python programming expert"
Agent: "I'll morph into a Python programming expert for you. Would you like me to proceed?"
User: "yes"
Agent: [Morphs into Python expert with comprehensive knowledge]
User: "How do I implement a decorator pattern in Python?"
Agent: [Responds as Python expert with detailed explanation]
User: "Become a wise old wizard from a fantasy world"
Agent: "I'll transform into a wise old wizard for you. Shall I proceed?"
User: "yes"
Agent: [Morphs into wizard character with mystical personality]
User: "Tell me about the ancient magic"
Agent: [Responds in wizard's mystical, wise tone]
User: "reset"
Agent: [Returns to base state]
User: "Become a travel agent"
Agent: [Morphs into travel agent]
User: "What's the best time to visit Paris?"
Agent: [Responds as travel agent]
User: "morph again"
Agent: [Returns to base state for new morphing]
resetormorph again: Return to base state for new morphingexitorgoodbye: End session with personalized thank youcapabilities: Check current agent capabilities and tools
- WelcomeAgent: Greets new users and explains capabilities
- SpecializationPromptAgent: Prompts for desired specialization
- MorphConfirmationAgent: Confirms morphing decision
- MorphingAgent: Creates specialized agent persona
- SpecializedAgent: Operates as the morphed agent
- ThankYouAgent: Provides personalized goodbye
call_external_api: Gathers information for morphingsave_agent_state: Persists agent statereset_agent: Returns to base stateexit_with_thanks: Graceful session terminationget_agent_capabilities: Shows current capabilities
The agent maintains several state variables:
user_specialization: Desired agent rolemorphed_agent_description: Created agent personaagent_history: Session historymorph_count: Number of transformationscurrent_role: Current agent state
You can extend AnyGent by adding new tools to the specialized_agent:
def my_custom_tool(tool_context: ToolContext):
# Your custom tool logic
return {"result": "custom response"}
# Add to specialized_agent tools list
specialized_agent = LlmAgent(
# ... other parameters
tools=[exit_with_thanks, reset_agent, get_agent_capabilities, call_external_api, my_custom_tool],
)You can customize AnyGent's behavior by modifying the instructions in each sub-agent:
welcome_agent = LlmAgent(
# ... other parameters
instruction="Your custom welcome message and instructions",
)- API Key Issues: Ensure your Google API key is properly set
- Model Access: Verify you have access to the specified Gemini model
- State Persistence: Check that session state is being maintained properly
Enable debug logging by modifying the logging level:
logging.basicConfig(level=logging.DEBUG)Feel free to enhance AnyGent by:
- Adding new tools and capabilities
- Improving the morphing logic
- Enhancing state management
- Adding new agent types or specializations
This project is open source and available under the MIT License.
Built with Google's Agent Development Kit (ADK) - A flexible and modular framework for developing and deploying AI agents.