mirror of
https://github.com/github/awesome-copilot.git
synced 2026-05-15 11:11:48 +00:00
docs(learning-hub): document userPromptSubmitted LLM bypass and multi-skill invocation (v1.0.44) (#1656)
- automating-with-hooks.md: update userPromptSubmitted event table entry to
mention new ability to handle requests directly (v1.0.44+); add 'Handling
Requests Directly with userPromptSubmitted' example section showing the
{"response":"..."} JSON pattern; update FAQ answer to describe the bypass
capability
- creating-effective-skills.md: update skill invocation Q&A to document
mid-input slash commands and multiple skills in a single message (v1.0.44+);
update 'Can agents chain multiple skills?' FAQ with user-facing details
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
2c275f2ef9
commit
cf6bbba6fc
@@ -3,7 +3,7 @@ title: 'Automating with Hooks'
|
|||||||
description: 'Learn how to use hooks to automate lifecycle events like formatting, linting, and governance checks during Copilot agent sessions.'
|
description: 'Learn how to use hooks to automate lifecycle events like formatting, linting, and governance checks during Copilot agent sessions.'
|
||||||
authors:
|
authors:
|
||||||
- GitHub Copilot Learning Hub Team
|
- GitHub Copilot Learning Hub Team
|
||||||
lastUpdated: 2026-05-05
|
lastUpdated: 2026-05-08
|
||||||
estimatedReadingTime: '8 minutes'
|
estimatedReadingTime: '8 minutes'
|
||||||
tags:
|
tags:
|
||||||
- hooks
|
- hooks
|
||||||
@@ -89,7 +89,7 @@ Hooks can trigger on several lifecycle events:
|
|||||||
|-------|---------------|------------------|
|
|-------|---------------|------------------|
|
||||||
| `sessionStart` | Agent session begins or resumes | Initialize environments, log session starts, validate project state |
|
| `sessionStart` | Agent session begins or resumes | Initialize environments, log session starts, validate project state |
|
||||||
| `sessionEnd` | Agent session completes or is terminated | Clean up temp files, generate reports, send notifications |
|
| `sessionEnd` | Agent session completes or is terminated | Clean up temp files, generate reports, send notifications |
|
||||||
| `userPromptSubmitted` | User submits a prompt | Log requests for auditing and compliance |
|
| `userPromptSubmitted` | User submits a prompt | Log requests for auditing and compliance; handle requests directly without invoking the LLM (v1.0.44+) |
|
||||||
| `preToolUse` | Before the agent uses any tool (e.g., `bash`, `edit`) | **Approve or deny** tool executions, block dangerous commands, enforce security policies |
|
| `preToolUse` | Before the agent uses any tool (e.g., `bash`, `edit`) | **Approve or deny** tool executions, block dangerous commands, enforce security policies |
|
||||||
| `postToolUse` | After a tool **successfully** completes execution | Log results, track usage, format code after edits |
|
| `postToolUse` | After a tool **successfully** completes execution | Log results, track usage, format code after edits |
|
||||||
| `postToolUseFailure` | When a tool call **fails with an error** | Log errors for debugging, send failure alerts, track error patterns |
|
| `postToolUseFailure` | When a tool call **fails with an error** | Log errors for debugging, send failure alerts, track error patterns |
|
||||||
@@ -441,6 +441,53 @@ Scan user prompts for potential security threats and log session activity:
|
|||||||
|
|
||||||
This pattern is useful for enterprise environments that need to audit AI interactions for compliance.
|
This pattern is useful for enterprise environments that need to audit AI interactions for compliance.
|
||||||
|
|
||||||
|
### Handling Requests Directly with userPromptSubmitted (v1.0.44+)
|
||||||
|
|
||||||
|
Since v1.0.44, `userPromptSubmitted` hooks can do more than log or block — they can **handle a request entirely**, returning a response to the user without making any model call. When your hook script writes a JSON object with a `response` field to stdout, the CLI delivers that text to the user and skips the LLM altogether.
|
||||||
|
|
||||||
|
This is useful for:
|
||||||
|
- **FAQ bots**: Return canned answers for common questions without spending model quota
|
||||||
|
- **Policy enforcement**: Reject out-of-scope prompts with a clear, consistent message
|
||||||
|
- **Redirect patterns**: Direct users to a specific resource or runbook
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"version": 1,
|
||||||
|
"hooks": {
|
||||||
|
"userPromptSubmitted": [
|
||||||
|
{
|
||||||
|
"type": "command",
|
||||||
|
"bash": "./scripts/prompt-router.sh",
|
||||||
|
"timeoutSec": 5
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Example script that handles a `/help` prefix without invoking the model:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# scripts/prompt-router.sh
|
||||||
|
# Return a direct response for known help queries — no LLM call needed.
|
||||||
|
|
||||||
|
INPUT=$(cat)
|
||||||
|
PROMPT=$(echo "$INPUT" | jq -r '.prompt // empty' | tr '[:upper:]' '[:lower:]')
|
||||||
|
|
||||||
|
if echo "$PROMPT" | grep -q "^/help\b"; then
|
||||||
|
echo '{"response": "Available commands: /generate-tests, /review-pr, /explain-architecture. Type /help <command> for details."}'
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# No match — let the LLM handle it normally (exit 0 without writing a response)
|
||||||
|
exit 0
|
||||||
|
```
|
||||||
|
|
||||||
|
> **How it works**: When the hook exits with code `0` **and** writes a valid `{"response": "..."}` JSON object to stdout, the CLI delivers that text to the user and stops processing — no model call is made. If the hook exits with code `0` but writes nothing (or writes no `response` key), the CLI proceeds normally and calls the LLM.
|
||||||
|
|
||||||
|
> **Multiple hooks**: If several `userPromptSubmitted` hooks are configured, the first one that returns a `response` wins; subsequent hooks for that event are skipped.
|
||||||
|
|
||||||
### Notification on Session End
|
### Notification on Session End
|
||||||
|
|
||||||
Send a Slack or Teams notification when an agent session completes:
|
Send a Slack or Teams notification when an agent session completes:
|
||||||
@@ -592,7 +639,7 @@ For team-wide hooks that everyone should use, `.github/hooks/` is the recommende
|
|||||||
|
|
||||||
**Q: Can hooks access the user's prompt text?**
|
**Q: Can hooks access the user's prompt text?**
|
||||||
|
|
||||||
A: Yes, for `userPromptSubmitted` events the prompt content is available via JSON input to the hook script. Other hooks like `preToolUse` and `postToolUse` receive context about the tool being called. See the [GitHub Copilot hooks documentation](https://docs.github.com/en/copilot/concepts/agents/coding-agent/about-hooks) for details.
|
A: Yes. For `userPromptSubmitted` events the prompt content is available via JSON input to the hook script. Since v1.0.44, these hooks can also **respond directly** by writing `{"response": "..."}` to stdout — the CLI delivers that text to the user and skips the LLM entirely. Other hooks like `preToolUse` and `postToolUse` receive context about the tool being called. See the [GitHub Copilot hooks documentation](https://docs.github.com/en/copilot/concepts/agents/coding-agent/about-hooks) for details.
|
||||||
|
|
||||||
**Q: What happens if a hook times out?**
|
**Q: What happens if a hook times out?**
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ title: 'Creating Effective Skills'
|
|||||||
description: 'Master the art of writing reusable, shareable skill folders that deliver consistent results across your team.'
|
description: 'Master the art of writing reusable, shareable skill folders that deliver consistent results across your team.'
|
||||||
authors:
|
authors:
|
||||||
- GitHub Copilot Learning Hub Team
|
- GitHub Copilot Learning Hub Team
|
||||||
lastUpdated: 2026-02-26
|
lastUpdated: 2026-05-08
|
||||||
estimatedReadingTime: '9 minutes'
|
estimatedReadingTime: '9 minutes'
|
||||||
tags:
|
tags:
|
||||||
- skills
|
- skills
|
||||||
@@ -347,7 +347,10 @@ Use [scripts/parse-test-output.sh](scripts/parse-test-output.sh) to extract stru
|
|||||||
|
|
||||||
**Q: How do I invoke a skill?**
|
**Q: How do I invoke a skill?**
|
||||||
|
|
||||||
A: Skills can be invoked in two ways. Users can type the skill name as a `/command` in VS Code Chat (e.g., `/generate-tests`). Agents can also discover and invoke skills automatically based on the skill's description and the user's intent.
|
A: Skills can be invoked in several ways:
|
||||||
|
- **Slash command**: Type the skill name anywhere in your message (e.g., `/generate-tests fix the failing tests`). Since v1.0.44, slash commands can appear mid-input — you don't have to start with them.
|
||||||
|
- **Multiple skills in one message**: You can invoke multiple skills in a single message (e.g., `/generate-tests and then /conventional-commit`). Both skills will be executed in sequence.
|
||||||
|
- **Agent discovery**: Agents can also discover and invoke skills automatically based on the skill's `description` and the user's intent — no slash command required.
|
||||||
|
|
||||||
**Q: How are skills different from prompts?**
|
**Q: How are skills different from prompts?**
|
||||||
|
|
||||||
@@ -361,9 +364,9 @@ A: Yes! Skills are folders, not single files. You can bundle reference documents
|
|||||||
|
|
||||||
A: Store skill folders in your repository's `.github/skills/` directory. They're automatically available to all team members with Copilot access when working in that repository.
|
A: Store skill folders in your repository's `.github/skills/` directory. They're automatically available to all team members with Copilot access when working in that repository.
|
||||||
|
|
||||||
**Q: Can agents chain multiple skills?**
|
**Q: Can I invoke multiple skills in one message?**
|
||||||
|
|
||||||
A: Agents can discover and invoke multiple skills during a conversation based on user intent. Each skill invocation is independent, but agents maintain conversation context across invocations.
|
A: Yes, since v1.0.44. You can include multiple slash commands in a single message (e.g., `/generate-tests and then /conventional-commit`), and the CLI will execute each skill in sequence. Agents can also discover and chain multiple skills during a conversation based on user intent. Each skill invocation is independent, but agents maintain conversation context across invocations.
|
||||||
|
|
||||||
**Q: Should skills include code examples?**
|
**Q: Should skills include code examples?**
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user