Skip to content

Add global kill switch to disable agent-sentry via config#16

Open
calabamatex wants to merge 1 commit into
mainfrom
claude/disable-agentsentry-hooks-Sw3K4
Open

Add global kill switch to disable agent-sentry via config#16
calabamatex wants to merge 1 commit into
mainfrom
claude/disable-agentsentry-hooks-Sw3K4

Conversation

@calabamatex

Copy link
Copy Markdown
Owner

Summary

This PR adds a global kill switch mechanism to agent-sentry that allows users to disable all hooks by setting enabled: false in the agent-sentry.config.json configuration file.

Key Changes

  • Added configuration check logic to all four hook scripts (post-write-checks.sh, session-checkpoint.sh, session-start-checks.sh, and lifecycle-manager.sh)
  • Each script now reads the agent-sentry.config.json file and exits early (with code 0) if the enabled field is set to false
  • Updated agent-sentry.config.json to set enabled: false by default
  • The kill switch gracefully handles missing configuration files or missing jq dependency by defaulting to enabled state

Implementation Details

  • The kill switch check is placed early in each script, after SCRIPT_DIR is determined but before any hook execution
  • Uses jq to parse the JSON configuration with a fallback default of true if the field is missing
  • Silently exits with code 0 when disabled, allowing the scripts to be safely called without side effects
  • The implementation is consistent across all four hook scripts for maintainability

https://claude.ai/code/session_0191XboFE6hWRqzHYKrh83nt

Set "enabled": false in agent-sentry.config.json to disable all hooks
without removing their definitions. Also added the global kill switch
guard to the 4 scripts that were missing it (post-write-checks.sh,
session-checkpoint.sh, session-start-checks.sh, lifecycle-manager.sh).

To re-enable, set "enabled" back to true in agent-sentry.config.json.

https://claude.ai/code/session_0191XboFE6hWRqzHYKrh83nt
@vercel

vercel Bot commented Apr 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agent-sentry Ready Ready Preview, Comment Apr 12, 2026 5:35pm
agent-sentry-5jxd Ready Ready Preview, Comment Apr 12, 2026 5:35pm

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8e6d3e6f96

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


# Global kill switch
_AS_CFG="$SCRIPT_DIR/../agent-sentry.config.json"
if [[ -f "$_AS_CFG" ]] && command -v jq &>/dev/null && [[ "$(jq -r '.enabled // true' "$_AS_CFG" 2>/dev/null)" == "false" ]]; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Read kill-switch flag without // true fallback

The new guard uses jq -r '.enabled // true', but in jq // treats false as missing, so a config with "enabled": false evaluates to true and the == "false" check never fires. This means the kill switch added in this commit does not activate in these scripts (same pattern appears in the other new guards), so users cannot reliably disable execution via config as intended.

Useful? React with 👍 / 👎.

@calabamatex calabamatex left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Review: Add global kill switch to disable agent-sentry via config

Code Quality — Shell Script Logic Looks Good ✅

The kill switch implementation is well done:

  • Pattern is consistent across all 4 scripts
  • Graceful degradation — if jq is missing or config file absent, defaults to enabled (hooks keep running)
  • Placement is correct — check runs early in each script, before any hook execution
  • Exit code 0 when disabled — scripts exit cleanly without side effects
  • jq -r '.enabled // true' correctly falls back to true if the field is missing

Blocking Issues

1. Config default changed to enabled: false

The PR changes agent-sentry.config.json from "enabled": true to "enabled": false. This would disable agent-sentry for all users upon merge. The kill switch feature should ship with the existing default (true) so current behavior is preserved — users who want to disable can then opt-in to false.

2. CI is failing

  • build-and-test (18) — ❌ failed
  • build-and-test (20) — cancelled (cascade)
  • build-and-test (22) — cancelled (cascade)

The PR can't merge until CI is green. This may be pre-existing on main (since the diff only touches shell scripts and JSON config), but it still blocks the merge.

Minor Nit

In lifecycle-manager.sh, there's no blank line between the kill switch fi and RUNTIME_DATA=, while the other 3 scripts all have a trailing blank line after the block. Minor consistency issue.

Verdict: Do Not Merge Yet

Please fix these two items before merge:

  1. Revert the config default back to "enabled": true
  2. Investigate / fix the CI failure (or confirm it's pre-existing on main)

Generated by Claude Code

calabamatex pushed a commit that referenced this pull request Apr 12, 2026
- Revert config default to enabled:true (was flipped to false, which
  would silently disable AgentSentry for all users after merge)
- Fix jq alternative operator bug in kill switch guards: jq's //
  treats false as falsy, so '.enabled // true' always returns "true"
  even when enabled is false, making the kill switch a no-op. Changed
  to '.enabled' which correctly outputs "false" for the == check.
  Fixed in all 4 PR scripts + pre-existing bug in hook-guard.sh.
- Drop Node 18 from CI matrix (EOL since April 2025) and add
  fail-fast:false so remaining matrix jobs aren't cancelled on failure
- Fix flaky coordinator test by using isolated temp directories
  instead of shared fixtures path (prevents SQLite disk I/O errors
  under parallel vitest execution)

https://claude.ai/code/session_01Cd7VMhAqtso4mQzCoQVRmr
@sonarqubecloud

Copy link
Copy Markdown

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.

2 participants