feat: add Analysis Mode setting for Security Agent#435
Merged
jeanduplessis merged 6 commits intomainfrom Feb 24, 2026
Merged
Conversation
Contributor
Author
Code Review SummaryStatus: No Issues Found | Recommendation: Merge This PR cleanly replaces the
Other Observations (not in diff)Issues found in unchanged code that cannot receive inline comments:
Files Reviewed (10 files)
|
83f24f4 to
6a801e5
Compare
1b9483f to
287f248
Compare
Add a configurable analysis_mode setting with three options: - auto (default): triage runs first, sandbox only if triage recommends it - shallow: triage only, never runs sandbox analysis - deep: always forces sandbox analysis Changes: - Add AnalysisMode type and analysis_mode to SecurityAgentConfig schema - Update DEFAULT_SECURITY_AGENT_CONFIG with analysis_mode: 'auto' - Add AnalysisModeSchema and analysisMode to SaveSecurityConfigInputSchema - Update startSecurityAnalysis to respect analysis_mode parameter - Update both personal and org routers (getConfig, saveConfig, startAnalysis) - Add Analysis Mode card to SecurityConfigForm UI with radio group - Pass analysisMode through SecurityAgentPageClient - Add analysisMode to PostHog tracking events - Add comprehensive tests for all three modes No database migration needed - analysis_mode fits in existing JSONB config column. Default-merge pattern ensures backward compatibility.
forceSandbox was never set to true by any caller and is fully superseded by analysisMode: 'deep'. Removing it simplifies the sandbox decision to a clean two-term expression and eliminates the confusing precedence issue where shallow mode silently ignored an explicit forceSandbox: true.
…ling Move startSecurityAnalysis result from untyped 'let' outside try/catch to 'const' inside the try block. This eliminates the possibility of accessing an undefined result if rethrowAsPaymentRequired's 'never' return type is ever lost in a refactor.
Add analysisMode to SecurityAgentAnalysisStartedEvent so analytics can distinguish input mode (auto/shallow/deep) from outcome (triageOnly). Without this, 'auto chose triage-only' and 'shallow forced triage-only' are indistinguishable in metrics.
…scoping in routers
a9df5bd to
966713a
Compare
eshurakov
approved these changes
Feb 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an
analysis_modesetting to the Security Agent configuration that lets users control the depth of vulnerability analysis. Three modes are available:forceSandboxmechanism).Key Design Decisions
analysis_modefield fits inside the existing JSONBconfigcolumn onagent_configs. The default-merge pattern ingetSecurityAgentConfig()means all existing users automatically get'auto'mode.forceSandbox: Thedeepmode reuses the existing sandbox-forcing mechanism.forceSandbox: Even ifforceSandboxis explicitly set,shallowmode will never run sandbox analysis.Changes
Config Schema & Defaults
AnalysisModetype ('auto' | 'shallow' | 'deep') tosrc/lib/security-agent/core/types.tsanalysis_modefield toSecurityAgentConfigSchemawith default'auto'AnalysisModeSchematosrc/lib/security-agent/core/schemas.tsDEFAULT_SECURITY_AGENT_CONFIGinsrc/lib/security-agent/core/constants.tsAnalysis Pipeline
startSecurityAnalysis()insrc/lib/security-agent/services/analysis-service.tsto accept and respectanalysisModedeep→ always sandbox;shallow→ never sandbox;auto→ respect triage recommendationAPI / Routers
security-agent-router.ts(personal) andorganization-security-agent-router.ts(org) now:analysisModefromgetConfiganalysisModeinsaveConfiganalysis_modefrom config when starting analysisUI
SecurityConfigForm.tsxwith three options and descriptive help textSecurityAgentPageClient.tsxTracking
analysisModeto PostHog config-saved eventTests
analysis-service.test.ts:forceSandboxanalysisModeis not specifiedRollout
Ships behind existing Security Agent feature flag. Default
'auto'means no behavioral change for existing users.Built for jean by Kilo for Slack