Skip to content

Debounce AI hooks#1252

Merged
paulpetit-gg-ext merged 2 commits into
mainfrom
ppetit/debounce-ai-hooks
May 26, 2026
Merged

Debounce AI hooks#1252
paulpetit-gg-ext merged 2 commits into
mainfrom
ppetit/debounce-ai-hooks

Conversation

@paulpetit-gg-ext
Copy link
Copy Markdown
Contributor

Context

Some agents can detect multiple hook configurations (for instance VSCode can load Claude's hooks in addition to its own).

In these cases, the same payload is usually called once for each hook, which create unnecessary load to GIM and latency to the user.

What has been done

  • Remember the hash of the latest payload in a cache file and use it to debounce hook payloads.
  • To avoid a race condition where the two hook processes are spawned quickly enough for the cache to be stale, file locking is done.
  • New dependency to the filelock library that makes this locking cross-platform.

@paulpetit-gg-ext paulpetit-gg-ext requested a review from a team as a code owner May 26, 2026 09:35
@paulpetit-gg-ext paulpetit-gg-ext self-assigned this May 26, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 26, 2026

Codecov Report

❌ Patch coverage is 90.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.63%. Comparing base (befdca6) to head (87e9b29).

Files with missing lines Patch % Lines
ggshield/verticals/ai/hooks.py 90.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1252      +/-   ##
==========================================
- Coverage   93.64%   93.63%   -0.01%     
==========================================
  Files         183      183              
  Lines        9960     9980      +20     
==========================================
+ Hits         9327     9345      +18     
- Misses        633      635       +2     
Flag Coverage Δ
unittests 93.63% <90.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@paulpetit-gg-ext paulpetit-gg-ext changed the title Debounce ai hooks Debounce AI hooks May 26, 2026
@paulpetit-gg-ext paulpetit-gg-ext force-pushed the ppetit/debounce-ai-hooks branch from 2864114 to 2cb1d1f Compare May 26, 2026 12:24
Comment thread ggshield/verticals/ai/hooks.py Outdated
Comment thread ggshield/verticals/ai/hooks.py Outdated
Copy link
Copy Markdown
Member

@xblanchot-gg xblanchot-gg left a comment

Choose a reason for hiding this comment

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

A few small comments, overall looks good !

@paulpetit-gg-ext paulpetit-gg-ext merged commit 58dac51 into main May 26, 2026
29 of 31 checks passed
@paulpetit-gg-ext paulpetit-gg-ext deleted the ppetit/debounce-ai-hooks branch May 26, 2026 15:04
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