aws / aws/amazon-q-developer-cli

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

Offen
#2,403 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
needs-investigation
Vorherrschende Sprache
Rust
Sterne
2k
Forks
439
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

### 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.
```

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne damit, das Problem mit dem dokumentierten Befehl `/hooks add --trigger conversation_start` zu reproduzieren, und durchsuche anschließend die CLI nach der Verarbeitung der Trigger `conversation_start` und `per_prompt`. Überprüfe den Lebenszyklus der Hooks über eine neue Konversation und mehrere Prompts hinweg. Als abgeschlossen gilt die Aufgabe, wenn `conversation_start` einmal pro Konversation ausgeführt wird, während `per_prompt` sein aktuelles Verhalten beibehält, und ein Regressionstest beide Trigger abdeckt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
bash, rust
Bereich
cli
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
50/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.