/health endpoint or a root / route.
AgentOS provides the on_route_conflict parameter to control how these conflicts are resolved, allowing you to choose whether your custom routes or AgentOS routes take precedence.
When to Use
Override routes when you need:- Custom health checks: Replace AgentOS’s
/healthendpoint with your own monitoring logic - Branded landing pages: Serve a custom homepage at
/instead of the default AgentOS interface - Custom authentication: Implement your own auth endpoints that conflict with AgentOS defaults
- API versioning: Control which version of an endpoint is exposed
- Custom error handlers: Define specialized error handling for specific routes
Configuration Options
Theon_route_conflict parameter accepts three values:
| Option | Custom Routes | AgentOS Routes | On Conflict |
|---|---|---|---|
preserve_base_app | ✓ Preserved | ✗ Skipped (conflicts only) | Logs at debug level |
preserve_agentos (default) | ✗ Overridden | ✓ Preserved | Logs a warning |
error | N/A | N/A | Raises ValueError |
Non-conflicting routes from both your app and AgentOS are always included in the two preserve modes.
Example
The example below useson_route_conflict="preserve_base_app" to preserve custom routes for the home page and health endpoint.
override_routes.py