A guide to understanding and handling errors from the Agent Governance SDK.
track...
methods are designed to be non-blocking and fail silently (logging an error to the console) to prevent monitoring issues from crashing your core application logic. You can track an event, and even if the SDK fails to process or send it, your application will continue running.
new AgentMonitor(...)
with invalid config) and manual flushing (monitor.flush()
), will throw exceptions that you should handle.
Error
objects, often with additional properties to provide more context.
AgentMonitor
constructor if the provided configuration is invalid.
'ValidationError'
.
"Invalid configuration: apiKey: is required; batchSize: must be less than 1000"
['batchSize']
monitor.flush()
or monitor.shutdown()
if the SDK fails to send an event batch after all retries.
'HttpRequestError'
or similar"Failed to send events after 3 attempts. Final error: HTTP 500: Internal Server Error"
track...
methods don’t throw, focus on handling configuration and shutdown errors.
Handle Configuration Errors
AgentMonitor
constructor in a try…catch block. A ValidationError
is a critical setup issue.Handle Shutdown Errors
Monitor SDK Logs
level: 'error'
and prefix [AgentGovernance]
Error: HTTP 401 Unauthorized
Error: HTTP 400 Bad Request
logLevel: 'debug'
and inspect payloads. Ensure custom events conform to schema.Error: Request timeout or Network request failed
api.aiagentshouse.com
.