Skip to content

Conversation

@sti0
Copy link
Contributor

@sti0 sti0 commented Jan 5, 2026

Summary

Adds VOICE_STRICT_MODE environment variable to control voice notification behavior in the stop-hook-voice system. When enabled, voice notifications only trigger when an explicit COMPLETED message is detected in the assistant's response—eliminating unwanted "Completed task" fallback notifications.

Problem

The current implementation falls back to speaking "Completed task" whenever no COMPLETED pattern is found in the response. This creates unwanted voice notifications for:

  • Intermediate responses during multi-step workflows
  • Conversational exchanges that don't represent task completions
  • Error messages or clarification requests

Solution

Introduce VOICE_STRICT_MODE environment variable with the following behavior:

VOICE_STRICT_MODE COMPLETED Found Result
unset / false Yes ✅ Speak completion message
unset / false No ✅ Speak "Completed task" (fallback)
true / 1 Yes ✅ Speak completion message
true / 1 No 🔇 Skip silently

Changes

Code (Packs/kai-voice-system/src/hooks/stop-hook-voice.ts)

  • Add isStrictMode constant reading VOICE_STRICT_MODE env var (supports true and 1)
  • Change extractCompletion() return type from string to string | null
  • Return null instead of fallback when strict mode enabled and no COMPLETED found
  • Add if (completion) guard in main() to skip notification when null

Documentation (Packs/kai-hook-system/README.md)

  • Add VOICE_STRICT_MODE to environment variables table
  • Bump version to 1.1.0
  • Add changelog entry

Configuration

Enable in your environment or $PAI_DIR/.env:

VOICE_STRICT_MODE=true

Test Plan

  • Default behavior preserved: Without VOICE_STRICT_MODE, fallback to "Completed task" still works
  • Strict mode + COMPLETED present: Voice notification fires with extracted message
  • Strict mode + no COMPLETED: Silent skip (no notification sent)
  • Build verification: TypeScript compiles without errors

Backward Compatibility

✅ Fully backward compatible - Existing behavior unchanged when VOICE_STRICT_MODE is unset or false.


🤖 Generated with https://claude.com/claude-code

@sti0 sti0 changed the title feat(voice): Add VOICE_STRICT_MODE for conditional voice notifications DRAFT: feat(voice): Add VOICE_STRICT_MODE for conditional voice notifications Jan 6, 2026
…found

Add environment variable to control voice notification behavior:
- When unset/false: Current behavior (fallback to "Completed task")
- When true/1: Skip voice notification silently if no COMPLETED found

Changes:
- Add isStrictMode constant checking VOICE_STRICT_MODE env var
- Change extractCompletion() return type to string | null
- Add null guard in main() to skip notification when completion is null
- Document VOICE_STRICT_MODE in kai-voice-system README
- Bump kai-voice-system version to 1.4.0

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@sti0 sti0 force-pushed the feature/voice-strict-mode branch from 8a07ea8 to 8a06bcb Compare January 6, 2026 09:38
@sti0 sti0 changed the title DRAFT: feat(voice): Add VOICE_STRICT_MODE for conditional voice notifications feat(voice): Add VOICE_STRICT_MODE for conditional voice notifications Jan 6, 2026
@danielmiessler
Copy link
Owner

Thank you @sti0 for the VOICE_STRICT_MODE concept! 🙏

Your voice system contributions have been fantastic. PAI v2.1 restructured everything (kai-*pai-*), so this would need to be re-applied to pai-voice-system.

See the release: https://github.com/danielmiessler/PAI/releases/tag/v2.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants