Skip to content

Commit cf6bbba

Browse files
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>
1 parent 2c275f2 commit cf6bbba

2 files changed

Lines changed: 57 additions & 7 deletions

File tree

website/src/content/docs/learning-hub/automating-with-hooks.md

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: 'Automating with Hooks'
33
description: 'Learn how to use hooks to automate lifecycle events like formatting, linting, and governance checks during Copilot agent sessions.'
44
authors:
55
- GitHub Copilot Learning Hub Team
6-
lastUpdated: 2026-05-05
6+
lastUpdated: 2026-05-08
77
estimatedReadingTime: '8 minutes'
88
tags:
99
- hooks
@@ -89,7 +89,7 @@ Hooks can trigger on several lifecycle events:
8989
|-------|---------------|------------------|
9090
| `sessionStart` | Agent session begins or resumes | Initialize environments, log session starts, validate project state |
9191
| `sessionEnd` | Agent session completes or is terminated | Clean up temp files, generate reports, send notifications |
92-
| `userPromptSubmitted` | User submits a prompt | Log requests for auditing and compliance |
92+
| `userPromptSubmitted` | User submits a prompt | Log requests for auditing and compliance; handle requests directly without invoking the LLM (v1.0.44+) |
9393
| `preToolUse` | Before the agent uses any tool (e.g., `bash`, `edit`) | **Approve or deny** tool executions, block dangerous commands, enforce security policies |
9494
| `postToolUse` | After a tool **successfully** completes execution | Log results, track usage, format code after edits |
9595
| `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:
441441

442442
This pattern is useful for enterprise environments that need to audit AI interactions for compliance.
443443

444+
### Handling Requests Directly with userPromptSubmitted (v1.0.44+)
445+
446+
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.
447+
448+
This is useful for:
449+
- **FAQ bots**: Return canned answers for common questions without spending model quota
450+
- **Policy enforcement**: Reject out-of-scope prompts with a clear, consistent message
451+
- **Redirect patterns**: Direct users to a specific resource or runbook
452+
453+
```json
454+
{
455+
"version": 1,
456+
"hooks": {
457+
"userPromptSubmitted": [
458+
{
459+
"type": "command",
460+
"bash": "./scripts/prompt-router.sh",
461+
"timeoutSec": 5
462+
}
463+
]
464+
}
465+
}
466+
```
467+
468+
Example script that handles a `/help` prefix without invoking the model:
469+
470+
```bash
471+
#!/usr/bin/env bash
472+
# scripts/prompt-router.sh
473+
# Return a direct response for known help queries — no LLM call needed.
474+
475+
INPUT=$(cat)
476+
PROMPT=$(echo "$INPUT" | jq -r '.prompt // empty' | tr '[:upper:]' '[:lower:]')
477+
478+
if echo "$PROMPT" | grep -q "^/help\b"; then
479+
echo '{"response": "Available commands: /generate-tests, /review-pr, /explain-architecture. Type /help <command> for details."}'
480+
exit 0
481+
fi
482+
483+
# No match — let the LLM handle it normally (exit 0 without writing a response)
484+
exit 0
485+
```
486+
487+
> **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.
488+
489+
> **Multiple hooks**: If several `userPromptSubmitted` hooks are configured, the first one that returns a `response` wins; subsequent hooks for that event are skipped.
490+
444491
### Notification on Session End
445492

446493
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
592639

593640
**Q: Can hooks access the user's prompt text?**
594641

595-
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.
642+
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.
596643

597644
**Q: What happens if a hook times out?**
598645

website/src/content/docs/learning-hub/creating-effective-skills.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: 'Creating Effective Skills'
33
description: 'Master the art of writing reusable, shareable skill folders that deliver consistent results across your team.'
44
authors:
55
- GitHub Copilot Learning Hub Team
6-
lastUpdated: 2026-02-26
6+
lastUpdated: 2026-05-08
77
estimatedReadingTime: '9 minutes'
88
tags:
99
- skills
@@ -347,7 +347,10 @@ Use [scripts/parse-test-output.sh](scripts/parse-test-output.sh) to extract stru
347347

348348
**Q: How do I invoke a skill?**
349349

350-
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.
350+
A: Skills can be invoked in several ways:
351+
- **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.
352+
- **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.
353+
- **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.
351354

352355
**Q: How are skills different from prompts?**
353356

@@ -361,9 +364,9 @@ A: Yes! Skills are folders, not single files. You can bundle reference documents
361364

362365
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.
363366

364-
**Q: Can agents chain multiple skills?**
367+
**Q: Can I invoke multiple skills in one message?**
365368

366-
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.
369+
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.
367370

368371
**Q: Should skills include code examples?**
369372

0 commit comments

Comments
 (0)