[superlog] Log recoverable AI tool errors as WARN instead of ERROR#495
[superlog] Log recoverable AI tool errors as WARN instead of ERROR#495superlog-app[bot] wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
|
The latest updates on your projects. Learn more about Unkey Deploy
|
Greptile SummaryThis PR fixes false-positive ERROR alerts caused by recoverable AI tool failures (SQL errors,
Confidence Score: 4/5The change is safe to merge — it eliminates a confirmed source of false-positive ERROR alerts without touching any job-failure or real-error paths. The fix correctly addresses the described issue and the global fallback and job-level error paths are untouched. The No files require special attention beyond Important Files Changed
Sequence Diagram%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant Job as insights job (jobs.ts)
participant Logger as createToolLogger.error()
participant RL as requestLogger (evlog)
participant GL as log (global evlog)
Job->>RL: setAiRequestLoggerProvider(getActiveInsightsLog)
Job->>Logger: toolLogger.error("SQL query failed", ctx)
alt Request-scoped (BEFORE this PR)
Logger->>RL: requestLogger.error(new Error(message), ctx)
Note over RL: wide-event severity to ERROR
Job->>RL: logger.emit - job_status succeeded
Note over RL: emits at ERROR - false-positive alert
end
alt Request-scoped (AFTER this PR)
Logger->>RL: requestLogger.warn(message, ctx)
Note over RL: wide-event severity to WARN
Job->>RL: logger.emit - job_status succeeded
Note over RL: emits at WARN - no false alert
end
alt No active request logger (unchanged)
Logger->>GL: log.error service api aiTool message ctx
Note over GL: global ERROR log preserved
end
alt Real job failure (unchanged, jobs.ts)
Job->>RL: logger.error(err)
Job->>RL: logger.emit - job_status failed
Note over RL: emits at ERROR - real alert fires
end
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant Job as insights job (jobs.ts)
participant Logger as createToolLogger.error()
participant RL as requestLogger (evlog)
participant GL as log (global evlog)
Job->>RL: setAiRequestLoggerProvider(getActiveInsightsLog)
Job->>Logger: toolLogger.error("SQL query failed", ctx)
alt Request-scoped (BEFORE this PR)
Logger->>RL: requestLogger.error(new Error(message), ctx)
Note over RL: wide-event severity to ERROR
Job->>RL: logger.emit - job_status succeeded
Note over RL: emits at ERROR - false-positive alert
end
alt Request-scoped (AFTER this PR)
Logger->>RL: requestLogger.warn(message, ctx)
Note over RL: wide-event severity to WARN
Job->>RL: logger.emit - job_status succeeded
Note over RL: emits at WARN - no false alert
end
alt No active request logger (unchanged)
Logger->>GL: log.error service api aiTool message ctx
Note over GL: global ERROR log preserved
end
alt Real job failure (unchanged, jobs.ts)
Job->>RL: logger.error(err)
Job->>RL: logger.emit - job_status failed
Note over RL: emits at ERROR - real alert fires
end
|
Summary
Scheduled insights generation jobs complete successfully but are logged at
ERRORseverity whenever the AI agent encounters a recoverable tool failure (e.g., a SQL query error or an annotationNOT_FOUND). This generates false-positive ERROR alerts in Superlog, masking real failures.The insights service wires the AI tool logger to the job's wide-event logger (
setAiRequestLoggerProvider(getActiveInsightsLog)). When any tool logged an error viarequestLogger.error(new Error(message), context), evlog recorded the highest severity as ERROR. The job's success-pathlogger.emit({ job_status: "succeeded" })then emitted the wide event at ERROR level — despite the job completing successfully and the AI agent having already recovered from the tool failure.The fix changes
createToolLogger.error()to callrequestLogger.warn(message, context)instead ofrequestLogger.error(new Error(message), context)when a request-scoped logger is active. Tool-level errors are recoverable by design (the AI agent retries or works around them), so WARN is the appropriate severity. Actual job failures remain at ERROR becausejobs.tscallslogger.error(err)directly on the unhandled-exception path before emitting withjob_status: "failed".An alternative approach would be to use
requestLogger.set()to add error fields to the wide event without any severity change at all. That would suppress even WARN-level recording of tool errors; the current approach of using WARN keeps the tool failure visible in the job's wide event while preventing false ERROR alerts.Incident on Superlog
Was this PR helpful? Leave feedback — goes straight to the Superlog team.
Summary by cubic
Log recoverable tool failures as WARN instead of ERROR to stop false alerts and keep successful jobs at the right severity. True job failures still log as ERROR.
Written for commit 9f68681. Summary will update on new commits.