-
Notifications
You must be signed in to change notification settings - Fork 3
refactor: replace config-based agents with lightweight registry #37
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bb56031 to
2a90d98
Compare
16c68ef to
5973774
Compare
- Remove empty __init__.py files across the codebase - Simplify AgentFactory by removing static methods and default configs - Remove unused types from core/types.py - Update tests to match simplified architecture - Clean up configuration handling in agent factory
- Pass full config to AgentFactory to avoid repeated config file reads - Load config once during server startup and reuse it - Add full_config parameter to factory methods to support config reuse - Update tests to pass full_config parameter This change reduces file system operations during agent creation by eliminating redundant config file reads on each request.
…egistry - Remove AgentConfiguration dataclass and TOML-based agent loading - Introduce AgentId enum with only CAIRO_CODER and SCARB agents - Create AgentSpec dataclass with build() method using match statement - Simplify AgentFactory from ~270 to ~125 LOC - Remove backward compatibility aliases (default, mcp-agent) - Pass VectorStoreConfig properly instead of creating empty configs - Update all tests to use new registry approach - Remove ~300 LOC of configuration indirection This makes adding new agents a simple 5-line change in registry.py instead of touching multiple config files and factory paths.
- Wrap ConfigManager.load_config() in try-catch blocks for optimizer notebooks - Allow tests to run without config.toml in CI environment - Prevents FileNotFoundError when pytest executes optimizer notebooks as tests
…zation - Wrap ConfigManager.load_config() in QueryAndRetrieval.__init__ with try-catch - Make optimizer file loading conditional on file existence - Allow document retriever to handle None vector_store_config in tests
ijusttookadnatest
approved these changes
Aug 5, 2025
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.
Great PR
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Summary: refactor: replace config-based agents with lightweight enum registry and optimize performance
📜 High-Level Summary
This PR replaces the configuration-based agent system with a lightweight enum-based registry, significantly simplifying agent management. The refactoring removes TOML-based agent configurations in favor of an in-memory registry with two built-in agents: Cairo Coder (general purpose) and Scarb Assistant (Scarb-specific). Additionally, the PR optimizes configuration loading by caching parsed TOML files and removes unnecessary empty
__init__.pyfiles throughout the codebase to improve import performance.📊 Architectural Impact & Visualizations
This diagram illustrates the simplified agent creation flow after removing the configuration-based system:
flowchart LR subgraph "Before" A1[config.toml] --> B1[ConfigManager] B1 --> C1[AgentConfiguration] C1 --> D1[AgentFactory] D1 --> E1[RagPipeline] end subgraph "After" A2[AgentId Enum] --> B2[registry.py] B2 --> C2[AgentSpec] C2 --> D2[AgentFactory] D2 --> E2[RagPipeline] end style A1 fill:#ffcccc style C1 fill:#ffcccc style A2 fill:#ccffcc style B2 fill:#ccffcc style C2 fill:#ccffcc⚙️ Detailed Changeset Breakdown
Changeset 1: Introduce Lightweight Agent Registry
Files Affected:
python/src/cairo_coder/agents/registry.pySummary of Changes:
AgentIdenum andAgentSpecdataclassbuild()method to create RagPipeline instances from specificationsget_agent_by_string_id()helper for string-based agent lookup[TRIAGE]: NEEDS_REVIEW
Changeset 2: Refactor Agent Factory to Use Registry
Files Affected:
python/src/cairo_coder/core/agent_factory.pySummary of Changes:
get_or_create_agent()to use the new registrycreate_agent(),create_agent_by_id(), and helper methodslist_available_agents()andget_agent_info()to use registryDefaultAgentConfigurationsclass entirelycreate_agent_factory()signature to remove config_manager and custom_agents[TRIAGE]: NEEDS_REVIEW
Changeset 3: Remove Agent Configuration from Core Config
Files Affected:
python/src/cairo_coder/core/config.pySummary of Changes:
AgentConfigurationdataclassRagSearchConfigdataclassConfigdataclassConfigdataclassVectorStoreConfigwhich is still needed[TRIAGE]: NEEDS_REVIEW
Changeset 4: Simplify Configuration Manager
Files Affected:
python/src/cairo_coder/config/manager.pySummary of Changes:
get_agent_config()static methodvalidate_config()load_config()to only handle vector store configuration[TRIAGE]: NEEDS_REVIEW
Changeset 5: Update Server to Use New Agent Factory
Files Affected:
python/src/cairo_coder/api/server.pySummary of Changes:
[TRIAGE]: NEEDS_REVIEW
Changeset 6: Update RAG Pipeline Factory
Files Affected:
python/src/cairo_coder/core/rag_pipeline.pySummary of Changes:
create_scarb_pipeline()method (now handled by registry)[TRIAGE]: NEEDS_REVIEW
Changeset 7: Update Tests for New Architecture
Files Affected:
python/tests/conftest.pypython/tests/test_agent_factory.pypython/tests/test_config_manager.pypython/tests/integration/test_server.pySummary of Changes:
sample_agent_configsfixture[TRIAGE]: NEEDS_REVIEW
Changeset 8: Update Documentation
Files Affected:
python/CLAUDE.md.claude/commands/commit.mdSummary of Changes:
[TRIAGE]: APPROVED
Changeset 9: Remove Empty Init Files
Files Affected:
python/src/cairo_coder/__init__.pypython/src/cairo_coder/agents/__init__.pypython/src/cairo_coder/api/__init__.pypython/src/cairo_coder/config/__init__.pypython/src/cairo_coder/core/__init__.pypython/src/cairo_coder/dspy/__init__.pypython/src/cairo_coder/utils/__init__.pySummary of Changes:
__init__.pyfiles throughout the codebase[TRIAGE]: APPROVED
Changeset 10: Update Optimizer Notebooks
Files Affected:
python/src/cairo_coder/optimizers/QueryAndRetrieval.pySummary of Changes:
[TRIAGE]: APPROVED
Changeset 11: Update Project Configuration
Files Affected:
python/pyproject.tomlSummary of Changes:
[TRIAGE]: APPROVED