Skip to content

Commit 6ec9f33

Browse files
fix: change stop hook from blocking to warning to prevent auto-commits (microsoft#1451)
## Summary Changes the stop hook from `"decision": "block"` to `"decision": "warn"` so the agent asks the user before committing instead of auto-committing. ## Background The `stop_hook.py` is a pre-session stop hook that runs when an agent (maintainer) session ends. It checks the git state for: 1. **Uncommitted TypeScript changes** (staged, modified, or untracked `.ts`/`.tsx` files) — reminds the agent to run pre-commit checks (lint, type-check, tests) 2. **Staged but uncommitted changes** — reminds the agent that work hasn't been committed ## Problem Previously, both checks used `"decision": "block"`, which **prevented the agent from ending the session** until the condition was resolved. The reason text explicitly told the agent to commit changes (e.g., *"If checks pass and changes are ready, commit them"*). This combination caused the agent to **auto-commit every time** without asking the user, which is undesirable when the user wants to review changes before committing. ## Changes - **`"decision": "block"` → `"decision": "warn"`** for both the TS changes check and the staged changes check. The agent sees the warning but is no longer forced to act on it. - **Removed commit instructions** from the reason text (e.g., *"commit them"*, *"Either commit them with a proper message"*) so the agent doesn't interpret them as required actions. - **Added explicit user-consent escape**: reason text now says *"Ask the user whether to commit or leave changes uncommitted"*, ensuring the agent defers to the user. ## Files Changed - `.github/hooks/scripts/stop_hook.py`
1 parent b0cca4e commit 6ec9f33

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

.github/hooks/scripts/stop_hook.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,12 @@ def main() -> int:
110110
response = {
111111
"hookSpecificOutput": {
112112
"hookEventName": "Stop",
113-
"decision": "block",
113+
"decision": "warn",
114114
"reason": (
115115
"You have uncommitted TypeScript changes. "
116-
"Before finishing, use the run-pre-commit-checks skill "
116+
"Before finishing, consider using the run-pre-commit-checks skill "
117117
"or manually run: npm run lint && npm run compile-tests && npm run unittest. "
118-
"If checks pass and changes are ready, commit them. "
119-
"If this session is just research/exploration, you can proceed without committing."
118+
"Ask the user whether to commit or leave changes uncommitted."
120119
),
121120
}
122121
}
@@ -128,10 +127,10 @@ def main() -> int:
128127
response = {
129128
"hookSpecificOutput": {
130129
"hookEventName": "Stop",
131-
"decision": "block",
130+
"decision": "warn",
132131
"reason": (
133132
"You have staged changes that haven't been committed. "
134-
"Either commit them with a proper message or unstage them before finishing."
133+
"Ask the user whether to commit them or leave them staged."
135134
),
136135
}
137136
}

0 commit comments

Comments
 (0)