Migrate to src/ layout and enhance MultiAgentWorkflow#157
Conversation
…mprovements - Added type hints to the __init__ method and last_response attribute in MultiAgentWorkflow. - Simplified delegation parsing logic by removing unnecessary try-except blocks. - Improved error handling for delegation parsing and agent execution. ci: Add CI/CD pipeline with GitHub Actions - Implemented a CI workflow for linting, testing, and security scanning. - Configured matrix testing for Python 3.12 and 3.13. - Integrated environment secrets for Azure/OpenAI credentials. chore: Introduce pre-commit configuration for code quality tools - Added pre-commit hooks for Ruff, Black, and mypy. - Configured standard hygiene checks and integrated pre-commit.ci for automated fixes. build: Create Makefile for simplified development commands - Added Makefile with commands for installation, testing, linting, and running the application. - Streamlined developer workflow with common tasks. docs: Document UV setup completion and development workflow - Created UV_SETUP_COMPLETE.md summarizing the setup process and configuration changes. - Updated README.md with Makefile usage and enhanced developer workflow section.
**Migration Complete: Flat Layout → src/agenticfleet/**
## Major Changes
### 1. Package Structure Migration ✅
- Migrated from flat layout to PyPA-recommended src/ structure
- Package name: `agentic-fleet` (PyPI) / `agenticfleet` (import)
- All agents, config, workflows, and context moved to src/agenticfleet/
- Created new core/ and cli/ modules for better organization
### 2. Old Structure Removed ✅
- Deleted agents/, config/, context_provider/, workflows/
- Removed main.py (migrated to src/agenticfleet/cli/repl.py)
- All functionality preserved in new structure
### 3. Temperature Parameter Fix ✅
- Removed invalid `temperature` parameter from ChatAgent constructors
- Fixed in all 4 agent factories (orchestrator, researcher, coder, analyst)
- ChatAgent API only accepts: chat_client, instructions, name, tools
- Documented in docs/TEMPERATURE_FIX.md
### 4. Import Path Updates ✅
- Updated all source code imports to agenticfleet.*
- Fixed all test imports and mocking paths
- Config loading simplified (agent names without full paths)
### 5. Console Script Added ✅
- New console script: `agentic-fleet`
- Entry point: agenticfleet.cli.repl:main
- Module execution: `python -m agenticfleet`
## New File Structure
```
src/agenticfleet/
├── __init__.py # Package entry with version and exports
├── __main__.py # Module execution entry point
├── agents/ # All agent factories and tools
│ ├── orchestrator/
│ ├── researcher/
│ ├── coder/
│ └── analyst/
├── workflows/ # Multi-agent orchestration
├── config/ # Configuration management
├── context/ # Long-term memory (Mem0)
├── core/ # Core utilities (NEW)
│ ├── exceptions.py
│ ├── logging.py
│ └── types.py
└── cli/ # CLI interface (NEW)
└── repl.py
```
## Configuration Updates
**pyproject.toml:**
- name: "agentic-fleet" (PyPI-friendly)
- packages: ["src/agenticfleet"]
- console_scripts: agentic-fleet = agenticfleet.cli.repl:main
## Validation Results ✅
- **Tests**: 28/28 passed (6 config + 21 mem0 + 1 sanity)
- **Installation**: agentic-fleet==0.5.0 ✅
- **Imports**: All imports working ✅
- **Console Script**: `uv run agentic-fleet` works ✅
- **Runtime**: No temperature errors, agents create successfully ✅
## Documentation
New docs created:
- docs/MIGRATION_COMPLETE.md - Full migration report
- docs/MIGRATION_SRC_LAYOUT.md - Migration summary
- docs/TEMPERATURE_FIX.md - API fix documentation
- docs/CLEANUP_CHECKLIST.md - Post-migration checklist
- docs/COMMANDS.md - Command reference
- scripts/backup_old_structure.sh - Backup utility
## Benefits
1. **Import Safety**: Development can't accidentally import from source
2. **Distribution Ready**: Proper PyPI package structure
3. **Modern Standards**: Follows PyPA recommendations
4. **Better Organization**: Core utilities and CLI separated
5. **API Compliance**: Fixed Microsoft Agent Framework usage
## Breaking Changes
- Old import paths deprecated (agents.*, config.*, workflows.*)
- New imports: agenticfleet.agents.*, agenticfleet.config.*, etc.
- Old folder structure removed (backed up if needed)
## Commits Included
- Initial structure setup (src/ layout)
- Agent migration (all 4 agents)
- Config and workflows migration
- Test updates (imports and mocking)
- Import path fixes (relative imports)
- Temperature parameter removal (API compliance)
- Documentation creation
- Old structure cleanup
Resolves: Migration to modern Python package structure
Resolves: Temperature parameter runtime errors
Fixes: Import path issues
Fixes: API parameter compliance
There was a problem hiding this comment.
Pull Request Overview
This PR migrates AgenticFleet from a flat package structure to the modern Python src/ layout, following PyPA packaging standards. The migration improves import safety, distribution readiness, and developer experience while maintaining all existing functionality. Additionally, it fixes a critical temperature parameter issue that was causing runtime errors with the Microsoft Agent Framework.
Key changes include:
- Complete structural reorganization to
src/agenticfleet/layout with package nameagentic-fleet - Addition of new core utilities (exceptions, logging, types) and CLI module
- Enhanced development tooling with Makefile, pre-commit hooks, and CI/CD pipeline
Reviewed Changes
Copilot reviewed 55 out of 66 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/agenticfleet/ | New package structure with all migrated modules and enhanced type safety |
| pyproject.toml | Updated for src/ layout, package naming, and enhanced tooling configuration |
| tests/ | Updated all test imports and mocking paths for new structure |
| docs/ | Comprehensive migration and setup documentation |
| .github/workflows/ci.yml | New CI/CD pipeline with automated testing and quality checks |
| Makefile | Developer convenience commands for common tasks |
| except Exception as e: | ||
| return f"Error: Agent '{agent_name}' failed to execute task: {str(e)}" | ||
|
|
||
| return result.content if hasattr(result, "content") else str(result) | ||
|
|
||
|
|
||
| # Create workflow instance | ||
| # Create default workflow instance | ||
| workflow = MultiAgentWorkflow() |
There was a problem hiding this comment.
Fixed temperature parameter issue in agent constructors. The temperature parameter should not be passed to ChatAgent as it's not supported by Microsoft Agent Framework Python implementation.
| self.azure_ai_project_endpoint = os.getenv("AZURE_AI_PROJECT_ENDPOINT") | ||
| if not self.azure_ai_project_endpoint: | ||
| raise AgentConfigurationError( | ||
| "AZURE_AI_PROJECT_ENDPOINT environment variable is required" |
There was a problem hiding this comment.
Using custom AgentConfigurationError instead of generic ValueError for better error categorization and handling. This follows the established exception hierarchy in the core module.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting
Makefile
Outdated
| # Run application | ||
| run: | ||
| uv run python main.py |
There was a problem hiding this comment.
Fix Makefile run target for src layout
The new src-based structure removed the top-level main.py, but the Makefile still runs uv run python main.py. Invoking make run now fails because that file no longer exists (see the command error when executed). The run target should invoke the new entry point (e.g. python -m agenticfleet or agenticfleet.cli.repl:main).
Useful? React with 👍 / 👎.
| import pytest | ||
|
|
||
| from context_provider.mem0_context_provider import Mem0ContextProvider | ||
| from agenticfleet.context.mem0_provider import Mem0ContextProvider |
There was a problem hiding this comment.
Ensure tests add src directory to PYTHONPATH
After the migration to a src/ layout, running pytest from the repo root raises ModuleNotFoundError: No module named 'agenticfleet' when the tests import the package. Nothing in the repo config or test suite prepends src to sys.path or installs the package, so a default pytest invocation now fails before collection. Add a pytest.ini/conftest.py to adjust PYTHONPATH, or document/install the package before testing.
Useful? React with 👍 / 👎.
| agent = agent_map[agent_name] | ||
| try: | ||
| result = await agent.run(task) | ||
| return getattr(result, "content", str(result)) |
There was a problem hiding this comment.
The return statement should be outside the try block. Moving it inside the try block changes the error handling behavior and may mask exceptions from the getattr call.
| error=f"Language {language} not supported yet. Only Python is supported in Phase 1.", | ||
| execution_time=0.0, | ||
| language=language, | ||
| exit_code=1, |
There was a problem hiding this comment.
Missing exit_code field in the earlier successful return statement (line ~50-60). The CodeExecutionResult model requires exit_code but it's only provided in the error case.
| self.azure_ai_project_endpoint = os.getenv("AZURE_AI_PROJECT_ENDPOINT") | ||
| if not self.azure_ai_project_endpoint: | ||
| raise AgentConfigurationError( | ||
| "AZURE_AI_PROJECT_ENDPOINT environment variable is required" | ||
| ) |
There was a problem hiding this comment.
The AZURE_AI_PROJECT_ENDPOINT validation is duplicated in the mem0_provider.py file (lines 34-35). Consider centralizing this validation logic to avoid duplication.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Zachary BENSALEM <zachary@qredence.ai>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Zachary BENSALEM <zachary@qredence.ai>
| error=f"Language {language} not supported yet. Only Python is supported in Phase 1.", | ||
| execution_time=0.0, | ||
| language=language, | ||
| exit_code=1, |
There was a problem hiding this comment.
The exit_code field is being added to the CodeExecutionResult model when the language is not supported. However, this field should be included in the original model definition but is missing from the context. Verify that the CodeExecutionResult model in the same file includes exit_code: int | None field to match this usage.
| agent_id: str | None = None, | ||
| metadata: dict | None = None, | ||
| ): | ||
| ) -> None: |
There was a problem hiding this comment.
Good improvement adding the return type annotation to the add method. This follows the Microsoft Agent Framework patterns for type safety.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Zachary BENSALEM <zachary@qredence.ai>
Migrate the project to a src/ layout for better organization and compliance with Python packaging standards. Enhance MultiAgentWorkflow with type hints and improved error handling. Introduce a CI/CD pipeline, pre-commit hooks, and a Makefile for streamlined development. Update documentation to reflect changes and ensure consistency across the project. Fix the temperature parameter issue in agent constructors.