# 962 Agents Plugins Blueprint Registration Fix 407fecbf

> Agent and Plugin Blueprint Registration Fix

- Skill: `tools-only/962-agents-plugins-blueprint-registration-fix-407fecbf` (Agent Skill, multi-file: 3 files)
- Install (CLI): `npx skillmds@latest add tools-only/962-agents-plugins-blueprint-registration-fix-407fecbf`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tools-only/962-agents-plugins-blueprint-registration-fix-407fecbf/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: tools-only (https://skillmd.com/u/tools-only)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/tools-only/962-agents-plugins-blueprint-registration-fix-407fecbf

---

# Agent and Plugin Blueprint Registration Fix

**Version Implemented:** 0.229.001

## Issue Description

The application was experiencing a critical issue where agent and plugin API endpoints were returning 404 (NOT FOUND) errors instead of properly functioning. Users reported that agents and actions were not loading as global or personal components, even though they were enabled in the system settings.

### Symptoms

The following console errors were observed in the browser:

```
GET https://127.0.0.1:5000/api/orchestration_types 404 (NOT FOUND)
GET https://127.0.0.1:5000/api/orchestration_settings 404 (NOT FOUND)  
GET https://127.0.0.1:5000/api/admin/agent/settings 404 (NOT FOUND)
GET https://127.0.0.1:5000/api/admin/agents 404 (NOT FOUND)
GET https://127.0.0.1:5000/api/user/plugins 404 (NOT FOUND)
GET https://127.0.0.1:5000/api/admin/plugins/settings 404 (NOT FOUND)
GET https://127.0.0.1:5000/api/admin/plugins 404 (NOT FOUND)
```

Additionally, frontend JavaScript errors indicated that agent and plugin data could not be loaded:

- "Failed to load actions: Error: Failed to load actions"
- "Error loading admin agent data: Error: Failed to load orchestration types"

## Root Cause Analysis

The issue was caused by **duplicate Flask app instances** being created in the application:

1. **Primary Flask app** created in `app.py` at line 56
2. **Conflicting Flask app** created in `config.py` at line 87

When `app.py` imported from `config.py` using `from config import *`, it inadvertently imported the Flask app instance from `config.py`, which overwrote the properly configured app instance from `app.py`.

### The Problem Sequence

1. `app.py` creates a Flask app instance and registers blueprints
2. `app.py` imports `from config import *` 
3. This import overwrites the configured Flask app with the unconfigured one from `config.py`
4. The blueprints that were registered to the original app instance are lost
5. API endpoints return 404 because the routes don't exist on the new app instance

## Technical Details

### Files Modified

1. **config.py**: Removed duplicate Flask app creation and converted to configuration constants
2. **app.py**: Updated to use configuration constants from config.py

### Code Changes

#### config.py (Lines 87-95)
**Before:**
```python
app = Flask(__name__)

app.config['EXECUTOR_TYPE'] = 'thread'
app.config['EXECUTOR_MAX_WORKERS'] = 30
executor = Executor()
executor.init_app(app)
app.config['SESSION_TYPE'] = 'filesystem'
app.config['VERSION'] = "0.228.001"

Session(app)
```

**After:**
```python
# Flask app configuration constants
EXECUTOR_TYPE = 'thread'
EXECUTOR_MAX_WORKERS = 30
SESSION_TYPE = 'filesystem'
VERSION = "0.228.002"
```

#### app.py (Lines 57-64)
**Before:**
```python
app.config['EXECUTOR_TYPE'] = 'thread'
app.config['EXECUTOR_MAX_WORKERS'] = 30
executor = Executor()
executor.init_app(app)
app.config['SESSION_TYPE'] = 'filesystem'
app.config['VERSION'] = "0.226.102"
```

**After:**
```python
app.config['EXECUTOR_TYPE'] = EXECUTOR_TYPE
app.config['EXECUTOR_MAX_WORKERS'] = EXECUTOR_MAX_WORKERS
executor = Executor()
executor.init_app(app)
app.config['SESSION_TYPE'] = SESSION_TYPE
app.config['VERSION'] = VERSION
```

## Validation

### Test Results

After implementing the fix, all previously failing API endpoints now return proper HTTP status codes:

| Endpoint | Before Fix | After Fix |
|----------|------------|-----------|
| `/api/orchestration_types` | 404 NOT FOUND | 401 Unauthorized |
| `/api/orchestration_settings` | 404 NOT FOUND | 401 Unauthorized |
| `/api/admin/agents` | 404 NOT FOUND | 401 Unauthorized |
| `/api/admin/agent/settings` | 404 NOT FOUND | 401 Unauthorized |
| `/api/user/plugins` | 404 NOT FOUND | 401 Unauthorized |
| `/api/admin/plugins/settings` | 404 NOT FOUND | 401 Unauthorized |
| `/api/admin/plugins` | 404 NOT FOUND | 401 Unauthorized |

The 401 (Unauthorized) responses indicate that the endpoints are now properly registered and accessible, but require authentication - which is the expected behavior.

### Blueprint Registration Verification

The fix ensures that all required blueprints are properly registered:

- ✅ `admin_plugins` - Admin plugin management endpoints
- ✅ `dynamic_plugins` - Dynamic plugin endpoints  
- ✅ `admin_agents` - Admin agent management endpoints
- ✅ `plugin_validation` - Plugin validation endpoints
- ✅ `migration` - Database migration endpoints
- ✅ `plugin_logging` - Plugin logging endpoints

## Impact

### User Experience Improvements

- **Agents**: Global and personal agents now load correctly in the admin interface
- **Actions/Plugins**: Plugin management interface is fully functional
- **Admin Settings**: Agent orchestration settings are accessible
- **User Workspace**: Personal agents and plugins display properly

### System Stability

- Eliminates Flask app instance conflicts
- Ensures consistent configuration across the application
- Prevents silent blueprint registration failures
- Maintains proper separation of concerns between configuration and application logic

## Prevention

To prevent similar issues in the future:

1. **Single Responsibility**: Keep Flask app creation in one location (`app.py`)
2. **Configuration Constants**: Use configuration constants instead of app instances in shared modules
3. **Import Testing**: Regularly test that blueprints are properly registered
4. **Code Review**: Review any changes to Flask app initialization carefully

## Testing

A functional test has been created at `functional_tests/test_agents_plugins_blueprint_fix.py` to ensure this issue doesn't regress. The test verifies:

1. All critical API endpoints return non-404 status codes
2. Required blueprints are properly registered
3. Flask app structure is correct

## Related Issues

This fix resolves the core infrastructure issue that was preventing agents and plugins from functioning. Users should now be able to:

- Access agent management interfaces
- Configure global and personal agents
- Manage plugin settings
- View orchestration options

If users continue to experience issues with specific agent or plugin functionality after this fix, those would be separate issues requiring individual investigation.

