Skip to content

proactive_tools

diapason.tools.proactive_tools

Proactive agent tools — check/record permissions, queue and execute actions.

These tools are used exclusively by ProactiveAgent to manage the propose → approve → execute lifecycle for autonomous actions.

Permission key convention: "{action_type}:{context_key}"

Approval response parsing

When the user replies to a pending-actions notification, their message is expected to contain one or more tokens of the form:

``{action_id} yes``   or   ``{action_id} no``
``yes {action_id}``   or   ``no {action_id}``
``always yes {action_id}``  →  approve + remember
``always no {action_id}``   →  deny + remember
``yes all``  /  ``no all``  →  bulk approve/deny all pending

Call parse_approval_response(text, store) from any channel message handler to process these replies without running the full agent.

CheckPermissionTool

Bases: BaseTool

Look up whether the user has a remembered decision for a permission key.

ExecutePendingActionsTool

Bases: BaseTool

Execute all approved (or trivial) actions and return a summary.

GetPendingActionsTool

Bases: BaseTool

Return all pending (not yet decided) actions as a JSON list.

QueueActionTool

Bases: BaseTool

Queue a proposed action for user approval or immediate execution.

RecordDecisionTool

Bases: BaseTool

Record a user approval or denial for a queued action.

parse_approval_response(text, store=None)

Parse a free-text message for approval tokens and update the store.

Returns a list of dicts describing each decision that was processed, for use in an acknowledgement message back to the user.

Call this from any channel message handler before routing the message to the main agent, e.g. inside the iMessage daemon or Telegram bot.