Skip to content

UserPromptSubmit hook stdout not injected into LLM context #370

@aranej

Description

@aranej

Problem

UserPromptSubmit hooks execute successfully but their stdout is not injected into the LLM context, despite documentation stating it should be.

Expected: Hook stdout added to context before prompt processing
Actual: Hook runs, outputs to stdout, but LLM never receives it

Evidence

Debug logging proves hook execution:

[2025-11-15 16:16:05.140072] UserPromptSubmit hook executed
[2025-11-15 16:16:05.140387] Output: ⏰ 2025-11-15 16:16:05
[2025-11-15 16:21:56.081558] UserPromptSubmit hook executed
[2025-11-15 16:21:56.081900] Output: ⏰ 2025-11-15 16:21:56
  • ✅ Hook executes on every prompt
  • ✅ Generates correct stdout
  • ✅ Exit code 0
  • ❌ LLM context doesn't contain the output

Reproduction

1. Create hook script (~/.factory/hooks/timestamp.py):

#!/usr/bin/env python3
from datetime import datetime
from zoneinfo import ZoneInfo

tz = ZoneInfo('Europe/Bratislava')
timestamp = datetime.now(tz).strftime('%Y-%m-%d %H:%M:%S')

print(f"⏰ {timestamp}")  # stdout per docs
exit(0)
chmod +x ~/.factory/hooks/timestamp.py

2. Configure hook (~/.factory/settings.json):

{
  "enableHooks": true,
  "hooks": {
    "UserPromptSubmit": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "~/.factory/hooks/timestamp.py"
          }
        ]
      }
    ]
  }
}

3. Restart DROID, send any prompt

Result: LLM response contains no timestamp. Hook output invisible to LLM.

Tested Approaches (All Failed)

  1. Bash echo: echo "⏰ $(date '+%Y-%m-%d %H:%M:%S')"
  2. Python JSON: {"hookSpecificOutput": {"additionalContext": "..."}}
  3. Python plain stdout: print(f"⏰ {timestamp}") (per docs example)

All execute successfully (verified via debug logging), but none inject stdout into context.

Environment

  • DROID CLI: v0.26.1 (Nov 14, 2025)
  • OS: Linux (Ubuntu 22.04, Kernel 6.8.0-85-generic)
  • Server: Hetzner CX32 VPS (8GB RAM, 4 vCPU)
  • Python: 3.12.3
  • Settings: ~/.factory/settings.json (user settings)

Notes

  • UserPromptSubmit feature added in v0.25.0 (Nov 13) - tested 1 day later
  • Use case (timestamp context) is explicitly shown in official docs example
  • Current workaround: prompt-based approach (less efficient but functional)

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions