-
Notifications
You must be signed in to change notification settings - Fork 342
Feature - Dynamic Agent #327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Add conditional message reordering for mixed content (text + images) - Preserve original order for pure tool responses to maintain references - Ensure OpenAI's required message sequence is maintained Fixes evalstate#314
- Added test_openai_tool_validation_fix.py with 3 test scenarios: 1. Parallel tool calls with mixed content ordering 2. OpenAI validation error prevention 3. Single mixed content tool validation - Added mixed_content_server.py MCP server to reproduce issue scenario - Moved tests to multimodal directory (appropriate for text+image content) - Updated fastagent.config.yaml files accordingly Tests validate the fix for OpenAI API validation errors that occurred during parallel tool calls when one tool returns mixed content.
Implement dynamic agents that can be created at runtime by other agents, enabling adaptive team composition and specialized task delegation. Key Features: - Create specialized agents on-the-fly during execution - Each agent has its own context, memory, tools, and prompt - Parallel execution for efficient team coordination - Lifecycle management (create, communicate, terminate) - MCP server and tool access control - Console display with agent tree visualization - Usage tracking and performance monitoring Use Cases: - Project management with specialized development teams - Code review teams with different expertise areas - Content creation with writers, editors, and reviewers - Data analysis with collectors, processors, and visualizers
- Organize imports alphabetically and group properly - Remove unused imports (typing.Any, TextContent, PromptMessageMultipart, etc.) - Fix import formatting across all example files - Ensure compliance with project code style guidelines
model: Optional[str] = None | ||
|
||
|
||
class DynamicAgentInfo(BaseModel): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already use the AgentCard (from the A2A framework) to describe Agents and Tools for Router/Orchestrator. Would it be possible to standardize on this type? And we have serialization routines for this (I think... check the router/orchestrator)
src/mcp_agent/agents/base_agent.py
Outdated
content=[TextContent(type="text", text=formatted)] | ||
) | ||
|
||
elif name == f"{DYNAMIC_AGENT_TOOL_PREFIX}_list": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have a think whether this would be best injected as part of the instructions/early messages? Rather than in a Tool Call. The text that describes the available agents doesn't need to be hidden behind a tool call. (Would consider this)
src/mcp_agent/agents/base_agent.py
Outdated
content=[TextContent(type="text", text=response)] | ||
) | ||
|
||
elif name == f"{DYNAMIC_AGENT_TOOL_PREFIX}_broadcast": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If were super-super MCP minded, we would set up a Resource Subscription for this. (This will add work for little benefit).
- Update dynamic_agent_manager.py to import from fast_agent.agents.agent_types - Update test_dynamic_agent_manager.py to import from fast_agent.agents.agent_types - All 19 dynamic agent tests now pass successfully - Resolves import errors caused by package restructuring in main branch
Addresses feedback to use existing AgentCard type instead of custom DynamicAgentInfo. Changes: - Replace DynamicAgentInfo class with create_dynamic_agent_card() function - Use AgentCard from a2a.types for consistency with router/orchestrator - Convert server access, status, and usage info into AgentSkill objects - Update list_agents() method to return List[AgentCard] instead of List[DynamicAgentInfo] - Update all tests to work with new AgentCard structure - Maintain all original functionality while using standardized types Benefits: - Consistency with existing codebase architecture - Access to existing serialization routines (model_dump_json) - Better integration with router/orchestrator components - Future-proof compatibility with A2A framework All 20 tests pass successfully.
#326
[https://drive.google.com/file/d/1Hrl2tHw_NfJNRfuuimOctbOh2Co_CjCo/view?usp=sharing](Video Preview)