voicemode icon indicating copy to clipboard operation
voicemode copied to clipboard

feat: hold_conch — exclusive voice access across turns + pause_conversation tool

Open mcteamster opened this issue 5 months ago • 1 comments

Summary

Adds two related features for multi-agent voice coordination:

1. hold_conch parameter on converse

A new hold_conch: bool parameter that, when True, sets a hold between turns so other agents queue rather than speak while the holding agent is processing.

How it works:

  • After each converse call with hold_conch=True, a conch_hold file is written to ~/.voicemode/conch_hold with the holding process's PID
  • Other agents calling try_acquire() check is_held_by_other() and return False immediately if a hold is active
  • The hold is released on the next converse call with hold_conch=False (the default), or automatically when the holding process exits (dead PID check)

New Conch class methods:

  • Conch.set_hold(agent_name) — write the hold file
  • Conch.release_hold() — remove it (PID-checked, won't clobber another agent's hold)
  • Conch.is_held_by_other() — returns True if another live process holds

2. pause_conversation(seconds, message=None) MCP tool

A new tool that sleeps for a specified duration while holding the conch, blocking other agents for the full duration.

  • Calculates resume time at call time and logs it immediately (e.g. Pause started: 30s, resuming at 22:09:45)
  • message parameter should be set to the calculated resume time (e.g. "Resuming at 22:09:45") — it appears in the tool call display in the client UI while the pause is running, giving the user visibility without any streaming
  • Returns "Pause complete. Resumed at HH:MM:SS (after Xs)." when done
  • Max safe duration ~5 min due to MCP client timeouts

Testing

Tested with two concurrent agents (Agent A holding, Agent B queuing) in a live multi-agent session:

  1. Agent A calls converse(..., hold_conch=True) — speaks and sets the hold
  2. Agent B calls converse(..., wait_for_conch=True) — correctly queues and does not speak
  3. Agent A calls pause_conversation(seconds=30, message="Resuming at HH:MM:SS") — hold is maintained for the full 30s; Agent B continues waiting throughout
  4. Agent A calls converse(..., hold_conch=False) — releases hold; Agent B acquires and speaks

Known limitations / discussion points for maintainer

⚠️ skip_conch=True overrides hold_conch — observed in testing

Observed behaviour: When Agent B timed out waiting (CONCH_TIMEOUT default 60s) while Agent A held the conch, Agent B fell back to calling converse(skip_conch=True) and successfully spoke over Agent A's held conversation. The hold was completely bypassed.

skip_conch=True skips the hold file check entirely — it does not call try_acquire() or is_held_by_other(). So a held conversation is not protected against agents using skip_conch.

The current skip_conch docstring describes this as intentional: "speak immediately regardless of whether another agent holds it". But this makes hold_conch not truly exclusive. A possible alternative semantics: skip_conch jumps the queue but still respects an active hold. Left for the maintainer to decide — raising it here for visibility.

⚠️ CONCH_TIMEOUT (default 60s) interacts poorly with long holds

Observed behaviour: Agent B with wait_for_conch=True timed out after 60s while Agent A held across a pause_conversation(seconds=180). After timeout, Agent B had no coordination option left other than skip_conch.

With hold_conch now enabling intentional holds longer than 60s, the default timeout may need revisiting — or agents should be instructed to use a longer timeout when they know a long hold is in progress.

Stale hold file — no permanent lockout risk

If the holding process dies without calling release_hold(), the hold file is left on disk. However, is_held_by_other() always verifies liveness via os.kill(pid, 0) before returning True. A dead PID raises ProcessLookupError, which is caught, and is_held_by_other() returns False — so other agents can always proceed past a stale hold. There is no risk of a permanent lockout.

The orphaned file is harmless but does accumulate. Active cleanup (same pattern as _check_and_clear_stale_lock) could be added to is_held_by_other() or release_hold() if desired.

mcteamster avatar Jun 07 '26 12:06 mcteamster

@ai-cora could you please help review?

mcteamster avatar Jun 07 '26 12:06 mcteamster

Thank you, Tony — this is excellent work and it shipped. Your design and original patch landed as VM-1433 (conch holdership), reimplemented on a single-file model (the hold is the existing conch left in place and marked, rather than a second conch_hold file) to avoid the release→set_hold and pause-clobber races a two-file design invites. Both hold_conch on converse and the pause_conversation tool are now on master, and you're credited by name in the CHANGELOG. We also root-fixed the two limitations you flagged: wait_for_conch now waits through a live hold (so agents no longer auto-fall-back to skip_conch over a held floor), and the conch timeout default rose 60→300s. Closing as landed-with-credit. Hugely appreciated — see commits 0f2451d / 2b44263 / 57939d1.

ai-cora avatar Jun 16 '26 16:06 ai-cora