aws / aws/amazon-q-developer-cli

bug: `conversation_start` hook triggers on every prompt instead of once per conversation

Open
#2,403 0 comments 0 reactions 0 assignees View on GitHub
needs-investigation
Dominant language
Rust
Stars
2k
Forks
439
PR merge metrics
No merged PRs in 30d

Description

### Checks

- [x] I have searched [github.com/aws/amazon-q-developer-cli/issues](https://github.com/aws/amazon-q-developer-cli/issues?q=) and there are no duplicates of my issue
- [x] I have run `q doctor` in the affected terminal session
- [x] I have run `q restart` and replicated the issue again

### Operating system

Windows 11 with WSL2 (Ubuntu) using integrated VS Code terminal

### Expected behaviour

I expected the following hook to run once at the start of each conversation, not on every prompt:
`/hooks add --trigger conversation_start`

This should behave differently from `--trigger per_prompt` and trigger only once per session.

### Actual behaviour

Despite using `--trigger conversation_start`, the hook is triggered on every single prompt. This makes it impossible to run setup logic only once per conversation.

Command used:
`/hooks add --trigger conversation_start --command 'context add .amazonq/rules/PROJECT_RULES.md' add_rules_on_session_start`

Each time I enter a prompt, the following error repeats:

`✗ add_rules_on_session_start failed after 0.06 s: command returned non-zero exit code: exit status: 127
✗ 0 of 1 hooks finished in 0.08 s`

I used `q doctor` and also restarted Q CLI, but the issue persists.

### Steps to reproduce

Steps:

1. Run the following command to add a hook:
`/hooks add --trigger conversation_start --command 'context add .amazonq/rules/PROJECT_RULES.md' add_rules_on_session_start`

2. Start a new conversation in Amazon Q CLI.

3. Enter any prompt (e.g., `nvm`, `dummy text`).

4. Observe that the hook runs on every prompt instead of only once at conversation start.

### Environment

```yaml
The Q diagnostic shows your system is running well:

## Q CLI Status
• **Version**: 1.12.7 (4 days old, current)
• **Variant**: minimal
• **Environment**: WSL2 Ubuntu 24.04.1 LTS

## System Information
• **CPU**: AMD Ryzen 5 7520U with Radeon Graphics (4 cores)
• **Memory**: 6.68 GB
• **Kernel**: WSL2 (6.6.87.2-microsoft-standard-WSL2)

## Environment
• **Current Directory**: /mnt/c/Users/mazar/cdk/q-integration-cdk-ts ✅
• **Shell**: /bin/bash
• **WSL**: Detected and running properly
• **Q Terminal Session**: Active (QTERM_SESSION_ID present)

## Key Observations
• You're in the correct project directory
• WSL2 environment is properly configured
• Q CLI is up-to-date and functioning
• PATH includes necessary tools (npm, node, git, etc.)

Everything looks good! Your Q CLI setup is working properly in your CDK
TypeScript project environment.
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.