Skip to content

fix(macos): lazy-init AVAudioEngine to prevent Bluetooth audio ducking#31

Merged
steipete merged 2 commits intoopenclaw:mainfrom
Nachx639:fix/lazy-audio-engine
Dec 16, 2025
Merged

fix(macos): lazy-init AVAudioEngine to prevent Bluetooth audio ducking#31
steipete merged 2 commits intoopenclaw:mainfrom
Nachx639:fix/lazy-audio-engine

Conversation

@Nachx639
Copy link
Contributor

Summary

  • Make audioEngine optional in VoiceWakeRuntime and VoicePushToTalk
  • Create the engine only when voice recognition actually starts
  • Prevents macOS from switching Bluetooth profile at app launch

Problem

When Clawdis launches, it creates AVAudioEngine() instances at singleton init time (even with Voice Wake disabled). This causes macOS to switch Bluetooth headphones from A2DP (high quality stereo) to HFP (headset profile), resulting in noticeably degraded audio quality.

Solution

Make the AVAudioEngine property optional and lazy-initialize it only when start() is called. This way, users who don't use Voice Wake won't experience the Bluetooth profile switch.

Testing

  • Verified with Bluetooth headphones that audio quality no longer degrades when launching Clawdis
  • Voice Wake functionality remains intact when enabled

Fixes #30

🤖 Generated with Claude Code

Creating AVAudioEngine at singleton init time causes macOS to switch
Bluetooth headphones from A2DP (high quality) to HFP (headset) profile,
resulting in degraded audio quality even when Voice Wake is disabled.

This change makes audioEngine optional and only creates it when voice
recognition actually starts, preventing the profile switch for users
who don't use Voice Wake.

Fixes openclaw#30

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@steipete steipete force-pushed the fix/lazy-audio-engine branch from 0221060 to bcc5d78 Compare December 14, 2025 19:16
@steipete
Copy link
Contributor

Thanks @Nachx639 — this is a great catch.\n\nI rebased the PR onto main, fixed the SwiftFormat lint failure, added inline comments explaining the lazy AVAudioEngine init, and noted the change in CHANGELOG.md.

@steipete steipete merged commit b443c20 into openclaw:main Dec 16, 2025
1 check passed
dgarson referenced this pull request in dgarson/clawdbot Feb 2, 2026
@janitooor
Copy link

All Bridgebuilder Review Findings Addressed ✅

Pushed bf9214518 with fixes for all 7 findings:

CRITICAL

  • Workflow Engine Path Collision — Renamed WorkflowEngineHardenedExecutor in new hardened-executor.ts. Old engine.ts is now a backwards-compat re-export shim with @deprecated notice. This frees the engine.ts path for a future multi-step workflow engine (with start()/advance()/resume()) that can delegate to the hardened executor for step execution.

HIGH

  • Non-Atomic Audit Trail Recovery — Recovery rewrite now uses crash-safe tmp → fsync → rename → dirsync pattern (same as ResilientJsonStore.set()), so the recovery path is at least as durable as the happy path.
  • Boot Orchestrator Non-Null AssertionsServicesBag.auditTrail and lockManager are now optional (can be undefined in dev mode). redactor and logger get no-op fallbacks instead of undefined! assertions.

MEDIUM

  • AsyncMutex Logger Bypass — Constructor now accepts optional warn callback; lease expiry uses it instead of console.warn directly. Backwards compatible (defaults to console.warn).
  • Circuit Breaker Rolling WindowrecordSuccess() in CLOSED state no longer clears the failure window. Window is only cleared on HALF_OPEN → CLOSED transition. Stale records evict naturally via rollingWindowMs.
  • Supersession Documentation — Added @deprecated JSDoc to pii-redactor.tsSecretRedactor and audit-logger.tsAuditTrail.

LOW

  • IdempotencyIndex FIFO Cap — Added maxEntries config (default: 10,000) with FIFO eviction in both evict() and markPending() to prevent unbounded growth within TTL window.

All 391 tests pass across persistence (174), safety (156), boot (47), and workflow (14) suites.

4p0hk pushed a commit to 4p0hk/clawpok_base that referenced this pull request Feb 16, 2026
5 tests: react/remove, read/paginate, edit, delete, pin/unpin
against live mattermost server via mm-test.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
frodo-harborbot added a commit to harborworks/openclaw that referenced this pull request Feb 16, 2026
Based on harborworks/.openclaw config. Includes:
- Auth profile for Anthropic
- Agent defaults: opus model, main agent with workspace
- Telegram channel config (bot token from env)
- Telegram plugin enabled
- Tool sandbox allowlist
- Brave web search config
- Gateway auth token from env
- Heartbeat disabled by default (0m)
dalefrieswthat pushed a commit to dalefrieswthat/openclaw that referenced this pull request Feb 25, 2026
…ss (openclaw#31)

* test(discord): align loadConfig mock signature with source

* fix: async agent delegation — config bug, pruning, observability, normalization, prompts

- Fix maxPerCall config bug: broker was reading maxConcurrency for both
  limits; add dedicated maxPerCall field to VoiceCallSubagentConfigSchema
- Replace O(n) pruning on every state transition with lazy threshold-based
  pruning (amortized via PRUNE_THRESHOLD=16)
- Add BrokerMetrics type and metrics getter for observability: enqueued,
  completed, failed, expired, canceled, fallbacksSpoken, repairAttempts,
  repairSuccesses, totalExecutionMs
- Improve JSON normalization pipeline: strip markdown fences, trailing
  commas, single-line comments; case-insensitive key matching; expanded
  alias sets; export extractFirstJsonObject, parseBoolean, parseNumber
- Lighten repairPayload: thinkLevel=off, 4s timeout, truncate input to
  1000 chars, pass context through to avoid redundant loadCoreAgentDeps
- Clean up orphaned session store entries and temp files after job
  completion (finally block with fs.unlinkSync)
- Move foreground envelope prompt to end of system prompt with structured
  RESPONSE FORMAT heading; wrap conversation history in XML tags
- Add specialist-specific prompts (SPECIALIST_PROMPTS map) for research,
  scheduler, and policy roles
- Expand test coverage: 55 tests across broker and normalization suites
  covering pruning, metrics, deadline clamping, JSON extraction edge
  cases, alias resolution, type coercion, and specialist prompts

https://claude.ai/code/session_01SYcKJe4ySZthJSCkKxzbFZ

* fix: guard fallback rejection, fix deadline overrun, resolve prompt conflict

- Wrap speakFallbackIfActive in try/catch inside the runJob catch block
  to prevent unhandled promise rejections when onSummaryReady is broken
- Check remaining time before applying Math.max(1000ms) clamp so jobs
  that have already expired hit the expiry branch instead of launching
  a 1s LLM call past their deadline
- Replace "use tools when helpful" with delegation guidance in the
  foreground voice prompt to avoid contradicting the JSON-only envelope
  instruction — tools belong in the specialist background lane

https://claude.ai/code/session_01SYcKJe4ySZthJSCkKxzbFZ

* fix: JSON-aware trailing comma/comment repair, session orphan prevention

Replace naive regex-based stripTrailingCommas and stripJsonComments with
character-walking implementations that track whether we're inside a JSON
string literal, so commas and // sequences inside string values are never
corrupted.

Move session store cleanup into the finally block of runJob so entries are
removed on both success and failure paths.  Add reapOrphanedSessions()
method that sweeps stale voice-subagent:* keys older than a configurable
threshold, called at webhook server startup to catch entries orphaned by
crashes.

https://claude.ai/code/session_01SYcKJe4ySZthJSCkKxzbFZ

---------

Co-authored-by: Claude <noreply@anthropic.com>
zooqueen referenced this pull request in hanzoai/bot Feb 25, 2026
)

Route all Linux CI jobs to self-hosted runners (hanzo-k8s label) on
our DOKS cluster instead of GitHub-hosted ubuntu-latest. This
eliminates queue wait times and runs jobs on dedicated infrastructure.

Migrated workflows: ci.yml (8 jobs), workflow-sanity.yml,
install-smoke.yml, formal-conformance.yml, labeler.yml,
auto-response.yml, stale.yml.

Kept on GitHub runners: Android (needs JDK/Gradle/SDK),
Windows (needs Windows OS), macOS (needs Xcode/Swift),
Docker release (needs Docker), npm release (needs registry).

Adjusted test parallelism: BOT_TEST_WORKERS=1 for 4GiB runner pods.

Runners: 3x github-runner + 2x github-runner-build pods in
actions-runner-system namespace, org-scoped for hanzoai.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
songliu0403-rgb pushed a commit to songliu0403-rgb/openclaw that referenced this pull request Feb 26, 2026
elliot-ylambda added a commit to elliot-ylambda/magister-openclaw that referenced this pull request Mar 7, 2026
heatherstew44-maker pushed a commit to heatherstew44-maker/openclaw that referenced this pull request Mar 8, 2026
Piboonsak added a commit to Piboonsak/openclaw_github that referenced this pull request Mar 9, 2026
LyleLiu666 added a commit to LyleLiu666/openclaw-upstream-fork that referenced this pull request Mar 10, 2026
* Agents: respect reasoning on OpenAI WS

* Agents: avoid implicit WS reasoning summaries

---------

Co-authored-by: Lyle <lyle@example.com>
lucasmpramos added a commit to butley/openclaw that referenced this pull request Mar 10, 2026
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.

Headphones sound lowering after opening clawdis

3 participants