-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Open
Labels
Description
Describe the feature or problem you'd like to solve
There is currently no way to deterministically guard the agent's work before it returns control to the user, while still being able to act on the result of the hook.
Proposed solution
Introduce a preAgentStop hook that fires when the agent is about to stop responding:
- Exit code 0: the agent stops as normal.
- Non-zero exit code: the agent receives the hook's stdout/stderr as context and continues working to address the issues. The hook re-triggers when the agent tries to stop again.
- A configurable
maxRetriesfield (e.g.,3) prevents infinite loops.
This benefits Copilot CLI users by enabling deterministic, enforceable guardrails and quality gates without relying on the model to remember instructions (which is not deterministic), while also being able to make changes on the outcome of those checks
Example prompts or workflows
- Linting and formatting enforcement
- Type-checks and build checks
- Running unit tests
...
Additional context
- Example
hooks.jsonconfiguration:
{
"version": 1,
"hooks": {
"preAgentStop": [
{
"type": "command",
"bash": "npx eslint",
"powershell": "npx eslint",
"cwd": ".",
"timeoutSec": 120,
"maxRetries": 3
}
]
}
}- Also add
preSubAgentStop
Analogous toagentStop and subAgentStop
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Type
Fields
Give feedbackNo fields configured for Feature.