aws / aws/amazon-q-developer-cli

Custom Agent agendSpawn hook running for all prompts

Open
#2,623 2 comments 0 reactions 0 assignees View on GitHub
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

macOS 15.6.0 (24G84)

### Expected behaviour

This is my full custom agent config:
```
{
"name": "hbt",
"description": "redacted",
"resources": [
"redacted"
],
"tools": [
"*"
],
"allowedTools": [
"fs_read"
],
"toolsSettings": {
"execute_bash": {
"alwaysAllow": [
{
"preset": "readOnly"
}
]
}
},
"hooks": {
"agentSpawn": [
{
"command": "pwd",
"timeout_ms": 5000
},
{
"command": "git status",
"timeout_ms": 5000
}
]
},
"mcpServers": {

}
}
```

And I expected the `git status` agentSpawn hook to only run on init.

### Actual behaviour

But if I initialise this agent in a non-git folder, it seems the command is being run for every propmt. See below conversation:
```
🤖 You are chatting with claude-4-sonnet

[hbt] > hello

✗ git status failed after 0.04 s: command returned non-zero exit code: exit status: 128
✗ 0 of 1 hooks finished in 0.08 s
> Hello! I'm Amazon Q, ready to help you with AWS, software development, and system administration tasks. I can assist with:

• Reading and writing files in your current directory (/Users/nvnpetla)
• Executing bash commands
• Making AWS CLI calls
• Code development and debugging
• Infrastructure configurations
• HBT team-specific work with agents and knowledge bases

What would you like to work on today?

[hbt] > how are you?

✗ git status failed after 0.04 s: command returned non-zero exit code: exit status: 128
✗ 0 of 1 hooks finished in 0.09 s
> I'm functioning well and ready to help with your technical tasks. What can I assist you with today?

[hbt] > hello there

✗ git status failed after 0.05 s: command returned non-zero exit code: exit status: 128
✗ 0 of 1 hooks finished in 0.09 s
> Hello! What can I help you with?

[hbt] >
```

```
[chat-transcript]
> hello

Hello! I'm Amazon Q, ready to help you with AWS, software development, and technical tasks. I can assist with code, infrastructure, CLI commands, file operations, and more.

What would you like to work on today?
[Tool uses: none]

> /context hooks

> hello again

Hello again! How can I help you today?
[Tool uses: none]

> yet another hello

Hi there! What can I help you with?
[Tool uses: none]

> q issue

I can help you report an issue with Amazon Q. Let me open the issue reporting tool for you.
[Tool uses: report_issue]

The issue reporting form should now be open in your browser. You can provide details about:

- What issue you're experiencing
- Steps to reproduce the problem
- Expected vs actual behavior
- Any error messages

Is there a specific issue you'd like help troubleshooting before submitting the report?
[Tool uses: none]

> q issue

[Tool uses: report_issue]
```

### Steps to reproduce

1. Create a simple custom Q agent configuration with agentSpawn hook for `git status` to be run.
2. Initialise q chat from a non-git folder
3. run multiple prompts and see the conversation trying to run the agentSpawn hook everytime and failing.

### Environment

```yaml

[q-details]
version = "1.13.3"
hash = "0c82fc60be46f6a51eff3da52861611e534e39a6"
date = "2025-08-11T21:20:15.725305Z (4d ago)"

[system-info]
os = "macOS 15.6.0 (24G84)"
chip = "Apple M3 Pro"
total-cores = 12
memory = "36.00 GB"

[environment]
cwd = "/Volumes/workplace"
cli-path = "/Volumes/workplace"
install-method = "unknown"

[env-vars]
PATH = "/Users/USER/.local/share/mise/installs/python/3.12.7/bin:/Users/USER/.local/share/mise/installs/python/3.11.10/bin:/Users/USER/.local/share/mise/installs/python/3.10.15/bin:/Users/USER/.local/share/mise/installs/python/3.9.20/bin:/Users/USER/.local/share/mise/installs/python/3.8.20/bin:/Users/USER/.local/share/mise/installs/node/18.20.8/bin:/Users/USER/.config/smithy-mcp/mcp-servers:/opt/homebrew/opt/curl/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/USER/.config/smithy-mcp/mcp-servers:/Users/USER/.nvm/versions/node/v20.19.2/bin:/opt/homebrew/opt/curl/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Users/USER/.cargo/bin:/Users/USER/.local/bin:/Applications/Visual Studio Code.app/Contents/Resources/app/bin:/Users/USER/.toolbox/bin:/Library/Java/JavaVirtualMachines/amazon-corretto-8.jdk/Contents/Home:/Users/USER/Library/Android/sdk/tools:/Users/USER/Library/Android/sdk/tools/bin:/Users/USER/Library/Android/sdk/platform-tools:/Library/Java/JavaVirtualMachines/amazon-corretto-8.jdk/Contents/Home:/Users/USER/Library/Android/sdk/tools:/Users/USER/Library/Android/sdk/tools/bin:/Users/USER/Library/Android/sdk/platform-tools"
QTERM_SESSION_ID = "4568906ed41e4870b093bb568d651bf1"
Q_SET_PARENT_CHECK = "1"
Q_TERM = "1.13.3"
SHELL = "/bin/zsh"
TERM = "xterm-256color"
__CFBundleIdentifier = "com.apple.Terminal"

[chat-settings]

[chat-trusted_tools]
redacted
fs_read=trusted
redacted
report_issue=trusted

[chat-failed_request_ids]
none

[chat-context]
current_profile=hbt
profile_context=
README.md
redacted

files=
redacted
total context size=3460 tkns
```

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.