Skip to content

fix(agent): skip on-call escalation when the workflow is not initialized - #261

Open
nghiadaulau wants to merge 1 commit into
VersusControl:mainfrom
nghiadaulau:fix/agent-oncall-uninitialized-panic
Open

fix(agent): skip on-call escalation when the workflow is not initialized#261
nghiadaulau wants to merge 1 commit into
VersusControl:mainfrom
nghiadaulau:fix/agent-oncall-uninitialized-panic

Conversation

@nghiadaulau

Copy link
Copy Markdown
Member

Problem

CreateIncidentFromFinding sets the oncall_enable=true query-param override for high/critical AI findings. When on-call is disabled at startup (oncall.enable and oncall.initialized_only both false), InitOnCallWorkflow is never called, so core.GetOnCallWorkflow() panics — taking down the agent tick goroutine on the first detect-mode emit of a high/critical pattern.

panic: on-call workflow not initialized - call InitOnCallWorkflow first
  pkg/core/oncall.go:64 GetOnCallWorkflow
  pkg/services/incident.go:100 CreateIncident
  pkg/agent.(*Worker).emitDetect

Fix

  • Add core.IsOnCallInitialized().
  • Guard the escalation in CreateIncident: when on-call is requested but the workflow was never initialized, log a warning and skip escalation instead of crashing. Channel fan-out (which runs first) is unaffected, so the alert still reaches Telegram/Slack/etc.

Verified

Reproduced on minikube (agent detect mode + Gemini, on-call disabled): before the fix the pod crash-looped on the first emit; after, the agent emits the incident to Telegram and logs ... on-call escalation requested but the workflow is not initialized ... skipping escalation. go test ./pkg/services/... ./pkg/core/... passes.

🤖 Generated with Claude Code

CreateIncidentFromFinding sets the oncall_enable=true query-param override
for high/critical AI findings. When on-call was disabled at startup
(oncall.enable and oncall.initialized_only both false) InitOnCallWorkflow
is never called, so GetOnCallWorkflow() panicked and took down the agent
tick goroutine on the first detect-mode emit of a high/critical pattern.

Add core.IsOnCallInitialized() and guard the escalation: when on-call is
requested but uninitialized, log a warning and skip instead of crashing.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant