Skip to main content
This guide covers best practices and strategies for deploying your AI agent application with the AI Agents House SDK integrated. Proper deployment ensures that monitoring is reliable, performant, and secure in your production environment.

Pre-deployment Checklist

Before deploying to production, ensure you have:
  • Finalized Configuration: Your AgentMonitor configuration is set for production (e.g., appropriate batchSize, flushInterval, and logLevel).
  • Tested Thoroughly: Your application has been tested against a staging environment. See our Testing Guide for comprehensive strategies.
  • Managed Secrets: Your AGENT_GOVERNANCE_API_KEY and other secrets are managed securely and are not hardcoded.

Environment Configuration

It is critical to manage different configurations for your development, staging, and production environments. The most secure and flexible way to do this is with environment variables.

Deployment Strategies

The AI Agents House SDK is a standard Node.js library and can be deployed in any environment that supports Node.js.
In a serverless environment, the execution context can be frozen or terminated after a request is handled. This makes graceful shutdown even more important.Key Considerations:
  • shutdown() is essential: Because serverless functions can terminate at any time, you must flush() or shutdown() the monitor at the end of each invocation that tracks events.
  • Connection Reuse: Serverless platforms often reuse execution contexts. You can initialize the monitor outside of your handler function to reuse the instance across invocations, but be mindful of flushing data.
Example: AWS Lambda Handler
Deploying with containers is a robust way to manage your application and its dependencies.Key Considerations:
  • Dockerfile: Ensure your Dockerfile correctly installs dependencies (npm ci --only=production) and copies necessary files.
  • Environment Variables: Pass your API key and other configurations to the container using environment variables (-e flag in Docker or env in Kubernetes manifests).
  • Health Checks: Configure Kubernetes liveness and readiness probes for your application.
  • Graceful Shutdown: Kubernetes sends a SIGTERM signal to pods before termination. Your application must handle this signal to call monitor.shutdown().
Example: Dockerfile
When deploying on a traditional virtual machine, using a process manager like PM2 is highly recommended.Key Considerations:
  • Process Manager: Use PM2 to manage your Node.js process, handle restarts, and manage logs.
  • Graceful Shutdown with PM2: PM2 sends SIGINT to your application, which you can catch to trigger monitor.shutdown().
  • Environment Configuration: Use a .env file or the OS’s environment to manage secrets.
Example: PM2 Ecosystem File