Skip to content

approval_bridge

diapason.server.approval_bridge

Chat tool confirmations, answered through the existing approval bell.

The tool executor calls a synchronous confirm_callback(prompt) -> bool whenever a tool declares requires_confirmation. Until now the server either hardcoded lambda _prompt: True (managed-agents chat) or passed nothing at all (main chat agent), so confirmation-gated tools ran silently or failed outright. This bridge gives that callback a real answer path:

  • agent.tool_approval = "auto" — legacy opt-in that confirms immediately.
  • agent.tool_approval = "ask" — queue the confirmation into the ApprovalStore that already feeds the frontend bell (GET /v1/approvals/pending + approve/deny), then wait for the user's decision. Timeout or denial refuses the tool.

The callback runs in the tool executor's worker thread, so blocking here never blocks the event loop; the store is opened per call because sqlite connections do not travel across threads.

announce_approval(title, body)

Poser une demande dans les notifications sans bloquer l'appelant.

EN TÂCHE DE FOND, et c'est le point : notifier_macos attend osascript jusqu'à dix secondes (livraison.py), soit près du quart du budget vocal de quarante-cinq. L'attente d'approbation ne doit pas financer sa propre annonce. Best-effort et silencieuse : une notification ratée ne fait pas tomber le tour d'outil qu'elle accompagne.

current_mode()

The configured approval mode, defensively normalized.

resumer_la_demande(prompt)

La demande en une ligne lisible, pour le centre de notifications.

tool_confirm_callback(wait_s=DEFAULT_WAIT_S)

Build the confirm callback for chat agents.

The mode is read at CALL time, not build time: flipping the composer chip applies to the very next tool, no server restart involved.